/** 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!"); }
/** This method prints all the next successors and their hashes. */ public void showAllSuccessors() { try { basic.Logger.appendln( "I'm " + node.getRMIInfo() + " with hash:\n" + node.getKey().getStringHash()); basic.Logger.inf("I'm " + node.getRMIInfo()); for (RemoteNode i = node.getSuccessor(); !i.getPid().equalsIgnoreCase(node.getPid()); i = i.getSuccessor()) { basic.Logger.appendln( "My next successor is " + i.getRMIInfo() + " with hash:\n" + i.getKey().getStringHash()); basic.Logger.inf("My next successor is " + i.getRMIInfo()); } } catch (RemoteException ex) { basic.Logger.err("The successors seems down... :("); try { node.joinedStabilize(); } catch (RemoteException remoteException) { basic.Logger.err(remoteException.getMessage()); } basic.Logger.err(ex.getMessage()); } }