Ejemplo n.º 1
0
 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);
   }
 }
Ejemplo n.º 2
0
  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());
    }
  }
Ejemplo n.º 3
0
  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);
      }
    }
  }