}
@SuppressWarnings("unchecked")
private TopologyInfo buildTopologyInfo(List<Address> newView) {
if (configuration.getGlobalConfiguration().hasTopologyInfo()) {
TopologyInfo oldTI = distributionManager.getTopologyInfo();
// we are using topologies
Set<Address> unknownAddresses = new HashSet<Address>();
for (Address a: newView) {
if (!oldTI.containsInfoForNode(a)) unknownAddresses.add(a);
}
if (!unknownAddresses.isEmpty()) {
Collection<NodeTopologyInfo> moreTopologies = null;
for (Address topologyProvider : unknownAddresses) {
Map<Address, Response> r = rpcManager.invokeRemotely(Collections.singleton(topologyProvider), cf.buildRehashControlCommand(RehashControlCommand.Type.FETCH_TOPOLOGY_INFO, self), true, true);
Response resp = r.get(topologyProvider);
if (resp.isSuccessful() && resp.isValid()) {
// we have the response we need!
moreTopologies = (Collection<NodeTopologyInfo>) ((SuccessfulResponse) resp).getResponseValue();
break;
}
}
if (moreTopologies == null) throw new CacheException("Unable to retrieve topology information for addresses " + unknownAddresses);
return new TopologyInfo(oldTI, moreTopologies);
}
return oldTI;
} else {
// no topologies are used in this config
return null;