List<Address> addresses = this.cache.getAdvancedCache().getDistributionManager().locate(key);
if (!addresses.contains(this.cache.getCacheManager().getAddress())) {
// Otherwise choose random node from hash targets
Map.Entry<String, ?> entry = this.registry.getRemoteEntry(addresses.get(random.nextInt(addresses.size())));
if (entry != null) {
return new NodeAffinity(entry.getKey());
}
}
}
return new NodeAffinity(this.registry.getLocalEntry().getKey());
}