Search in sources :

Example 6 with ConcurrentGlobalContainer

use of org.infinispan.extendedstats.container.ConcurrentGlobalContainer in project infinispan by infinispan.

the class ConcurrentContainerTest method testIsolationWithEnqueueAndResetSingleAction.

public void testIsolationWithEnqueueAndResetSingleAction() {
    final ConcurrentGlobalContainer globalContainer = new ConcurrentGlobalContainer(TIME_SERVICE);
    final List<StatisticsSnapshot> snapshots = new ArrayList<>(4);
    snapshots.add(globalContainer.getSnapshot());
    // two random stats, one local and one remote
    final ExtendedStatistic localStat = ExtendedStatistic.PREPARE_COMMAND_SIZE;
    final ExtendedStatistic remoteStat = ExtendedStatistic.NUM_COMMITTED_WR_TX;
    Assert.assertTrue(localStat.isLocal());
    Assert.assertTrue(remoteStat.isRemote());
    globalContainer.flushing().set(true);
    globalContainer.add(localStat, 10, true);
    globalContainer.add(remoteStat, 20, false);
    snapshots.add(globalContainer.getSnapshot());
    assertSnapshotValues(snapshots, Arrays.asList(0D, 0D), localStat, true);
    assertSnapshotValues(snapshots, Arrays.asList(0D, 0D), remoteStat, false);
    Assert.assertEquals(globalContainer.queue().size(), 2);
    globalContainer.flushing().set(false);
    snapshots.add(globalContainer.getSnapshot());
    assertSnapshotValues(snapshots, Arrays.asList(0D, 0D, 10D), localStat, true);
    assertSnapshotValues(snapshots, Arrays.asList(0D, 0D, 20D), remoteStat, false);
    globalContainer.reset();
    snapshots.clear();
    snapshots.add(globalContainer.getSnapshot());
    assertSnapshotValues(snapshots, Collections.singletonList(0D), localStat, true);
    assertSnapshotValues(snapshots, Collections.singletonList(0D), remoteStat, false);
    globalContainer.flushing().set(true);
    globalContainer.add(localStat, 10, true);
    globalContainer.add(remoteStat, 20, false);
    globalContainer.reset();
    snapshots.add(globalContainer.getSnapshot());
    Assert.assertTrue(globalContainer.isReset());
    Assert.assertEquals(globalContainer.queue().size(), 2);
    assertSnapshotValues(snapshots, Arrays.asList(0D, 0D), localStat, true);
    assertSnapshotValues(snapshots, Arrays.asList(0D, 0D), remoteStat, false);
    globalContainer.flushing().set(false);
    snapshots.add(globalContainer.getSnapshot());
    Assert.assertFalse(globalContainer.isReset());
    Assert.assertTrue(globalContainer.queue().isEmpty());
    assertSnapshotValues(snapshots, Arrays.asList(0D, 0D, 0D), localStat, true);
    assertSnapshotValues(snapshots, Arrays.asList(0D, 0D, 0D), remoteStat, false);
    assertFinalState(globalContainer);
}
Also used : ExtendedStatistic(org.infinispan.extendedstats.container.ExtendedStatistic) StatisticsSnapshot(org.infinispan.extendedstats.container.StatisticsSnapshot) ArrayList(java.util.ArrayList) ConcurrentGlobalContainer(org.infinispan.extendedstats.container.ConcurrentGlobalContainer)

Example 7 with ConcurrentGlobalContainer

