Пример #1
0
 /**
  * Used to construct the prototype node. This class currently does not have specific configuration
  * parameters and so the parameter <code>prefix</code> is not used. It reads the protocol
  * components (components that have type {@value peersim.core.Node#PAR_PROT}) from the
  * configuration.
  */
 public GeneralNode(String prefix) {
   System.err.println("Instantiating GenralNode with prefix = " + prefix);
   String[] names = Configuration.getNames(PAR_PROT);
   String[] names_specs = Configuration.getNames(prefix);
   CommonState.setNode(this);
   ID = nextID();
   protocol = new Protocol[names.length + names_specs.length];
   System.err.println(
       "Instantiating GenralNode with prefix = " + prefix + " ==> Loading protocols");
   int i = 0;
   for (i = 0; i < names.length; i++) {
     System.err.println("Loading protocol: " + names[i]);
     CommonState.setPid(i);
     Protocol p = (Protocol) Configuration.getInstance(names[i]);
     if (p == null) System.err.println(" ############## Failed to instantiate: " + names[i]);
     protocol[i] = p;
   }
   System.err.println(
       "Instantiating GenralNode with prefix = " + prefix + " ==> Loading secondary protocols");
   for (int j = 0; j < names_specs.length; j++, i++) {
     CommonState.setPid(i);
     Protocol p = (Protocol) Configuration.getInstance(names_specs[j]);
     if (p == null)
       System.err.println(" ############### Failed to instantiate: " + names_specs[j]);
     protocol[i] = p;
   }
 }
Пример #2
0
  /** Initialization based on configuration parameters. */
  public OrangeSched(String n) {

    String[] prots = Configuration.getString(n + "." + PAR_PROTOCOL).split("\\s");
    pid = new int[prots.length];
    nce = new NextCycleEvent[prots.length];
    for (int i = 0; i < prots.length; ++i) {
      pid[i] = Configuration.lookupPid(prots[i]);
      if (!(Network.prototype.getProtocol(pid[i]) instanceof CDProtocol)) {
        throw new IllegalParameterException(
            n + "." + PAR_PROTOCOL, "Only CDProtocols are accepted here");
      }

      nce[i] =
          (NextCycleEvent) Configuration.getInstance(n + "." + PAR_NEXTC, new NextCycleEvent(null));
    }

    randstart = Configuration.contains(n + "." + PAR_RNDSTART);
  }