Package jade.core

Examples of jade.core.MainContainer


      //log("Transferring identity of agent "+agentID+" from "+src.getName()+" to "+dest.getName(), 2);
      if(myLogger.isLoggable(Logger.FINE))
        myLogger.log(Logger.FINE,"Transferring identity of agent "+agentID+" from "+src.getName()+" to "+dest.getName());
     
     
      MainContainer impl = myContainer.getMain();
      if(impl != null) {
        AgentDescriptor ad = impl.acquireAgentDescriptor(agentID);
        if (ad != null) {
          try {
            AgentMobilitySlice srcSlice = (AgentMobilitySlice)getSlice(src.getName());
            AgentMobilitySlice destSlice = (AgentMobilitySlice)getSlice(dest.getName());
            boolean srcReady = false;
            boolean destReady = false;
           
            try {
              srcReady = srcSlice.prepare();
            }
            catch(IMTPException imtpe) {
              srcSlice = (AgentMobilitySlice)getFreshSlice(src.getName());
              srcReady = srcSlice.prepare();
            }
            //log("Source "+src.getName()+" "+srcReady, 2);
            if(myLogger.isLoggable(Logger.FINE))
              myLogger.log(Logger.FINE,"Source "+src.getName()+" "+srcReady);
           
           
            try {
              destReady = destSlice.prepare();
            }
            catch(IMTPException imtpe) {
              destSlice = (AgentMobilitySlice)getFreshSlice(dest.getName());
              destReady = destSlice.prepare();
            }
            //log("Destination "+dest.getName()+" "+destReady, 2);
            if(myLogger.isLoggable(Logger.FINE))
              myLogger.log(Logger.FINE,"Destination "+dest.getName()+" "+destReady);
           
           
            if(srcReady && destReady) {
              // FIXME: We should issue a TRANSFER_IDENTITY V-Command to allow migration tracing and prevention
              // Commit transaction
              movedAgent(agentID, (ContainerID)src, (ContainerID)dest);
              replicationHandle.invokeReplicatedMethod("movedAgent", new Object[]{agentID, (ContainerID)src, (ContainerID)dest});
              return true;
            }
            else {
              // Problems on a participant slice: abort transaction
              return false;
            }
          }
          catch(Exception e) {
            // Link failure: abort transaction
            //log("Link failure!", 2);
            if(myLogger.isLoggable(Logger.WARNING))
              myLogger.log(Logger.WARNING,"Link failure!");
           
            return false;
          }
          finally {
            impl.releaseAgentDescriptor(agentID);
          }
        }
        else {
          throw new NotFoundException("Agent agentID not found");
        }
View Full Code Here


      }
    }
  }
 
  private ContainerID getAgentLocation(AID agentID) throws IMTPException, NotFoundException {
    MainContainer impl = myContainer.getMain();
    if(impl != null) {
      agentID = resolveGlobalAlias(agentID);
      return impl.getContainerID(agentID);
    }
    else {
      // Should never happen
      throw new NotFoundException("getAgentLocation() invoked on a non-main container");
    }
View Full Code Here

  void deliverInLocalPlatfrom(GenericMessage msg, AID receiverID) throws IMTPException, ServiceException, NotFoundException, JADESecurityException {
    if (msg.getTraceID() != null) {
      myLogger.log(Logger.INFO, msg.getTraceID() + " - Activating local-platform delivery");
    }
   
    MainContainer impl = myContainer.getMain();
    if (impl != null) {
      // Directly use the GADT on the main container
      while (true) {
        ContainerID cid = getAgentLocation(receiverID);
        MessagingSlice targetSlice = oneShotDeliver(cid, msg, receiverID);
View Full Code Here

          return true;
        }
        else {
          // Check in the GADT
          try {
            MainContainer impl = myContainer.getMain();
            if(impl != null) {
              // Directly use the GADT on the main container
              getAgentLocation(id);
            }
            else {
View Full Code Here

  }
 
  // Modify GADT to reflect an agent clonation
  // Public since it is replicated by the MainReplicationService
  public void bornAgent(AID agentID, ContainerID cid, JADEPrincipal principal, String ownership, boolean forceReplacement) throws NameClashException, NotFoundException {
    MainContainer impl = myContainer.getMain();
    try {
      impl.bornAgent(agentID, cid, principal, ownership, forceReplacement);
    }
    catch(NameClashException nce) {
      try {
        ContainerID oldCid = impl.getContainerID(agentID);
        Node n = impl.getContainerNode(oldCid).getNode();
       
        // Perform a non-blocking ping to check...
        n.ping(false);
       
        // Ping succeeded: rethrow the NameClashException
        throw nce;
      }
      catch(NameClashException nce2) {
        throw nce2; // Let this one through...
      }
      catch(Exception e) {
        // Ping failed: forcibly replace the dead agent...
        impl.bornAgent(agentID, cid, null, ownership, true);
      }
    }
  }
View Full Code Here

  protected void initPlatformController() throws ControllerException {
    if (myPlatformController == null) {
      if (myImpl == null) {
        throw new ControllerException("Stale proxy.");
      }
      MainContainer main = myImpl.getMain();
      if (main == null) {
        throw new ControllerException("Not a Main Container.");
      }
      if (main instanceof AgentManager) {
        myPlatformController = new PlatformControllerImpl(this, (AgentManager) main);
View Full Code Here

      JADEPrincipal owner = (JADEPrincipal) params[4];
      Credentials initialCredentials = (Credentials) params[5];
     
      if(myLogger.isLoggable(Logger.CONFIG))
        myLogger.log(Logger.CONFIG,"Source Sink consuming command REQUEST_CREATE. Name is "+name);
      MainContainer impl = myContainer.getMain();
      if(impl != null) {
        AID agentID = new AID(name, AID.ISLOCALNAME);
        AgentManagementSlice targetSlice = (AgentManagementSlice)getSlice(cid.getName());
        if (targetSlice != null) {
          try {
View Full Code Here

     
      //log("Source Sink consuming command REQUEST_KILL. Name is "+agentID.getName(), 3);
      if(myLogger.isLoggable(Logger.CONFIG))
        myLogger.log(Logger.CONFIG,"Source Sink consuming command REQUEST_KILL. Name is "+agentID.getName());
     
      MainContainer impl = myContainer.getMain();
      if(impl != null) {
        ContainerID cid = impl.getContainerID(agentID);
        // Note that since getContainerID() succeeded, targetSlice can't be null
        AgentManagementSlice targetSlice = (AgentManagementSlice)getSlice(cid.getName());
        try {
          targetSlice.killAgent(agentID, cmd);
        }
View Full Code Here

      }
      else if(as.equals(jade.domain.FIPAAgentManagement.AMSAgentDescription.ACTIVE)) {
        newState = Agent.AP_ACTIVE;
      }
     
      MainContainer impl = myContainer.getMain();
      if(impl != null) {
        ContainerID cid = impl.getContainerID(agentID);
        // Note that since getContainerID() succeeded, targetSlice can't be null
        AgentManagementSlice targetSlice = (AgentManagementSlice)getSlice(cid.getName());
        try {
          targetSlice.changeAgentState(agentID, newState);
        }
View Full Code Here

   
    private void handleAddTool(VerticalCommand cmd) {
      Object[] params = cmd.getParams();
      AID tool = (AID)params[0];
     
      MainContainer impl = myContainer.getMain();
      if(impl != null) {
        impl.toolAdded(tool);
      }
      else {
        // Do nothing for now, but could also route the command to the main slice, thus enabling e.g. AMS replication
      }
    }
View Full Code Here

TOP

Related Classes of jade.core.MainContainer

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.