use of org.infinispan.extendedstats.container.ConcurrentGlobalContainer 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);
        }
    }
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) ExtendedStatisticRpcManager(org.infinispan.extendedstats.wrappers.ExtendedStatisticRpcManager) ExtendedStatisticRpcManager(org.infinispan.extendedstats.wrappers.ExtendedStatisticRpcManager) ControlledRpcManager(org.infinispan.util.ControlledRpcManager) RpcManager(org.infinispan.remoting.rpc.RpcManager) CacheStatisticCollector(org.infinispan.extendedstats.CacheStatisticCollector) ExtendedStatisticInterceptor(org.infinispan.extendedstats.wrappers.ExtendedStatisticInterceptor) WithinThreadExecutor(org.infinispan.util.concurrent.WithinThreadExecutor) ReplicatedControlledConsistentHashFactory(org.infinispan.util.ReplicatedControlledConsistentHashFactory) ExtendedStatisticLockManager(org.infinispan.extendedstats.wrappers.ExtendedStatisticLockManager) ConcurrentGlobalContainer(org.infinispan.extendedstats.container.ConcurrentGlobalContainer) CacheStatisticManager(org.infinispan.extendedstats.CacheStatisticManager) LockManager(org.infinispan.util.concurrent.locks.LockManager) ExtendedStatisticLockManager(org.infinispan.extendedstats.wrappers.ExtendedStatisticLockManager) TestingUtil.extractLockManager(org.infinispan.test.TestingUtil.extractLockManager) LockContainer(org.infinispan.util.concurrent.locks.impl.LockContainer)

Example 8 with ConcurrentGlobalContainer

use of org.infinispan.extendedstats.container.ConcurrentGlobalContainer in project infinispan by infinispan.

the class BaseTxClusterExtendedStatisticLogicTest method createCacheManagers.

@Override
protected void createCacheManagers() throws Throwable {
    for (int i = 0; i < NUM_NODES; ++i) {
        ConfigurationBuilder builder = getDefaultClusteredCacheConfig(cacheMode, true);
        builder.locking().isolationLevel(IsolationLevel.READ_COMMITTED).lockAcquisitionTimeout(0);
        builder.clustering().hash().numOwners(1);
        builder.transaction().recovery().disable();
        extendedStatisticInterceptors[i] = new ExtendedStatisticInterceptor();
        builder.customInterceptors().addInterceptor().interceptor(extendedStatisticInterceptors[i]).after(TxInterceptor.class);
        addClusterEnabledCacheManager(TestDataSCI.INSTANCE, builder);
    }
    waitForClusterToForm();
    for (int i = 0; i < NUM_NODES; ++i) {
        TestingUtil.replaceComponent(cacheManagers.get(i), TimeService.class, TEST_TIME_SERVICE, true);
        lockManagers[i] = extractLockManager(cache(i));
        ExtendedStatisticInterceptor interceptor = extendedStatisticInterceptors[i];
        CacheStatisticManager manager = extractField(interceptor, "cacheStatisticManager");
        CacheStatisticCollector collector = extractField(manager, "cacheStatisticCollector");
        ConcurrentGlobalContainer globalContainer = extractField(collector, "globalContainer");
        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", lockManagers[i], ExtendedStatisticLockManager.class);
        replaceField(TEST_TIME_SERVICE, "timeService", extractComponent(cache(i), RpcManager.class), ExtendedStatisticRpcManager.class);
        transactionTrackInterceptors[i] = TransactionTrackInterceptor.injectInCache(cache(i));
    }
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) ExtendedStatisticRpcManager(org.infinispan.extendedstats.wrappers.ExtendedStatisticRpcManager) RpcManager(org.infinispan.remoting.rpc.RpcManager) ExtendedStatisticInterceptor(org.infinispan.extendedstats.wrappers.ExtendedStatisticInterceptor) ConcurrentGlobalContainer(org.infinispan.extendedstats.container.ConcurrentGlobalContainer)

Example 9 with ConcurrentGlobalContainer

use of org.infinispan.extendedstats.container.ConcurrentGlobalContainer in project infinispan by infinispan.

the class LocalTxClusterExtendedStatisticLogicTest method setup.

