Search in sources :

Example 1 with TxCompletionNotificationCommand

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);
}
Also used : AbstractDelegatingRpcManager(org.infinispan.util.AbstractDelegatingRpcManager) Function(java.util.function.Function) RpcManager(org.infinispan.remoting.rpc.RpcManager) AbstractDelegatingRpcManager(org.infinispan.util.AbstractDelegatingRpcManager) TxCompletionNotificationCommand(org.infinispan.commands.remote.recovery.TxCompletionNotificationCommand) ReplicableCommand(org.infinispan.commands.ReplicableCommand) TransactionTable(org.infinispan.transaction.impl.TransactionTable) Collection(java.util.Collection)

Example 2 with TxCompletionNotificationCommand

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);
    });
}
Also used : CacheNotFoundResponse(org.infinispan.remoting.responses.CacheNotFoundResponse) UnsureResponse(org.infinispan.remoting.responses.UnsureResponse) Response(org.infinispan.remoting.responses.Response) Address(org.infinispan.remoting.transport.Address) TransactionBoundaryCommand(org.infinispan.commands.tx.TransactionBoundaryCommand) TxCompletionNotificationCommand(org.infinispan.commands.remote.recovery.TxCompletionNotificationCommand) GlobalTransaction(org.infinispan.transaction.xa.GlobalTransaction) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 3 with TxCompletionNotificationCommand

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();
    }
}
Also used : TxCompletionNotificationCommand(org.infinispan.commands.remote.recovery.TxCompletionNotificationCommand)

Example 4 with TxCompletionNotificationCommand

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();
    }
}
Also used : TxCompletionNotificationCommand(org.infinispan.commands.remote.recovery.TxCompletionNotificationCommand)

Example 5 with TxCompletionNotificationCommand

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);
    }
}
Also used : Address(org.infinispan.remoting.transport.Address) TxCompletionNotificationCommand(org.infinispan.commands.remote.recovery.TxCompletionNotificationCommand) LocalizedCacheTopology(org.infinispan.distribution.LocalizedCacheTopology)

Aggregations

TxCompletionNotificationCommand (org.infinispan.commands.remote.recovery.TxCompletionNotificationCommand)7 Address (org.infinispan.remoting.transport.Address)2 GlobalTransaction (org.infinispan.transaction.xa.GlobalTransaction)2 Collection (java.util.Collection)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Function (java.util.function.Function)1 ReplicableCommand (org.infinispan.commands.ReplicableCommand)1 ClusteredGetCommand (org.infinispan.commands.remote.ClusteredGetCommand)1 CommitCommand (org.infinispan.commands.tx.CommitCommand)1 PrepareCommand (org.infinispan.commands.tx.PrepareCommand)1 RollbackCommand (org.infinispan.commands.tx.RollbackCommand)1 TransactionBoundaryCommand (org.infinispan.commands.tx.TransactionBoundaryCommand)1 LocalizedCacheTopology (org.infinispan.distribution.LocalizedCacheTopology)1 ExtendedStatistic (org.infinispan.extendedstats.container.ExtendedStatistic)1 CacheNotFoundResponse (org.infinispan.remoting.responses.CacheNotFoundResponse)1 Response (org.infinispan.remoting.responses.Response)1 UnsureResponse (org.infinispan.remoting.responses.UnsureResponse)1 RpcManager (org.infinispan.remoting.rpc.RpcManager)1 TransactionTable (org.infinispan.transaction.impl.TransactionTable)1