Ejemplo n.º 1
0
  /** 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());
    }
  }
Ejemplo n.º 2
0
  /** Prints all the chord files. */
  public void getFiles() {
    try {
      basic.Logger.appendln("My files are");
      String[] files = node.getFile_keys();
      for (int i = 0; i < files.length; i++) {
        basic.Logger.appendln(files[i]);
      }
      for (RemoteNode i = node.getSuccessor();
          !i.getPid().equalsIgnoreCase(node.getPid());
          i = i.getSuccessor()) {
        files = i.getFile_keys();
        basic.Logger.appendln("My next successor files are: ");
        for (int j = 0; j < files.length; j++) {
          basic.Logger.appendln(files[j]);
        }
      }

    } 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());
    }
  }
Ejemplo n.º 3
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();
  }
Ejemplo n.º 4
0
 /** This method return the node successor. */
 public String getRMIInfo() {
   String returnval = "FAIL!!!";
   try {
     returnval = node.getSuccessor().getRMIInfo();
   } catch (RemoteException ex) {
     basic.Logger.war("The successors seems down... :(");
     try {
       node.joinedStabilize();
       node.fixFingers();
     } catch (RemoteException remoteException) {
       basic.Logger.err(remoteException.getMessage());
     }
     basic.Logger.err(ex.getMessage());
   }
   return returnval;
 }