public void sendDiscoveryRequest(String cluster_name, Promise promise, ViewId view_id) throws Exception { PingData data = null; PhysicalAddress physical_addr = (PhysicalAddress) down(new Event(Event.GET_PHYSICAL_ADDRESS, local_addr)); if (view_id == null) { List<PhysicalAddress> physical_addrs = Arrays.asList(physical_addr); data = new PingData(local_addr, null, false, UUID.get(local_addr), physical_addrs); } PingHeader hdr = new PingHeader(PingHeader.GET_MBRS_REQ, data, cluster_name); hdr.view_id = view_id; Collection<PhysicalAddress> cluster_members = fetchClusterMembers(cluster_name); if (cluster_members == null) { Message msg = new Message(null); // multicast msg msg.setFlag(Message.OOB); msg.putHeader(getId(), hdr); sendMcastDiscoveryRequest(msg); } else { if (cluster_members.isEmpty()) { // if we don't find any members, return immediately if (promise != null) promise.setResult(null); } else { for (final Address addr : cluster_members) { if (addr.equals(physical_addr)) // no need to send the request to myself continue; final Message msg = new Message(addr, null, null); msg.setFlag(Message.OOB); msg.putHeader(this.id, hdr); if (log.isTraceEnabled()) log.trace("[FIND_INITIAL_MBRS] sending discovery request to " + msg.getDest()); if (!sendDiscoveryRequestsInParallel()) { down_prot.down(new Event(Event.MSG, msg)); } else { timer.execute( new Runnable() { public void run() { try { down_prot.down(new Event(Event.MSG, msg)); } catch (Exception ex) { if (log.isErrorEnabled()) log.error("failed sending discovery request to " + addr + ": " + ex); } } }); } } } } }
public Responses findMembers( final List<Address> members, final boolean initial_discovery, boolean async) { num_discovery_requests++; int num_expected = members != null ? members.size() : 0; int capacity = members != null ? members.size() : 16; final Responses rsps = new Responses(num_expected, initial_discovery && break_on_coord_rsp, capacity); synchronized (ping_responses) { ping_responses.put(System.nanoTime(), rsps); } if (async || async_discovery) timer.execute(() -> findMembers(members, initial_discovery, rsps)); else findMembers(members, initial_discovery, rsps); weedOutCompletedDiscoveryResponses(); return rsps; }
protected synchronized void startCacheDissemination( List<Address> curr_mbrs, List<Address> left_mbrs, List<Address> new_mbrs) { timer.execute(new DiscoveryCacheDisseminationTask(curr_mbrs, left_mbrs, new_mbrs)); }