Search in sources :

Example 16 with RpcManager

use of org.infinispan.remoting.rpc.RpcManager in project infinispan by infinispan.

the class PrepareCoordinator method rollbackRemoteTransaction.

/**
 * Rollbacks a transaction that is remove in all the cluster members.
 */
public final void rollbackRemoteTransaction(GlobalTransaction gtx) {
    RpcManager rpcManager = cache.getRpcManager();
    ComponentRegistry componentRegistry = cache.getComponentRegistry();
    CommandsFactory factory = componentRegistry.getCommandsFactory();
    try {
        RollbackCommand rollbackCommand = factory.buildRollbackCommand(gtx);
        rollbackCommand.setTopologyId(rpcManager.getTopologyId());
        CompletionStage<Void> cs = rpcManager.invokeCommandOnAll(rollbackCommand, validOnly(), rpcManager.getSyncRpcOptions());
        rollbackCommand.invokeAsync(componentRegistry).toCompletableFuture().join();
        cs.toCompletableFuture().join();
    } catch (Throwable throwable) {
        throw Util.rewrapAsCacheException(throwable);
    } finally {
        forgetTransaction(gtx, rpcManager, factory);
    }
}
Also used : CommandsFactory(org.infinispan.commands.CommandsFactory) RpcManager(org.infinispan.remoting.rpc.RpcManager) ComponentRegistry(org.infinispan.factories.ComponentRegistry) RollbackCommand(org.infinispan.commands.tx.RollbackCommand)

Example 17 with RpcManager

use of org.infinispan.remoting.rpc.RpcManager in project infinispan by infinispan.

the class PrepareCoordinator method onePhaseCommitRemoteTransaction.

/**
 * Commits a remote 1PC transaction that is already in MARK_COMMIT state
 */
public int onePhaseCommitRemoteTransaction(GlobalTransaction gtx, List<WriteCommand> modifications) {
    RpcManager rpcManager = cache.getRpcManager();
    ComponentRegistry componentRegistry = cache.getComponentRegistry();
    CommandsFactory factory = componentRegistry.getCommandsFactory();
    try {
        // only pessimistic tx are committed in 1PC and it doesn't use versions.
        PrepareCommand command = factory.buildPrepareCommand(gtx, modifications, true);
        CompletionStage<Void> cs = rpcManager.invokeCommandOnAll(command, validOnly(), rpcManager.getSyncRpcOptions());
        command.invokeAsync(componentRegistry).toCompletableFuture().join();
        cs.toCompletableFuture().join();
        forgetTransaction(gtx, rpcManager, factory);
        return loggingCompleted(true) == Status.OK ? XAResource.XA_OK : XAException.XAER_RMERR;
    } catch (Throwable throwable) {
        // transaction should commit but we still can have exceptions (timeouts or similar)
        return XAException.XAER_RMERR;
    }
}
Also used : CommandsFactory(org.infinispan.commands.CommandsFactory) RpcManager(org.infinispan.remoting.rpc.RpcManager) ComponentRegistry(org.infinispan.factories.ComponentRegistry) PrepareCommand(org.infinispan.commands.tx.PrepareCommand)

Example 18 with RpcManager

use of org.infinispan.remoting.rpc.RpcManager in project hibernate-orm by hibernate.

the class Caches method broadcastEvictAll.

/**
	 * Broadcast an evict-all command with the given cache instance.
	 *
	 * @param cache instance used to broadcast command
	 */
public static void broadcastEvictAll(AdvancedCache cache) {
    final RpcManager rpcManager = cache.getRpcManager();
    if (rpcManager != null) {
        // Only broadcast evict all if it's clustered
        final CacheCommandInitializer factory = cache.getComponentRegistry().getComponent(CacheCommandInitializer.class);
        final boolean isSync = isSynchronousCache(cache);
        final EvictAllCommand cmd = factory.buildEvictAllCommand(cache.getName());
        final RpcOptions options = rpcManager.getDefaultRpcOptions(isSync);
        rpcManager.invokeRemotely(null, cmd, options);
    }
}
Also used : RpcOptions(org.infinispan.remoting.rpc.RpcOptions) RpcManager(org.infinispan.remoting.rpc.RpcManager)

Example 19 with RpcManager

use of org.infinispan.remoting.rpc.RpcManager in project infinispan by infinispan.

the class RevokeBiasCommand method invokeAsync.

@Override
public CompletionStage<?> invokeAsync(ComponentRegistry componentRegistry) throws Throwable {
    BiasManager biasManager = componentRegistry.getBiasManager().running();
    for (Object key : keys) {
        biasManager.revokeLocalBias(key);
    }
    // ackTarget null means that this message is sent synchronously by primary owner == originator
    if (ackTarget != null) {
        RpcManager rpcManager = componentRegistry.getRpcManager().running();
        rpcManager.sendTo(ackTarget, new BackupAckCommand(cacheName, id, topologyId), DeliverOrder.NONE);
    }
    return CompletableFutures.completedNull();
}
Also used : RpcManager(org.infinispan.remoting.rpc.RpcManager) BiasManager(org.infinispan.scattered.BiasManager) BackupAckCommand(org.infinispan.commands.write.BackupAckCommand)

Example 20 with RpcManager

use of org.infinispan.remoting.rpc.RpcManager in project infinispan by infinispan.

the class IracTombstoneUnitTest method createRpcManager.

private static RpcManager createRpcManager() {
    RpcManager rpcManager = Mockito.mock(RpcManager.class);
    RpcOptions rpcOptions = Mockito.mock(RpcOptions.class);
    Transport transport = Mockito.mock(Transport.class);
    Mockito.doNothing().when(transport).checkCrossSiteAvailable();
    Mockito.when(transport.localSiteName()).thenReturn("B");
    Mockito.when(rpcManager.getTransport()).thenReturn(transport);
    Mockito.when(rpcManager.getSyncRpcOptions()).thenReturn(rpcOptions);
    Mockito.when(rpcManager.invokeCommand(ArgumentMatchers.anyCollection(), ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any())).thenReturn(CompletableFutures.completedNull());
    return rpcManager;
}
Also used : RpcOptions(org.infinispan.remoting.rpc.RpcOptions) RpcManager(org.infinispan.remoting.rpc.RpcManager) Transport(org.infinispan.remoting.transport.Transport)

Aggregations

RpcManager (org.infinispan.remoting.rpc.RpcManager)37 Address (org.infinispan.remoting.transport.Address)11 CommandsFactory (org.infinispan.commands.CommandsFactory)7 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)7 RpcOptions (org.infinispan.remoting.rpc.RpcOptions)7 Transport (org.infinispan.remoting.transport.Transport)7 Map (java.util.Map)5 ComponentRegistry (org.infinispan.factories.ComponentRegistry)5 DeliverOrder (org.infinispan.remoting.inboundhandler.DeliverOrder)4 RpcManagerImpl (org.infinispan.remoting.rpc.RpcManagerImpl)4 AbstractDelegatingRpcManager (org.infinispan.util.AbstractDelegatingRpcManager)4 ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)3 List (java.util.List)3 CompletableFuture (java.util.concurrent.CompletableFuture)3 Cache (org.infinispan.Cache)3 IntSet (org.infinispan.commons.util.IntSet)3 InternalDataContainer (org.infinispan.container.impl.InternalDataContainer)3 InitialPublisherCommand (org.infinispan.reactive.publisher.impl.commands.batch.InitialPublisherCommand)3 Response (org.infinispan.remoting.responses.Response)3