Package jade.util.leap

Examples of jade.util.leap.List


    }
   
    private void handleDebugOff(VerticalCommand cmd) throws IMTPException, ServiceException, NotFoundException {
      Object[] params = cmd.getParams();
      AID introspector = (AID)params[0];
      List targets = (List)params[1];
     
      MainContainer impl = myContainer.getMain();
      if(impl != null) {
        // Deactivate debugging each element of the list
        Iterator it = targets.iterator();
        while(it.hasNext()) {
          AID target = (AID)it.next();
          ContainerID cid = impl.getContainerID(target);
         
          NotificationSlice slice = (NotificationSlice)getSlice(cid.getName());
View Full Code Here


      }
      tn.addObservedAgent(targetName);
     
      // Update the map of debuggers currently debugging the targetName agent
      synchronized (debuggers) {
        List l = (List) debuggers.get(targetName);
        if (l == null) {
          l = new LinkedList();
          debuggers.put(targetName, l);
        }
        if (!l.contains(introspectorName)) {
          l.add(introspectorName);
        }
      }
     
      Agent a = myContainer.acquireLocalAgent(targetName);
     
      // Activate generation of behaviour-related events on the
      // target agent
      a.setGenerateBehaviourEvents(true);
     
      // Retrieve the current agent state
      AgentState as = a.getAgentState();
     
      // Retrieve the list of pending ACL messages
      List messages = new LinkedList();
      myContainer.fillListFromMessageQueue(messages, a);
     
      // Retrieve the list of ready and blocked agent behaviour IDs
      List readyBehaviours = new LinkedList();
      myContainer.fillListFromReadyBehaviours(readyBehaviours, a);
      List blockedBehaviours = new LinkedList();
      myContainer.fillListFromBlockedBehaviours(blockedBehaviours, a);
     
      myContainer.releaseLocalAgent(targetName);
     
      // Notify all the needed events 
      fireChangedAgentState(targetName, as, as);
     
      Iterator itReady = readyBehaviours.iterator();
      while(itReady.hasNext()) {
        BehaviourID bid = (BehaviourID)itReady.next();
        AgentEvent ev = new AgentEvent(AgentEvent.ADDED_BEHAVIOUR, targetName, bid, myContainer.getID());
        tn.addedBehaviour(ev);
      }
     
      Iterator itBlocked = blockedBehaviours.iterator();
      while(itBlocked.hasNext()) {
        BehaviourID bid = (BehaviourID)itBlocked.next();
        AgentEvent ev = new AgentEvent(AgentEvent.ADDED_BEHAVIOUR, targetName, bid, myContainer.getID());
        tn.addedBehaviour(ev);
        ev = new AgentEvent(AgentEvent.CHANGED_BEHAVIOUR_STATE, targetName, bid, Behaviour.STATE_READY, Behaviour.STATE_BLOCKED, myContainer.getID());
View Full Code Here

        tn.removeObservedAgent(targetName);
      }
     
      boolean resetGenerateBehaviourEvents = true;
      synchronized (debuggers) {
        List l = (List) debuggers.get(targetName);
        if (l != null) {
          l.remove(introspectorName);
          if (l.size() > 0) {
            // There is still at least 1 debugger debugging the agent
            // Do not stop generation of behaviour events
            resetGenerateBehaviourEvents = false;
          }
          else {
View Full Code Here

        // SNIFF ON
        SniffOn requestSniffOn = (SniffOn) aa;
        // Start sniffing existing agents.
        // Put non existing agents in the preload map. We will start
        // sniffing them as soon as they start.
        List agentsToSniff = requestSniffOn.getCloneOfSniffedAgents();                     
        for (int i=0;i<agentsToSniff.size();i++) {
          AID aid = (AID)agentsToSniff.get(i);
          if (allAgents.contains(aid)) {
            addAgent(aid);
          }
          else {
            //not alive -> put it into preload
            int performativeCount = ACLMessage.getAllPerformativeNames().length;
            boolean[] filter = new boolean[performativeCount];
            for (int j=0; j<performativeCount;j++) {
              filter[j] = true;
            }
            preload.put(aid.getName(), filter);                 
          }
        }                                   
      }
      else {
        // SNIFF OFF
        SniffOff requestSniffOff = (SniffOff) aa;
        List agentsToSniff = requestSniffOff.getCloneOfSniffedAgents();                     
        for (int i=0;i<agentsToSniff.size();i++) {
          AID aid = (AID)agentsToSniff.get(i);
          removeAgent(aid);
        }
      }

      // Send back the notification
View Full Code Here

 
  // Transfer all local alias entries for a given agent on a remote container
  // This is executed when an agent moves
  void transferLocalAliases(AID agent, ContainerID dest) {
    myLogger.log(Logger.FINE, "Transferring all local alias entries for agent "+agent.getLocalName()+" to "+dest.getName());
    List aliases = removeLocalAliases(agent);
    if (aliases.size() > 0) {
      try {
        MessagingSlice destSlice = (MessagingSlice) getSlice(dest.getName());
        destSlice.transferLocalAliases(agent, aliases);
      }
      catch (Exception e) {
View Full Code Here

 
  // Remove all global alias entries for a given agent
  // Public since it is replicated by the MainReplicationService
  public void removeGlobalAliases(AID agent) {
    myLogger.log(Logger.FINE, "Removing all global alias entries for agent "+agent.getLocalName());
    List removedAliases = removeEntriesFor(globalAliases, agent);
    // Notify listeners
    Iterator it = removedAliases.iterator();
    while (it.hasNext()) {
      AID alias = (AID) it.next();
      notifyAliasListeners(alias, agent, false);
    }
  }
View Full Code Here

    }
  }
 
  // Remove all entries that maps to a given target
  private List removeEntriesFor(Hashtable table, Object target) {
    List removedKeys = new ArrayList();
    synchronized (table) {
      java.util.Iterator it = table.entrySet().iterator();
      while (it.hasNext()) {
        java.util.Map.Entry entry = (java.util.Map.Entry) it.next();
        if (entry.getValue().equals(target)) {
          removedKeys.add(entry.getKey());
          it.remove();
        }
      }
    }
    return removedKeys;
View Full Code Here

  /**
   Searches the White Pages for agents whose description matches a given
   template.
   */
  public List amsSearch(AMSAgentDescription template, long maxResults) {
    List results = new ArrayList();
    AID[] ids = platformAgents.keys();
    for (int i = 0; i < ids.length; ++i) {
      try {
        AMSAgentDescription amsd = getAMSDescription(ids[i]);
        if (match(template, amsd)) {
          results.add(amsd);
          if (results.size() >= maxResults) {
            break;
          }
        }
      }
      catch (NotFoundException nfe) {
View Full Code Here

 
  /**
   Return all agents living on a container
   */
  public List containerAgents(ContainerID cid) throws NotFoundException {
    List agents = new ArrayList();
    AID[] allIds = platformAgents.keys();
   
    for (int i = 0; i < allIds.length; ++i) {
      AID    id = allIds[i];
      AgentDescriptor ad = platformAgents.acquire(id);
      if (ad != null) {
        ContainerID cid1 = ad.getContainerID();
       
        if (cid.equals(cid1)) {
          agents.add(id);
        }
        platformAgents.release(id);
      }
    }
    return agents;
View Full Code Here

    }
  }
 
  private void removeAllMTPs(ContainerID cid) {
    try {
      List l = containers.getMTPs(cid);
      Object[] objs = l.toArray();
      for(int i = 0; i < objs.length; i++) {
        MTPDescriptor mtp = (MTPDescriptor)objs[i];
       
        GenericCommand gCmd = new GenericCommand(jade.core.messaging.MessagingSlice.DEAD_MTP, jade.core.messaging.MessagingSlice.NAME, null);
        gCmd.addParam(mtp);
View Full Code Here

TOP

Related Classes of jade.util.leap.List

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.