use of org.jgroups.PhysicalAddress in project JGroups by belaban.
the class FILE_PING method findMembers.
public void findMembers(final List<Address> members, final boolean initial_discovery, Responses responses) {
try {
readAll(members, cluster_name, responses);
if (responses.isEmpty()) {
PhysicalAddress physical_addr = (PhysicalAddress) down(new Event(Event.GET_PHYSICAL_ADDRESS, local_addr));
PingData coord_data = new PingData(local_addr, true, NameCache.get(local_addr), physical_addr).coord(is_coord);
write(Collections.singletonList(coord_data), cluster_name);
return;
}
PhysicalAddress phys_addr = (PhysicalAddress) down_prot.down(new Event(Event.GET_PHYSICAL_ADDRESS, local_addr));
PingData data = responses.findResponseFrom(local_addr);
// the logical addr *and* IP address:port have to match
if (data != null && data.getPhysicalAddr().equals(phys_addr)) {
if (data.isCoord() && initial_discovery)
responses.clear();
else
// use case #1 if we have predefined files: most members join but are not coord
;
} else {
sendDiscoveryResponse(local_addr, phys_addr, NameCache.get(local_addr), null, false);
}
} finally {
responses.done();
}
}
use of org.jgroups.PhysicalAddress in project JGroups by belaban.
the class PING method sendDiscoveryRequest.
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);
}
use of org.jgroups.PhysicalAddress in project JGroups by belaban.
the class GossipRouter method handleRegister.
protected void handleRegister(Address sender, DataInput in) {
GossipData req = readRequest(in, GossipType.REGISTER);
if (req != null) {
String group = req.getGroup();
Address addr = req.getAddress();
PhysicalAddress phys_addr = req.getPhysicalAddress();
String logical_name = req.getLogicalName();
addAddressMapping(sender, group, addr, phys_addr, logical_name);
}
}
Aggregations