Example #1
0
 public boolean execute() {
   int size = Network.size();
   int numClient = Network.size() - Library.offset;
   String path = "./startup/startup_file_" + Integer.toString(numClient) + ".txt";
   BufferedReader br = null;
   try {
     br = new BufferedReader(new FileReader(path));
   } catch (IOException e) {
     e.printStackTrace();
   }
   TreeSet<Comparator> ts = new TreeSet<Comparator>();
   try {
     for (int i = Library.offset; i < size; i++) {
       long wait = Long.parseLong(br.readLine());
       Comparator comp = new Comparator(wait, i);
       ts.add(comp);
     }
   } catch (IOException e) {
     e.printStackTrace();
   }
   Iterator<Comparator> it = ts.iterator();
   while (it.hasNext()) {
     Comparator comp = it.next();
     Node node = (Node) Network.get(comp.id);
     PeerProtocol pp = (PeerProtocol) node.getProtocol(pid);
     Node server = (Node) Network.get(((PeerProtocol) node.getProtocol(pid)).servId);
     pp.doRequest(node, server, idLength, pid, comp.wait);
     if (comp.id == Library.offset) {
       Library.logTask(comp.id, true, pid, comp.wait + Library.clientSendOverhead);
     }
   }
   return false;
 }
Example #2
0
  public boolean execute() {
    int size = Network.size();
    int numClient = ((PeerProtocol) (((Node) Network.get(0)).getProtocol(pid))).numClient;
    Library.numAllOpera = (long) numClient * (long) numReqPerClient;
    for (int i = 0; i < numClient; i++) {
      ((PeerProtocol) (((Node) Network.get(i)).getProtocol(pid))).numOpera = numReqPerClient;
      ((PeerProtocol) (((Node) Network.get(i)).getProtocol(pid))).reqArrivalInterval =
          reqArrivalInterval;
      ((PeerProtocol) (((Node) Network.get(i)).getProtocol(pid))).localTransTime = localTransTime;
    }

    String path = startupFilePath + "startup_file_" + Integer.toString(size) + ".txt";
    BufferedReader br = null;
    try {
      br = new BufferedReader(new FileReader(path));
    } catch (IOException e) {
      e.printStackTrace();
    }
    TreeSet<Comparator> ts = new TreeSet<Comparator>();
    try {
      for (int i = 0; i < numClient; i++) {
        long wait = Long.parseLong(br.readLine());
        Comparator comp = new Comparator(wait, i);
        ts.add(comp);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
    Iterator<Comparator> it = ts.iterator();
    while (it.hasNext()) {
      Comparator comp = it.next();
      Node node = (Node) Network.get(comp.id);
      PeerProtocol pp = (PeerProtocol) node.getProtocol(pid);
      pp.doRequest(node, pid, comp.wait);
    }
    return false;
  }