CacheContainer cacheContainer = hrServ2CacheManager.get(serverAddress);
assertNotNull("For server address " + serverAddress + " found " + cacheContainer + ". Map is: " + hrServ2CacheManager, cacheContainer);
DistributionManager distributionManager = cacheContainer.getCache().getAdvancedCache().getDistributionManager();
Address clusterAddress = cacheContainer.getCache().getAdvancedCache().getRpcManager().getAddress();
ConsistentHash serverCh = distributionManager.getReadConsistentHash();
int numSegments = serverCh.getNumSegments();
int keySegment = serverCh.getSegment(key);
Address serverOwner = serverCh.locatePrimaryOwnerForSegment(keySegment);
Address serverPreviousOwner = serverCh.locatePrimaryOwnerForSegment((keySegment - 1 + numSegments) % numSegments);
assert clusterAddress.equals(serverOwner) || clusterAddress.equals(serverPreviousOwner);
tcpConnectionFactory.releaseTransport(transport);
}
}