/** Broadcast the given message. * * @param message describes the message and its context. * @throws IOException */ public void broadcastMessage(Message message) throws IOException { // very hard implementation, will modified to use propagate List<PipeAdvertisement> list = PipeUtil.getAdvertisements(getPeerGroup(), null); for (PipeAdvertisement pipeAdvertisement : list) { // make sure it is not us if (!this.networkHandler.getKernelAddress().toString().equals(pipeAdvertisement.getName())) { sendMessage(message, true, pipeAdvertisement); } } }
private PipeAdvertisement findCandidateKernel() { List<PipeAdvertisement> list = PipeUtil.getAdvertisements(getPeerGroup(), null); while (!list.isEmpty()) { int idx = RandomNumber.nextInt(list.size()); PipeAdvertisement a = list.get(idx); if (this.networkHandler.getKernelAddress().toString().equals(a.getName())) { list.remove(idx); } else { return a; } } return null; }