use of org.infinispan.util.ReplicatedControlledConsistentHashFactory in project infinispan by infinispan.
the class OrphanTransactionsCleanupTest method createCacheManagers.
@Override
protected void createCacheManagers() throws Throwable {
configurationBuilder = getDefaultClusteredCacheConfig(CacheMode.REPL_SYNC, true);
configurationBuilder.transaction().lockingMode(LockingMode.PESSIMISTIC);
// Make the coordinator the primary owner of the only segment
configurationBuilder.clustering().hash().numSegments(1).consistentHashFactory(new ReplicatedControlledConsistentHashFactory(0));
configurationBuilder.clustering().stateTransfer().awaitInitialTransfer(false);
addClusterEnabledCacheManager(configurationBuilder);
addClusterEnabledCacheManager(configurationBuilder);
waitForClusterToForm();
}
use of org.infinispan.util.ReplicatedControlledConsistentHashFactory in project infinispan by infinispan.
the class ReplCommandForwardingTest method buildConfig.
private ConfigurationBuilder buildConfig(Class<?> commandToBlock) {
ConfigurationBuilder configurationBuilder = getDefaultClusteredCacheConfig(CacheMode.REPL_ASYNC, false);
configurationBuilder.clustering().remoteTimeout(15000);
// The coordinator will always be the primary owner
configurationBuilder.clustering().hash().numSegments(1).consistentHashFactory(new ReplicatedControlledConsistentHashFactory(0));
configurationBuilder.clustering().stateTransfer().fetchInMemoryState(true);
// We must block after the commit was replicated, but before the entries are committed
configurationBuilder.customInterceptors().addInterceptor().after(EntryWrappingInterceptor.class).interceptor(new DelayInterceptor(commandToBlock));
return configurationBuilder;
}
use of org.infinispan.util.ReplicatedControlledConsistentHashFactory in project infinispan by infinispan.
the class PessimisticLockingTxClusterExtendedStatisticLogicTest method createCacheManagers.
@Override
protected void createCacheManagers() {
for (int i = 0; i < NUM_NODES; ++i) {
ConfigurationBuilder builder = getDefaultClusteredCacheConfig(CacheMode.REPL_SYNC, true);
builder.clustering().hash().numSegments(1).consistentHashFactory(new ReplicatedControlledConsistentHashFactory(0));
//
builder.locking().isolationLevel(IsolationLevel.REPEATABLE_READ).lockAcquisitionTimeout(// the timeout are triggered by the TimeService!
60000);
builder.transaction().recovery().disable();
builder.transaction().lockingMode(LockingMode.PESSIMISTIC);
// builder.versioning().enable().scheme(VersioningScheme.SIMPLE);
extendedStatisticInterceptors[i] = new ExtendedStatisticInterceptor();
builder.customInterceptors().addInterceptor().interceptor(extendedStatisticInterceptors[i]).after(TxInterceptor.class);
addClusterEnabledCacheManager(builder);
}
waitForClusterToForm();
for (int i = 0; i < NUM_NODES; ++i) {
ExtendedStatisticInterceptor interceptor = extendedStatisticInterceptors[i];
CacheStatisticManager manager = extractField(interceptor, "cacheStatisticManager");
CacheStatisticCollector collector = extractField(manager, "cacheStatisticCollector");
ConcurrentGlobalContainer globalContainer = extractField(collector, "globalContainer");
ExtendedStatisticRpcManager rpcManager = (ExtendedStatisticRpcManager) extractComponent(cache(i), RpcManager.class);
ExtendedStatisticLockManager lockManager = (ExtendedStatisticLockManager) extractLockManager(cache(i));
lockManagers[i] = lockManager;
replaceField(TEST_TIME_SERVICE, "timeService", manager, CacheStatisticManager.class);
replaceField(TEST_TIME_SERVICE, "timeService", collector, CacheStatisticCollector.class);
replaceField(TEST_TIME_SERVICE, "timeService", globalContainer, ConcurrentGlobalContainer.class);
replaceField(TEST_TIME_SERVICE, "timeService", interceptor, ExtendedStatisticInterceptor.class);
replaceField(TEST_TIME_SERVICE, "timeService", lockManager, ExtendedStatisticLockManager.class);
replaceField(TEST_TIME_SERVICE, "timeService", rpcManager, ExtendedStatisticRpcManager.class);
controlledRpcManager[i] = ControlledRpcManager.replaceRpcManager(cache(i));
transactionTrackInterceptors[i] = TransactionTrackInterceptor.injectInCache(cache(i));
if (i == 0) {
LockManager actualLockManager = lockManager.getActual();
LockContainer container = extractField(actualLockManager, "lockContainer");
TestingUtil.inject(container, new WithinThreadExecutor(), lockManagerTimeService);
}
}
}
use of org.infinispan.util.ReplicatedControlledConsistentHashFactory in project infinispan by infinispan.
the class APITest method createCacheManagers.
@Override
protected void createCacheManagers() throws Throwable {
ConfigurationBuilder cfg = getDefaultClusteredCacheConfig(CacheMode.REPL_SYNC, true);
cfg.clustering().hash().numSegments(1).consistentHashFactory(new ReplicatedControlledConsistentHashFactory(0));
cfg.transaction().lockingMode(LockingMode.PESSIMISTIC).cacheStopTimeout(0).locking().lockAcquisitionTimeout(TestingUtil.shortTimeoutMillis());
createCluster(cfg, 2);
}
use of org.infinispan.util.ReplicatedControlledConsistentHashFactory 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