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); } } }
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); } }