use of org.infinispan.commands.remote.recovery.TxCompletionNotificationCommand in project infinispan by infinispan.
the class AbstractCrashTest method skipTxCompletion.
protected void skipTxCompletion(final AdvancedCache<Object, Object> cache, final CountDownLatch releaseLocksLatch) {
RpcManager rpcManager = new AbstractDelegatingRpcManager(cache.getRpcManager()) {
@Override
protected <T> void performSend(Collection<Address> targets, ReplicableCommand command, Function<ResponseCollector<T>, CompletionStage<T>> invoker) {
if (command instanceof TxCompletionNotificationCommand) {
releaseLocksLatch.countDown();
log.tracef("Skipping TxCompletionNotificationCommand");
} else {
super.performSend(targets, command, invoker);
}
}
};
// not too nice: replace the rpc manager in the class that builds the Sync objects
final TransactionTable transactionTable = TestingUtil.getTransactionTable(cache(1));
TestingUtil.replaceField(rpcManager, "rpcManager", transactionTable, TransactionTable.class);
TxControlInterceptor txControlInterceptor = new TxControlInterceptor();
txControlInterceptor.prepareProgress.countDown();
txControlInterceptor.commitProgress.countDown();
extractInterceptorChain(advancedCache(1)).addInterceptor(txControlInterceptor, 1);
}
use of org.infinispan.commands.remote.recovery.TxCompletionNotificationCommand in project infinispan by infinispan.
the class PartitionHandlingManagerImpl method completeTransaction.
private void completeTransaction(final TransactionInfo transactionInfo, CacheTopology cacheTopology) {
List<Address> commitNodes = transactionInfo.getCommitNodes(cacheTopology);
TransactionBoundaryCommand command = transactionInfo.buildCommand(commandsFactory);
command.setTopologyId(cacheTopology.getTopologyId());
CompletionStage<Map<Address, Response>> remoteInvocation = commitNodes != null ? rpcManager.invokeCommand(commitNodes, command, MapResponseCollector.ignoreLeavers(commitNodes.size()), rpcManager.getSyncRpcOptions()) : rpcManager.invokeCommandOnAll(command, MapResponseCollector.ignoreLeavers(), rpcManager.getSyncRpcOptions());
remoteInvocation.whenComplete((responseMap, throwable) -> {
final boolean trace = log.isTraceEnabled();
final GlobalTransaction globalTransaction = transactionInfo.getGlobalTransaction();
if (throwable != null) {
log.failedPartitionHandlingTxCompletion(globalTransaction, throwable);
return;
}
if (trace) {
log.tracef("Future done for transaction %s. Response are %s", globalTransaction, responseMap);
}
for (Response response : responseMap.values()) {
if (response == UnsureResponse.INSTANCE || response == CacheNotFoundResponse.INSTANCE) {
if (trace) {
log.tracef("Topology changed while completing partial transaction %s", globalTransaction);
}
return;
}
}
if (trace) {
log.tracef("Performing cleanup for transaction %s", globalTransaction);
}
lockManager.unlockAll(transactionInfo.getLockedKeys(), globalTransaction);
partialTransactions.remove(globalTransaction);
TxCompletionNotificationCommand completionCommand = commandsFactory.buildTxCompletionNotificationCommand(null, globalTransaction);
// A little bit overkill, but the state transfer can happen during a merge and some nodes can receive the
// transaction that aren't in the original affected nodes.
// no side effects.
rpcManager.sendToAll(completionCommand, DeliverOrder.NONE);
});
}
use of org.infinispan.commands.remote.recovery.TxCompletionNotificationCommand in project infinispan by infinispan.
the class RecoveryManagerImpl method removeRecoveryInformationFromCluster.
@Override
public CompletionStage<Void> removeRecoveryInformationFromCluster(Collection<Address> where, long internalId) {
if (rpcManager != null) {
TxCompletionNotificationCommand ftc = commandFactory.buildTxCompletionNotificationCommand(internalId);
CompletionStage<Void> stage = sendTxCompletionNotification(where, ftc);
removeRecoveryInformation(internalId);
return stage;
} else {
removeRecoveryInformation(internalId);
return CompletableFutures.completedNull();
}
}
use of org.infinispan.commands.remote.recovery.TxCompletionNotificationCommand in project infinispan by infinispan.
the class RecoveryManagerImpl method removeRecoveryInformation.
@Override
public CompletionStage<Void> removeRecoveryInformation(Collection<Address> lockOwners, XidImpl xid, GlobalTransaction gtx, boolean fromCluster) {
if (log.isTraceEnabled())
log.tracef("Forgetting tx information for %s", gtx);
// todo make sure this gets broad casted or at least flushed
if (rpcManager != null && !fromCluster) {
TxCompletionNotificationCommand ftc = commandFactory.buildTxCompletionNotificationCommand(xid, gtx);
CompletionStage<Void> stage = sendTxCompletionNotification(lockOwners, ftc);
removeRecoveryInformation(xid);
return stage;
} else {
removeRecoveryInformation(xid);
return CompletableFutures.completedNull();
}
}
use of org.infinispan.commands.remote.recovery.TxCompletionNotificationCommand in project infinispan by infinispan.
the class TransactionTable method removeTransactionInfoRemotely.
private void removeTransactionInfoRemotely(LocalTransaction localTransaction, GlobalTransaction gtx) {
if (mayHaveRemoteLocks(localTransaction) && !partitionHandlingManager.isTransactionPartiallyCommitted(gtx)) {
TxCompletionNotificationCommand command = commandsFactory.buildTxCompletionNotificationCommand(null, gtx);
LocalizedCacheTopology cacheTopology = clusteringLogic.getCacheTopology();
Collection<Address> owners = cacheTopology.getWriteOwners(localTransaction.getAffectedKeys());
Collection<Address> commitNodes = cacheTopology.getReadConsistentHash().isReplicated() ? null : owners;
commitNodes = localTransaction.getCommitNodes(commitNodes, cacheTopology);
if (log.isTraceEnabled())
log.tracef("About to invoke tx completion notification on commitNodes: %s", commitNodes);
rpcManager.sendToMany(commitNodes, command, DeliverOrder.NONE);
}
}
Aggregations