use of org.infinispan.statetransfer.OutboundTransferTask in project infinispan by infinispan.
the class ScatteredStateProviderImpl method startKeysTransfer.
@Override
public void startKeysTransfer(IntSet segments, Address origin) {
CacheTopology cacheTopology = distributionManager.getCacheTopology();
OutboundTransferTask outboundTransferTask = new OutboundTransferTask(origin, segments, cacheTopology.getCurrentCH().getNumSegments(), chunkSize, cacheTopology.getTopologyId(), keyPartitioner, chunks -> {
}, rpcManager, commandsFactory, timeout, cacheName, true, false);
addTransfer(outboundTransferTask);
outboundTransferTask.execute(Flowable.concat(publishDataContainerKeys(segments), publishStoreKeys(segments))).whenComplete((ignored, throwable) -> {
if (throwable != null) {
logError(outboundTransferTask, throwable);
}
onTaskCompletion(outboundTransferTask);
});
}
use of org.infinispan.statetransfer.OutboundTransferTask in project infinispan by infinispan.
the class ScatteredStateProviderImpl method replicateAndInvalidate.
// This method handles creating the backup copy and invalidation on other nodes for segments
// that this node keeps from previous topology.
private CompletableFuture<Void> replicateAndInvalidate(CacheTopology cacheTopology) {
Address nextMember = getNextMember(cacheTopology);
if (nextMember != null) {
HashSet<Address> otherMembers = new HashSet<>(cacheTopology.getActualMembers());
Address localAddress = rpcManager.getAddress();
otherMembers.remove(localAddress);
otherMembers.remove(nextMember);
if (!cacheTopology.getCurrentCH().getMembers().contains(localAddress)) {
log.trace("Local address is not a member of currentCH, returning");
return CompletableFutures.completedNull();
}
IntSet oldSegments = IntSets.from(cacheTopology.getCurrentCH().getSegmentsForOwner(localAddress));
oldSegments.retainAll(cacheTopology.getPendingCH().getSegmentsForOwner(localAddress));
log.trace("Segments to replicate and invalidate: " + oldSegments);
if (oldSegments.isEmpty()) {
return CompletableFutures.completedNull();
}
// We pretend to do one extra invalidation at the beginning that finishes after we sent all chunks
AtomicInteger outboundInvalidations = new AtomicInteger(1);
CompletableFuture<Void> invalidationFuture = new CompletableFuture<>();
OutboundTransferTask outboundTransferTask = new OutboundTransferTask(nextMember, oldSegments, cacheTopology.getCurrentCH().getNumSegments(), chunkSize, cacheTopology.getTopologyId(), keyPartitioner, chunks -> invalidateChunks(chunks, otherMembers, outboundInvalidations, invalidationFuture, cacheTopology), rpcManager, commandsFactory, timeout, cacheName, true, true);
outboundTransferTask.execute(Flowable.concat(publishDataContainerEntries(oldSegments), publishStoreEntries(oldSegments))).whenComplete((ignored, throwable) -> {
if (throwable != null) {
logError(outboundTransferTask, throwable);
}
if (outboundInvalidations.decrementAndGet() == 0) {
invalidationFuture.complete(null);
}
});
return invalidationFuture;
} else {
return CompletableFutures.completedNull();
}
}
Aggregations