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);
}
}
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;
}
}
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);
}
}
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();
}
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;
}
Aggregations