return consistentHash.getMembers().contains(address) ? consistentHash.getSegmentsForOwner(address)
: InfinispanCollections.<Integer>emptySet();
}
public void applyState(Address sender, int topologyId, Collection<StateChunk> stateChunks) {
ConsistentHash wCh = cacheTopology.getWriteConsistentHash();
// Ignore responses received after we are no longer a member
if (!wCh.getMembers().contains(rpcManager.getAddress())) {
if (trace) {
log.tracef("Ignoring received state because we are no longer a member of cache %s", cacheName);
}
return;
}
// Ignore segments that we requested for a previous rebalance
// Can happen when the coordinator leaves, and the new coordinator cancels the rebalance in progress
int rebalanceTopologyId = stateTransferTopologyId.get();
if (rebalanceTopologyId == NO_REBALANCE_IN_PROGRESS) {
log.debugf("Discarding state response with topology id %d for cache %s, we don't have a state transfer in progress",
topologyId, cacheName);
return;
}
if (topologyId < rebalanceTopologyId) {
log.debugf("Discarding state response with old topology id %d for cache %s, state transfer request topology was %d",
topologyId, cacheName, waitingForState.get());
return;
}
if (trace) {
log.tracef("Before applying the received state the data container of cache %s has %d keys", cacheName, dataContainer.size());
}
Set<Integer> mySegments = wCh.getSegmentsForOwner(rpcManager.getAddress());
for (StateChunk stateChunk : stateChunks) {
if (!mySegments.contains(stateChunk.getSegmentId())) {
log.warnf("Discarding received cache entries for segment %d of cache %s because they do not belong to this node.", stateChunk.getSegmentId(), cacheName);
continue;
}