@Override
protected void setup() throws Exception {
    super.setup();
    CacheStatisticManager manager = extractField(extendedStatisticInterceptor, "cacheStatisticManager");
    CacheStatisticCollector collector = extractField(manager, "cacheStatisticCollector");
    ConcurrentGlobalContainer globalContainer = extractField(collector, "globalContainer");
    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", extendedStatisticInterceptor, ExtendedStatisticInterceptor.class);
    replaceField(TEST_TIME_SERVICE, "timeService", extractLockManager(cache()), ExtendedStatisticLockManager.class);
}
Also used : CacheStatisticManager(org.infinispan.extendedstats.CacheStatisticManager) CacheStatisticCollector(org.infinispan.extendedstats.CacheStatisticCollector) ConcurrentGlobalContainer(org.infinispan.extendedstats.container.ConcurrentGlobalContainer)

Example 10 with ConcurrentGlobalContainer

use of org.infinispan.extendedstats.container.ConcurrentGlobalContainer in project infinispan by infinispan.

the class OptimisticLockingTxClusterExtendedStatisticLogicTest 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(TestingUtil.shortTimeoutMillis());
        builder.transaction().recovery().disable();
        builder.transaction().lockingMode(LockingMode.OPTIMISTIC);
        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);
        }
    }
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) ExtendedStatisticRpcManager(org.infinispan.extendedstats.wrappers.ExtendedStatisticRpcManager) ExtendedStatisticRpcManager(org.infinispan.extendedstats.wrappers.ExtendedStatisticRpcManager) ControlledRpcManager(org.infinispan.util.ControlledRpcManager) RpcManager(org.infinispan.remoting.rpc.RpcManager) CacheStatisticCollector(org.infinispan.extendedstats.CacheStatisticCollector) ExtendedStatisticInterceptor(org.infinispan.extendedstats.wrappers.ExtendedStatisticInterceptor) WithinThreadExecutor(org.infinispan.util.concurrent.WithinThreadExecutor) ReplicatedControlledConsistentHashFactory(org.infinispan.util.ReplicatedControlledConsistentHashFactory) ExtendedStatisticLockManager(org.infinispan.extendedstats.wrappers.ExtendedStatisticLockManager) ConcurrentGlobalContainer(org.infinispan.extendedstats.container.ConcurrentGlobalContainer) CacheStatisticManager(org.infinispan.extendedstats.CacheStatisticManager) LockManager(org.infinispan.util.concurrent.locks.LockManager) ExtendedStatisticLockManager(org.infinispan.extendedstats.wrappers.ExtendedStatisticLockManager) TestingUtil.extractLockManager(org.infinispan.test.TestingUtil.extractLockManager) LockContainer(org.infinispan.util.concurrent.locks.impl.LockContainer)

Aggregations

ConcurrentGlobalContainer (org.infinispan.extendedstats.container.ConcurrentGlobalContainer)10 ArrayList (java.util.ArrayList)6 ExtendedStatistic (org.infinispan.extendedstats.container.ExtendedStatistic)6 StatisticsSnapshot (org.infinispan.extendedstats.container.StatisticsSnapshot)6 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)3 CacheStatisticCollector (org.infinispan.extendedstats.CacheStatisticCollector)3 CacheStatisticManager (org.infinispan.extendedstats.CacheStatisticManager)3 ExtendedStatisticInterceptor (org.infinispan.extendedstats.wrappers.ExtendedStatisticInterceptor)3 ExtendedStatisticRpcManager (org.infinispan.extendedstats.wrappers.ExtendedStatisticRpcManager)3 RpcManager (org.infinispan.remoting.rpc.RpcManager)3 ExtendedStatisticLockManager (org.infinispan.extendedstats.wrappers.ExtendedStatisticLockManager)2 TestingUtil.extractLockManager (org.infinispan.test.TestingUtil.extractLockManager)2 ControlledRpcManager (org.infinispan.util.ControlledRpcManager)2 ReplicatedControlledConsistentHashFactory (org.infinispan.util.ReplicatedControlledConsistentHashFactory)2 WithinThreadExecutor (org.infinispan.util.concurrent.WithinThreadExecutor)2 LockManager (org.infinispan.util.concurrent.locks.LockManager)2 LockContainer (org.infinispan.util.concurrent.locks.impl.LockContainer)2