コード例 #1
0
ファイル: Node.java プロジェクト: bruntha1991/ds
 public void leaveDSSystem() {
   List<Neighbor> neighbors = Configuration.getNeighbors();
   Iterator<Neighbor> neighborsIterator = neighbors.iterator();
   while (neighborsIterator.hasNext()) {
     Neighbor temp = neighborsIterator.next();
     Message leaveMsg = new LEAVEMessage(temp.getIpAddress(), temp.getPortNumber());
     myMsgTransfer.sendMessage(leaveMsg);
   }
 }
コード例 #2
0
ファイル: Node.java プロジェクト: bruntha1991/ds
  public void printConnectedNeighbors() {

    System.out.println("Connected Neighbors:");

    List<Neighbor> neighbors = Configuration.getNeighbors();

    Iterator<Neighbor> neighborsIterator = neighbors.iterator();
    while (neighborsIterator.hasNext()) {
      Neighbor temp = neighborsIterator.next();

      System.out.println(temp.toString());
    }
  }
コード例 #3
0
ファイル: Node.java プロジェクト: bruntha1991/ds
  public void forwardSerMsg(Message message) {

    List<Neighbor> neighbors = Configuration.getNeighbors();
    Iterator<Neighbor> neighborsIterator = neighbors.iterator();
    while (neighborsIterator.hasNext()) {
      Neighbor temp = neighborsIterator.next();
      if (!message.ip_from.matches(temp.getIpAddress())
          || message.port_from != temp.getPortNumber()) {
        Message serMsg =
            new SERMessage(
                message.query,
                message.hops + 1,
                message.ip_from,
                message.port_from,
                temp.getIpAddress(),
                temp.getPortNumber());
        noOfFwdMsg++;
        System.out.println(
            "Forwarded query : "
                + message.ip_from
                + ":"
                + message.port_from
                + " TO "
                + temp.getIpAddress()
                + ":"
                + temp.getPortNumber());
        myMsgTransfer.sendMessage(serMsg);
      }
    }
  }