@Override public void members(List<PingData> mbrs) { PhysicalAddress own_physical_addr=(PhysicalAddress)down(new Event(Event.GET_PHYSICAL_ADDRESS, local_addr)); PingData data=new PingData(local_addr, false, org.jgroups.util.NameCache.get(local_addr), own_physical_addr); PingHeader hdr=new PingHeader(PingHeader.GET_MBRS_REQ).clusterName(cluster_name); Set<PhysicalAddress> physical_addrs=mbrs.stream().filter(ping_data -> ping_data != null && ping_data.getPhysicalAddr() != null) .map(PingData::getPhysicalAddr).collect(Collectors.toSet()); for(PhysicalAddress physical_addr: physical_addrs) { if(physical_addr != null && own_physical_addr.equals(physical_addr)) // no need to send the request to myself continue; // the message needs to be DONT_BUNDLE, see explanation above final Message msg=new Message(physical_addr).setFlag(Message.Flag.INTERNAL, Message.Flag.DONT_BUNDLE, Message.Flag.OOB) .putHeader(this.id, hdr).setBuffer(marshal(data)); log.trace("%s: sending discovery request to %s", local_addr, msg.getDest()); down_prot.down(msg); } }
PingHeader hdr=new PingHeader(PingHeader.GET_MBRS_REQ).clusterName(cluster_name).initialDiscovery(initial_discovery); for(final PhysicalAddress addr: cluster_members) { if(addr.equals(physical_addr)) // no need to send the request to myself
PingHeader hdr = new PingHeader(PingHeader.GET_MBRS_REQ).clusterName(cluster_name).initialDiscovery(initial_discovery); for (Address addr : cluster_members) {
protected void sendDiscoveryRequest(String cluster_name, List<Address> members_to_find, boolean initial_discovery) throws Exception { PingData data=null; if(!use_ip_addrs || !initial_discovery) { PhysicalAddress physical_addr=(PhysicalAddress)down(new Event(Event.GET_PHYSICAL_ADDRESS, local_addr)); // https://issues.jboss.org/browse/JGRP-1670 data=new PingData(local_addr, false, NameCache.get(local_addr), physical_addr); if(members_to_find != null && members_to_find.size() <= max_members_in_discovery_request) data.mbrs(members_to_find); } // message needs to have DONT_BUNDLE flag: if A sends message M to B, and we need to fetch B's physical // address, then the bundler thread blocks until the discovery request has returned. However, we cannot send // the discovery *request* until the bundler thread has returned from sending M PingHeader hdr=new PingHeader(PingHeader.GET_MBRS_REQ).clusterName(cluster_name).initialDiscovery(initial_discovery); Message msg=new Message(null).putHeader(getId(),hdr) .setFlag(Message.Flag.INTERNAL,Message.Flag.DONT_BUNDLE,Message.Flag.OOB) .setTransientFlag(Message.TransientFlag.DONT_LOOPBACK); if(data != null) msg.setBuffer(marshal(data)); sendMcastDiscoveryRequest(msg); }
PingHeader hdr=new PingHeader(PingHeader.GET_MBRS_REQ).clusterName(cluster_name).initialDiscovery(initial_discovery); for(final PhysicalAddress addr: cluster_members) { if(physical_addr != null && addr.equals(physical_addr)) // no need to send the request to myself
@Override public void members(List<PingData> mbrs) { PhysicalAddress own_physical_addr=(PhysicalAddress)down(new Event(Event.GET_PHYSICAL_ADDRESS, local_addr)); PingData data=new PingData(local_addr, false, org.jgroups.util.NameCache.get(local_addr), own_physical_addr); PingHeader hdr=new PingHeader(PingHeader.GET_MBRS_REQ).clusterName(cluster_name); Set<PhysicalAddress> physical_addrs=mbrs.stream().filter(ping_data -> ping_data != null && ping_data.getPhysicalAddr() != null) .map(PingData::getPhysicalAddr).collect(Collectors.toSet()); for(PhysicalAddress physical_addr: physical_addrs) { if(physical_addr != null && own_physical_addr.equals(physical_addr)) // no need to send the request to myself continue; // the message needs to be DONT_BUNDLE, see explanation above final Message msg=new Message(physical_addr).setFlag(Message.Flag.INTERNAL, Message.Flag.DONT_BUNDLE, Message.Flag.OOB) .putHeader(this.id, hdr).setBuffer(marshal(data)); log.trace("%s: sending discovery request to %s", local_addr, msg.getDest()); down_prot.down(msg); } }
PingHeader hdr=new PingHeader(PingHeader.GET_MBRS_REQ).clusterName(cluster_name).initialDiscovery(initial_discovery); for(final PhysicalAddress addr: cluster_members) { if(physical_addr != null && addr.equals(physical_addr)) // no need to send the request to myself
PingHeader hdr=new PingHeader(PingHeader.GET_MBRS_REQ).clusterName(cluster_name).initialDiscovery(initial_discovery); for(final PhysicalAddress addr: cluster_members) { if(physical_addr != null && addr.equals(physical_addr)) // no need to send the request to myself
@Override public void findMembers(List<Address> members, boolean initial_discovery, Responses responses) { kubernetesHosts = findKubernetesHosts(); PhysicalAddress physical_addr = (PhysicalAddress) down(new Event(Event.GET_PHYSICAL_ADDRESS, local_addr)); // https://issues.jboss.org/browse/JGRP-1670 PingData data = new PingData(local_addr, false, org.jgroups.util.UUID.get(local_addr), physical_addr); PingHeader hdr = new PingHeader(PingHeader.GET_MBRS_REQ).clusterName(cluster_name); Set<PhysicalAddress> cluster_members = new HashSet<>(kubernetesHosts); cluster_members.addAll(dynamic_hosts); if (use_disk_cache) { // this only makes sense if we have PDC below us Collection<PhysicalAddress> list = (Collection<PhysicalAddress>) down_prot.down(new Event(Event.GET_PHYSICAL_ADDRESSES)); if (list != null) for (PhysicalAddress phys_addr : list) if (!cluster_members.contains(phys_addr)) cluster_members.add(phys_addr); } for (final PhysicalAddress addr : cluster_members) { if (physical_addr != null && addr.equals(physical_addr)) // no need to send the request to myself continue; // the message needs to be DONT_BUNDLE, see explanation above final Message msg = new Message(addr).setFlag(Message.Flag.INTERNAL, Message.Flag.DONT_BUNDLE, Message.Flag.OOB) .putHeader(this.id, hdr).setBuffer(marshal(data)); log.trace("%s: sending discovery request to %s", local_addr, msg.getDest()); down_prot.down(new Event(Event.MSG, msg)); } }
/** * Fetches all of the cluster members found on EC2. The host portion of the * addresses are the private ip addresses of the matching nodes. The port * numbers of the addresses are set to the port number plus all the ports in * the range after that specified on this protocol. */ @Override protected void findMembers(final List<Address> members, boolean initial_discovery, final Responses responses) { final IpAddress physical_addr = (IpAddress) down(new Event(Event.GET_PHYSICAL_ADDRESS, local_addr)); final PingData data = new PingData(local_addr, false, NameCache.get(local_addr), physical_addr); final PingHeader hdr = new PingHeader(PingHeader.GET_MBRS_REQ).clusterName(cluster_name); final List<IpAddress> clusterMembers = ipAddressUtils.expandClusterMemberPorts(getPrivateIpAddresses()); clusterMembers.stream() .filter(Objects::nonNull) //guard against nulls .filter(address -> !address.getIpAddress().equals(physical_addr.getIpAddress())) //filter out self .map(address -> new Message(address) .setFlag(Message.Flag.INTERNAL, Message.Flag.DONT_BUNDLE, Message.Flag.OOB) .putHeader(this.id, hdr).setBuffer(marshal(data))) .forEach(message -> { if(async_discovery_use_separate_thread_per_request) { log.trace("%s: sending async discovery request to %s", local_addr, message.getDest()); down_prot.down(message); } else { log.trace("%s: sending discovery request to %s", local_addr, message.getDest()); down_prot.down(message); } }); }
protected void sendDiscoveryRequest(String cluster_name, List<Address> members_to_find, boolean initial_discovery) throws Exception { PingData data=null; if(!use_ip_addrs || !initial_discovery) { PhysicalAddress physical_addr=(PhysicalAddress)down(new Event(Event.GET_PHYSICAL_ADDRESS, local_addr)); // https://issues.jboss.org/browse/JGRP-1670 data=new PingData(local_addr, false, NameCache.get(local_addr), physical_addr); if(members_to_find != null && members_to_find.size() <= max_members_in_discovery_request) data.mbrs(members_to_find); } // message needs to have DONT_BUNDLE flag: if A sends message M to B, and we need to fetch B's physical // address, then the bundler thread blocks until the discovery request has returned. However, we cannot send // the discovery *request* until the bundler thread has returned from sending M PingHeader hdr=new PingHeader(PingHeader.GET_MBRS_REQ).clusterName(cluster_name).initialDiscovery(initial_discovery); Message msg=new Message(null).putHeader(getId(),hdr) .setFlag(Message.Flag.INTERNAL,Message.Flag.DONT_BUNDLE,Message.Flag.OOB) .setTransientFlag(Message.TransientFlag.DONT_LOOPBACK); if(data != null) msg.setBuffer(marshal(data)); sendMcastDiscoveryRequest(msg); }
PingHeader hdr = new PingHeader(PingHeader.GET_MBRS_REQ).clusterName(cluster_name).initialDiscovery(initial_discovery); for (final Address addr : discovered_hosts) {