use of org.infinispan.client.hotrod.impl.consistenthash.SegmentConsistentHash in project infinispan by infinispan.
the class ChannelFactory method receiveTopology.
public void receiveTopology(byte[] cacheName, int responseTopologyAge, int responseTopologyId, InetSocketAddress[] addresses, SocketAddress[][] segmentOwners, short hashFunctionVersion) {
WrappedByteArray wrappedCacheName = wrapBytes(cacheName);
lock.writeLock().lock();
try {
CacheInfo cacheInfo = topologyInfo.getCacheInfo(wrappedCacheName);
assert cacheInfo != null : "The cache info must exist before receiving a topology update";
// Relies on TopologyInfo.switchCluster() to update the topologyAge for caches first
if (responseTopologyAge == cacheInfo.getTopologyAge() && responseTopologyId > cacheInfo.getTopologyId()) {
List<InetSocketAddress> addressList = Arrays.asList(addresses);
HOTROD.newTopology(responseTopologyId, responseTopologyAge, addresses.length, addressList);
CacheInfo newCacheInfo;
if (hashFunctionVersion >= 0) {
SegmentConsistentHash consistentHash = createConsistentHash(segmentOwners, hashFunctionVersion, cacheInfo.getCacheName());
newCacheInfo = cacheInfo.withNewHash(responseTopologyAge, responseTopologyId, addressList, consistentHash, segmentOwners.length);
} else {
newCacheInfo = cacheInfo.withNewServers(responseTopologyAge, responseTopologyId, addressList);
}
updateCacheInfo(wrappedCacheName, newCacheInfo, false);
} else {
if (log.isTraceEnabled())
log.tracef("[%s] Ignoring outdated topology: topology id = %s, topology age = %s, servers = %s", cacheInfo.getCacheName(), responseTopologyId, responseTopologyAge, Arrays.toString(addresses));
}
} finally {
lock.writeLock().unlock();
}
}
use of org.infinispan.client.hotrod.impl.consistenthash.SegmentConsistentHash in project infinispan by infinispan.
the class IterationStartOperation method acceptResponse.
@Override
public void acceptResponse(ByteBuf buf, short status, HeaderDecoder decoder) {
SegmentConsistentHash consistentHash = (SegmentConsistentHash) channelFactory.getConsistentHash(cacheName);
IterationStartResponse response = new IterationStartResponse(ByteBufUtil.readArray(buf), consistentHash, header.topologyId().get(), channel);
complete(response);
}
Aggregations