Ejemplo n.º 1
0
 /** Stops the execution of the thread. */
 public void stop() {
   basic.Logger.append("Killing this node...");
   this.killNode();
   basic.Logger.append("..");
   if (!basic.Global.SIMPLE) {
     basic.Logger.inf(
         "find_successor has been called " + basic.HopsAndTime.search_counter + " times");
     basic.Logger.inf("Average hops/find_successor: " + basic.HopsAndTime.getAvgHops());
     basic.Logger.inf("Average execution time/find_successor: " + basic.HopsAndTime.getAvgTime());
   }
   basic.Logger.append("..");
   receivemulticast.stop();
   basic.Logger.append(".");
   MulticastSender fixmulticast;
   if (!basic.Global.SIMPLE) {
     try {
       fixmulticast =
           new networking.MulticastSender(
               1101, "224.1.1.1", ("fix " + node.getPid()).getBytes(), node);
       fixmulticast.start();
       basic.Logger.append(".");
       try {
         fixmulticast.getThread().join();
       } catch (InterruptedException ex) {
         Logger.getLogger(DJchord.class.getName()).log(Level.SEVERE, null, ex);
       }
     } catch (RemoteException ex) {
       Logger.getLogger(DJchord.class.getName()).log(Level.SEVERE, null, ex);
     }
   }
   basic.Logger.append(".");
   runner.interrupt();
   runner = null;
   basic.Logger.appendln("done!");
 }
Ejemplo n.º 2
0
  /** Is invoked by start() */
  public void run() {
    try {
      node = new Node();
    } catch (RemoteException ex) {
      basic.Logger.err(ex.getMessage());
    } catch (NoSuchAlgorithmException ex) {
      basic.Logger.err(ex.getMessage());
    } catch (UnsupportedEncodingException ex) {
      basic.Logger.err(ex.getMessage());
    }
    try {
      sendmulticast = new MulticastSender(1101, "224.1.1.1", node.getPid().getBytes(), node);
    } catch (RemoteException ex) {
      basic.Logger.err(ex.getMessage());
    }
    sendmulticast.start();
    try {
      sendmulticast.getThread().join();
    } catch (InterruptedException ex) {

    }
    try {
      node.setSuccessor(1, node.getSuccessor().getSuccessor());
      node.getSuccessor().setSuccessor(1, node.getSuccessor().getSuccessor().getSuccessor());
      node.setSuccessor(2, node.getSuccessor().getSuccessor(1));
    } catch (RemoteException ex) {
      basic.Logger.err(ex.getMessage());
    }
    try {
      node.joinedStabilize();
      node.fixFingers();
      node.sendFiles2ResponsibleNode();
    } catch (RemoteException ex) {
      basic.Logger.err(ex.getMessage());
    }
    node.startCheck();
    receivemulticast = new MulticastReceiver(1101, "224.1.1.1", node);
    receivemulticast.start();
  }