// #APIDOC_EXCLUDE_BEGIN public static void notifyFailureToSender(ACLMessage msg, String sender, String error) { if (myFrontEnd != null) { // Send back a failure message try { Iterator it = msg.getAllReceiver(); while (it.hasNext()) { AID receiver = (AID) it.next(); // If this receiver is local, the message has certainly been delivered // successfully --> Do not send any FAILURE back for this receiver if (myFrontEnd.getLocalAgent(receiver.getLocalName()) == null) { ACLMessage failure = msg.createReply(); failure.setPerformative(ACLMessage.FAILURE); failure.setSender(myFrontEnd.getAMS()); failure.setLanguage(FIPANames.ContentLanguage.FIPA_SL); String content = "( (action " + sender; content = content + " (ACLMessage) ) (MTS-error " + receiver + " \"" + error + "\") )"; failure.setContent(content); myFrontEnd.messageIn(failure, sender); } } } catch (Exception e1) { logger.log(Logger.SEVERE, "Error delivering FAILURE message.", e1); } } }
private static void initCouple(Properties basePP, String prefix, int index) { String senderClass = "jade.core.ScalabilityTest$BitrateSenderAgent"; String receiverClass = "jade.core.ScalabilityTest$BitrateReceiverAgent"; if (measure == RTT_MEASURE) { senderClass = "jade.core.ScalabilityTest$RTTSenderAgent"; receiverClass = "jade.core.ScalabilityTest$RTTReceiverAgent"; } Properties pp = (Properties) basePP.clone(); /*Properties pp = new Properties(); if (host != null) { pp.setProperty(MicroRuntime.HOST_KEY, host); } if (port != null) { pp.setProperty(MicroRuntime.PORT_KEY, port); } if (proto != null) { pp.setProperty(MicroRuntime.PROTO_KEY, proto); } if (maxDiscTime != null) { pp.setProperty(JICPProtocol.MAX_DISCONNECTION_TIME_KEY, maxDiscTime); }*/ String sName = "S-" + prefix + "-" + index; pp.setProperty(PDPContextManager.MSISDN, sName); String rName = "R-" + prefix + "-" + index; String prop = sName + ":" + senderClass + "(" + rName + ")"; pp.setProperty(MicroRuntime.AGENTS_KEY, prop); // pp.setProperty(JICPProtocol.KEEP_ALIVE_TIME_KEY, "-1"); FrontEndContainer fes = new FrontEndContainer(); fes.start(pp); pp = (Properties) basePP.clone(); /*pp = new Properties(); if (host != null) { pp.setProperty(MicroRuntime.HOST_KEY, host); } if (port != null) { pp.setProperty(MicroRuntime.PORT_KEY, port); } if (proto != null) { pp.setProperty(MicroRuntime.PROTO_KEY, proto); } if (maxDiscTime != null) { pp.setProperty(JICPProtocol.MAX_DISCONNECTION_TIME_KEY, maxDiscTime); }*/ pp.setProperty(PDPContextManager.MSISDN, rName); prop = rName + ":" + receiverClass; pp.setProperty(MicroRuntime.AGENTS_KEY, prop); // pp.setProperty(JICPProtocol.KEEP_ALIVE_TIME_KEY, "-1"); FrontEndContainer fer = new FrontEndContainer(); fer.start(pp); }
public static String getContainerName() { if (myFrontEnd != null) { Location cid = myFrontEnd.here(); if (cid != null) { return cid.getName(); } } return null; }
/** * Kill an agent. This method terminates an agent running within the active Front End container. * * @param name The local name (i.e. without the platform ID) of the agent to kill. * @throws NotFoundException If no agent with the given local name are running within the active * Front End. */ public static void killAgent(String name) throws NotFoundException { if (myFrontEnd != null) { try { myFrontEnd.killAgent(name); } catch (IMTPException imtpe) { // Should never happen as this is a local call imtpe.printStackTrace(); } } }
/** * Start a new agent. This method starts a new agent within the active Front End container. * * @param name The local name (i.e. without the platform ID) of the agent to create. * @param className The fully qualified name of the class implementing the agent to start. * @param args The creation arguments for the agent. * @throws Exception If the underlying agent creation process fails. */ public static void startAgent(String name, String className, Object[] args) throws Exception { if (myFrontEnd != null) { try { myFrontEnd.createAgent(name, className, args); } catch (IMTPException imtpe) { // This is a local call --> an IMTPxception always wrap some other exception throw (Exception) imtpe.getNested(); } } }
/** * Get agent proxy to local agent given its name. <br> * <b>NOT available in MIDP</b> <br> * * @param localAgentName The short local name of the desired agent. * @throws ControllerException If any problems occur obtaining this proxy. */ public static AgentController getAgent(String localName) throws ControllerException { if (myFrontEnd == null) { throw new ControllerException("FrontEndContainer not found"); } // Check that the agent exists jade.core.Agent instance = myFrontEnd.getLocalAgent(localName); if (instance == null) { throw new ControllerException("Agent " + localName + " not found."); } return new MicroAgentControllerImpl(localName, myFrontEnd); }
/** * Shut down the JADE runtime. This method stops the JADE Front End container currently running in * this JVM, if one such container exists. */ public static void stopJADE() { if (myFrontEnd != null) { try { // Self-initiated shutdown myFrontEnd.exit(true); } catch (IMTPException imtpe) { // Should never happen as this is a local call imtpe.printStackTrace(); } } }
/** * Start up the JADE runtime. This method launches a JADE Front End container. Since JADE supports * only one container in the split-container deployment, if a Front End is already running this * method does nothing. * * @param p A property bag, containing name-value pairs used to configure the container during * boot. * @param r A <code>Runnable</code> object, whose <code>run()</code> method will be executed just * after container termination. */ public static void startJADE(Properties p, Runnable r) { if (myFrontEnd == null) { terminator = r; terminated = false; myFrontEnd = new FrontEndContainer(); myFrontEnd.start(p); if (terminated) { myFrontEnd = null; } } }
/** * Disconnect this front-end container from the platform. That is, though the local front-end * container and its agent(s) remain active, the back-end is shut down and, of course, the FE-2-BE * connection is closed --> Therefore the rest of the platform does not see the local container * and its agent(s) anymore. The local container automatically re-connects to the platform (and * local agents are registered with the AMS again) as soon as a message to a remote agent is sent. */ public static void detach() { if (myFrontEnd != null) { myFrontEnd.detach(); } }
/** * Remove a listener to Front-End relevant events BORN_AGENT and DEAD_AGENT <br> * <b>NOT available in MIDP</b> <br> * * @param l The listener to be removed */ public static void removeListener(FEListener l) { if (myFrontEnd != null) { myFrontEnd.removeListener(l); } }
/** * Add a listener that will be notified about Front-End relevant events such as BORN_AGENT and * DEAD_AGENT <br> * <b>NOT available in MIDP</b> <br> * * @param l The listener that will be notified about Front-End relevant events */ public static void addListener(FEListener l) { if (myFrontEnd != null) { myFrontEnd.addListener(l); } }