Beispiel #1
0
  private static Properties adjustProperties(Properties pp) {
    // A BackEndContainer is never a Main
    pp.setProperty(Profile.MAIN, "false");

    // Set default additional services if not already set
    String services = pp.getProperty(Profile.SERVICES);
    if (services == null) {
      services = "jade.core.event.NotificationService";
    }
    String additionalServices = pp.getProperty(BEManagementService.ADDITIONAL_SERVICES);
    if (additionalServices != null) {
      services += ";" + additionalServices;
    }
    pp.setProperty(Profile.SERVICES, services);

    // Merge back-end and front-end services
    String feServices = pp.getProperty(MicroRuntime.BE_REQUIRED_SERVICES_KEY);
    if (feServices != null) {
      Vector ss = Specifier.parseList(pp.getProperty(Profile.SERVICES), ';');
      Vector fess = Specifier.parseList(feServices, ';');
      for (int i = 0; i < fess.size(); ++i) {
        String s = (String) fess.get(i);
        if (!ss.contains(s)) {
          ss.add(s);
        }
      }
      pp.setProperty(Profile.SERVICES, Specifier.encodeList(ss, Specifier.SPECIFIER_SEPARATOR));
    }
    return pp;
  }
  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);
  }
Beispiel #3
0
 public static final Properties parseCreateMediatorRequest(String s) throws ICPException {
   StringTokenizer st = new StringTokenizer(s, "=#");
   Properties p = new Properties();
   while (st.hasMoreTokens()) {
     String key = st.nextToken();
     if (!st.hasMoreTokens()) {
       throw new ICPException("Wrong initialization properties format.");
     }
     p.setProperty(key, st.nextToken());
   }
   return p;
 }
  protected final BackEndSkel startBackEndContainer(Properties props) throws ICPException {
    try {
      String nodeName = myID.replace(':', '_');
      props.setProperty(Profile.CONTAINER_NAME, nodeName);

      myContainer = new BackEndContainer(props, this);
      if (!myContainer.connect()) {
        throw new ICPException("BackEnd container failed to join the platform");
      }
      // Possibly the node name was re-assigned by the main
      myID = myContainer.here().getName();
      if (myLogger.isLoggable(Logger.CONFIG)) {
        myLogger.log(
            Logger.CONFIG, "BackEndContainer " + myID + " successfully joined the platform");
      }
      return new BackEndSkel(myContainer);
    } catch (ProfileException pe) {
      // should never happen
      pe.printStackTrace();
      throw new ICPException("Error creating profile");
    }
  }
  /** Create a BackEnd in the fixed network and return a stub to communicate with it */
  public BackEnd getBackEnd(FrontEnd fe, Properties p) throws IMTPException {
    props = p;

    beAddrsText = props.getProperty(FrontEnd.REMOTE_BACK_END_ADDRESSES);
    backEndAddresses = parseBackEndAddresses(beAddrsText);

    // Host
    String host = props.getProperty("host");
    if (host == null) {
      host = "localhost";
    }
    // Port
    int port = JICPProtocol.DEFAULT_PORT;
    try {
      port = Integer.parseInt(props.getProperty("port"));
    } catch (NumberFormatException nfe) {
      // Use default
    }
    // Compose URL. Note that we build a JICPAddress just to avoid loading the HTTPAddress class.
    mediatorTA = JICPProtocol.getInstance().buildAddress(host, String.valueOf(port), null, null);

    // Mediator class
    String tmp = props.getProperty(JICPProtocol.MEDIATOR_CLASS_KEY);
    if (tmp != null) {
      myMediatorClass = tmp;
    } else {
      // Set the default mediator class since this must be propagated to the mediator.
      props.setProperty(JICPProtocol.MEDIATOR_CLASS_KEY, myMediatorClass);
    }

    // Read re-connection retry time
    long retryTime = JICPProtocol.DEFAULT_RETRY_TIME;
    try {
      retryTime = Long.parseLong(props.getProperty(JICPProtocol.RECONNECTION_RETRY_TIME_KEY));
    } catch (Exception e) {
      // Use default
    }

    // Read Max disconnection time
    maxDisconnectionTime = JICPProtocol.DEFAULT_MAX_DISCONNECTION_TIME;
    try {
      maxDisconnectionTime =
          Long.parseLong(props.getProperty(JICPProtocol.MAX_DISCONNECTION_TIME_KEY));
    } catch (Exception e) {
      // Use default
      props.setProperty(
          JICPProtocol.MAX_DISCONNECTION_TIME_KEY, String.valueOf(maxDisconnectionTime));
    }

    // Read Keep-alive time
    keepAliveTime = JICPProtocol.DEFAULT_KEEP_ALIVE_TIME;
    try {
      keepAliveTime = Long.parseLong(props.getProperty(JICPProtocol.KEEP_ALIVE_TIME_KEY));
    } catch (Exception e) {
      // Use default
      props.setProperty(JICPProtocol.KEEP_ALIVE_TIME_KEY, String.valueOf(keepAliveTime));
    }

    if (myLogger.isLoggable(Logger.CONFIG)) {
      myLogger.log(Logger.CONFIG, "Remote URL = http://" + host + ":" + port);
      myLogger.log(Logger.CONFIG, "Mediator class = " + myMediatorClass);
      myLogger.log(Logger.CONFIG, "Reconnection retry time = " + retryTime);
      myLogger.log(Logger.CONFIG, "Max disconnection time = " + maxDisconnectionTime);
      myLogger.log(Logger.CONFIG, "Keep-alive time = " + keepAliveTime);
    }

    myDisconnectionManager = new DisconnectionManager(retryTime, maxDisconnectionTime);
    myKeepAliveManager = new KeepAliveManager(keepAliveTime);
    myInputManager = new InputManager();

    // Read the owner if any
    owner = props.getProperty("owner");

    // Create the BackEnd stub and the FrontEnd skeleton
    myStub = new BackEndStub(this);
    mySkel = new FrontEndSkel(fe);

    // Start the InputManager
    myInputManager.start();

    // Create the remote BackEnd
    createBackEnd();

    return myStub;
  }
Beispiel #6
0
 /**
  * Add a new user defined parameter to this ACLMessage. Notice that according to the FIPA
  * specifications, the keyword of a user-defined parameter must not contain space inside. Note
  * that the user does not need to (and shall not) add the prefix "X-" to the keyword. This is
  * automatically added by the StringACLCodec.
  *
  * @param key the property key.
  * @param value the property value
  */
 public void addUserDefinedParameter(String key, String value) {
   userDefProps = (userDefProps == null ? new Properties() : userDefProps);
   userDefProps.setProperty(key, value);
 }