use of org.infinispan.remoting.rpc.RpcManager in project infinispan by infinispan.
the class PessimistTxFailureAfterLockingTest method replaceRpcManagerInCache.
private void replaceRpcManagerInCache(Cache cache) {
RpcManager rpcManager = TestingUtil.extractComponent(cache, RpcManager.class);
TestControllerRpcManager testControllerRpcManager = new TestControllerRpcManager(rpcManager);
TestingUtil.replaceComponent(cache, RpcManager.class, testControllerRpcManager, true);
}
use of org.infinispan.remoting.rpc.RpcManager 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.remoting.rpc.RpcManager in project infinispan by infinispan.
the class OutboundRpcSequencerAction method replaceRpcManager.
private void replaceRpcManager() {
if (ourRpcManager == null) {
ComponentRegistry componentRegistry = cache.getAdvancedCache().getComponentRegistry();
RpcManager rpcManager = componentRegistry.getComponent(RpcManager.class);
ourRpcManager = new SequencerRpcManager(rpcManager, stateSequencer, matcher);
TestingUtil.replaceComponent(cache, RpcManager.class, ourRpcManager, true);
}
}
use of org.infinispan.remoting.rpc.RpcManager in project infinispan by infinispan.
the class MessageSentToLeaverTest method testGroupRequestSentToMemberAfterLeaving.
public void testGroupRequestSentToMemberAfterLeaving() {
EmbeddedCacheManager cm1 = null, cm2 = null, cm3 = null;
try {
ConfigurationBuilder c = new ConfigurationBuilder();
c.clustering().cacheMode(CacheMode.REPL_SYNC).hash().numOwners(3);
cm1 = TestCacheManagerFactory.createClusteredCacheManager(c);
cm2 = TestCacheManagerFactory.createClusteredCacheManager(c);
cm3 = TestCacheManagerFactory.createClusteredCacheManager(c);
Cache<Object, Object> c1 = cm1.getCache();
Cache<Object, Object> c2 = cm2.getCache();
Cache<Object, Object> c3 = cm3.getCache();
TestingUtil.blockUntilViewsReceived(30000, c1, c2, c3);
c2.put("k", "v1");
RpcManager rpcManager = TestingUtil.extractComponent(c1, RpcManager.class);
Collection<Address> addresses = cm1.getMembers();
CommandsFactory cf = TestingUtil.extractCommandsFactory(c1);
PutKeyValueCommand cmd = cf.buildPutKeyValueCommand("k", "v2", 0, new EmbeddedMetadata.Builder().build(), EnumUtil.EMPTY_BIT_SET);
RpcOptions rpcOptions = rpcManager.getSyncRpcOptions();
cmd.setTopologyId(rpcManager.getTopologyId());
Map<Address, Response> responseMap = rpcManager.blocking(rpcManager.invokeCommand(addresses, cmd, MapResponseCollector.validOnly(), rpcOptions));
assert responseMap.size() == 2;
TestingUtil.killCacheManagers(cm2);
TestingUtil.blockUntilViewsReceived(30000, false, c1, c3);
try {
rpcManager.blocking(rpcManager.invokeCommand(addresses, cmd, MapResponseCollector.validOnly(), rpcOptions));
assert false : "invokeRemotely should have thrown an exception";
} catch (SuspectException e) {
// expected
}
} finally {
TestingUtil.killCacheManagers(cm1, cm2, cm3);
}
}
use of org.infinispan.remoting.rpc.RpcManager in project infinispan by infinispan.
the class ForceSyncAsyncFlagsTest method testForceAsyncFlagUsage.
public void testForceAsyncFlagUsage() throws Exception {
ConfigurationBuilder builder = getDefaultClusteredCacheConfig(CacheMode.REPL_SYNC, false);
builder.clustering().hash().numSegments(1).consistentHashFactory(new ReplicatedControlledConsistentHashFactory(0));
createClusteredCaches(2, "replSync", builder);
AdvancedCache<String, String> cache1 = this.<String, String>cache(0, "replSync").getAdvancedCache();
cache(1, "replSync").getAdvancedCache();
Transport originalTransport = TestingUtil.extractGlobalComponent(cache1.getCacheManager(), Transport.class);
RpcManagerImpl rpcManager = (RpcManagerImpl) TestingUtil.extractComponent(cache1, RpcManager.class);
Transport mockTransport = spy(originalTransport);
rpcManager.setTransport(mockTransport);
// check that the replication call was sync
cache1.put("k", "v");
verify(mockTransport).invokeCommandOnAll(any(), any(), any(), any(), anyLong(), any());
reset(mockTransport);
// verify FORCE_ASYNCHRONOUS flag on SYNC cache
cache1.withFlags(Flag.FORCE_ASYNCHRONOUS).put("k", "v");
verify(mockTransport).sendToAll(any(ReplicableCommand.class), any(DeliverOrder.class));
}
Aggregations