Search in sources :

Example 1 with CountingRpcManager

use of org.infinispan.util.CountingRpcManager in project infinispan by infinispan.

the class RepeatableReadRemoteGetCountTest method replaceRpcManager.

private CountingRpcManager replaceRpcManager(Cache cache) {
    RpcManager current = TestingUtil.extractComponent(cache, RpcManager.class);
    if (current instanceof CountingRpcManager) {
        return (CountingRpcManager) current;
    }
    CountingRpcManager countingRpcManager = new CountingRpcManager(current);
    TestingUtil.replaceComponent(cache, RpcManager.class, countingRpcManager, true);
    return countingRpcManager;
}
Also used : CountingRpcManager(org.infinispan.util.CountingRpcManager) RpcManager(org.infinispan.remoting.rpc.RpcManager) CountingRpcManager(org.infinispan.util.CountingRpcManager)

Example 2 with CountingRpcManager

use of org.infinispan.util.CountingRpcManager in project infinispan by infinispan.

the class BiasRevocationTest method createCacheManagers.

@Override
protected void createCacheManagers() throws Throwable {
    ConfigurationBuilder builder = getDefaultClusteredCacheConfig(CacheMode.SCATTERED_SYNC, false);
    builder.clustering().biasAcquisition(BiasAcquisition.ON_WRITE).remoteTimeout(1000);
    createCluster(TestDataSCI.INSTANCE, builder, 3);
    TestingUtil.wrapComponent(cache(0), RpcManager.class, rpcManager -> rpcManager0 = new FailingRpcManager(rpcManager));
    // just touch to start it
    cache(1);
    TestingUtil.wrapComponent(cache(2), RpcManager.class, rpcManager -> rpcManager2 = new CountingRpcManager(rpcManager));
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) CountingRpcManager(org.infinispan.util.CountingRpcManager)

Example 3 with CountingRpcManager

use of org.infinispan.util.CountingRpcManager in project infinispan by infinispan.

the class FunctionalNoopDoesNotGoToBackupTest method createCacheManagers.

@Override
protected void createCacheManagers() throws Throwable {
    createCluster(TestDataSCI.INSTANCE, getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC), 2);
    FunctionalMapImpl<Object, Object> fmap0 = FunctionalMapImpl.create(cache(0).getAdvancedCache());
    FunctionalMapImpl<Object, Object> fmap1 = FunctionalMapImpl.create(cache(1).getAdvancedCache());
    rw0 = ReadWriteMapImpl.create(fmap0);
    rw1 = ReadWriteMapImpl.create(fmap1);
    wo0 = WriteOnlyMapImpl.create(fmap0);
    wo1 = WriteOnlyMapImpl.create(fmap1);
    key = new MagicKey(cache(0));
    rpcManager0 = TestingUtil.wrapComponent(cache(0), RpcManager.class, CountingRpcManager::new);
    rpcManager1 = TestingUtil.wrapComponent(cache(1), RpcManager.class, CountingRpcManager::new);
}
Also used : RpcManager(org.infinispan.remoting.rpc.RpcManager) CountingRpcManager(org.infinispan.util.CountingRpcManager) MagicKey(org.infinispan.distribution.MagicKey)

Example 4 with CountingRpcManager

use of org.infinispan.util.CountingRpcManager in project infinispan by infinispan.

the class RepeatableReadRemoteGetCountTest method testWithoutReading.

public void testWithoutReading() throws Exception {
    final Object key = new MagicKey("key", cache(0));
    final Cache<Object, Object> cache = cache(1);
    final TransactionManager tm = tm(1);
    final CountingRpcManager rpcManager = replaceRpcManager(cache);
    cache(0).put(key, "v0");
    tm.begin();
    rpcManager.resetStats();
    cache.getAdvancedCache().withFlags(Flag.IGNORE_RETURN_VALUES).put(key, "v1");
    AssertJUnit.assertEquals("Wrong number of gets after put.", 0, rpcManager.clusterGet);
    AssertJUnit.assertEquals("Wrong value read.", "v1", cache.get(key));
    AssertJUnit.assertEquals("Wrong number of gets after read.", 0, rpcManager.clusterGet);
    AssertJUnit.assertEquals("Wrong put return value.", "v1", cache.put(key, "v2"));
    AssertJUnit.assertEquals("Wrong number of gets after put.", 0, rpcManager.clusterGet);
    AssertJUnit.assertEquals("Wrong replace return value.", "v2", cache.replace(key, "v3"));
    AssertJUnit.assertEquals("Wrong number of gets after replace.", 0, rpcManager.clusterGet);
    AssertJUnit.assertEquals("Wrong conditional replace return value.", true, cache.replace(key, "v3", "v4"));
    AssertJUnit.assertEquals("Wrong number of gets after conditional replace.", 0, rpcManager.clusterGet);
    AssertJUnit.assertEquals("Wrong conditional remove return value.", true, cache.remove(key, "v4"));
    AssertJUnit.assertEquals("Wrong number of gets after conditional remove.", 0, rpcManager.clusterGet);
    AssertJUnit.assertEquals("Wrong conditional put return value.", null, cache.putIfAbsent(key, "v5"));
    AssertJUnit.assertEquals("Wrong number of gets after conditional put.", 0, rpcManager.clusterGet);
    tm.commit();
}
Also used : CountingRpcManager(org.infinispan.util.CountingRpcManager) TransactionManager(javax.transaction.TransactionManager) MagicKey(org.infinispan.distribution.MagicKey)

Example 5 with CountingRpcManager

use of org.infinispan.util.CountingRpcManager in project infinispan by infinispan.

the class RepeatableReadRemoteGetCountTest method doTest.

private void doTest(boolean initialized) throws Exception {
    final Object key = new MagicKey("key", cache(0));
    final Cache<Object, Object> cache = cache(1);
    final TransactionManager tm = tm(1);
    final CountingRpcManager rpcManager = replaceRpcManager(cache);
    if (initialized) {
        cache(0).put(key, "v1");
    }
    tm.begin();
    rpcManager.resetStats();
    AssertJUnit.assertEquals("Wrong value read.", initialized ? "v1" : null, cache.get(key));
    AssertJUnit.assertEquals("Wrong number of gets after read.", 1, rpcManager.clusterGet);
    AssertJUnit.assertEquals("Wrong put return value.", initialized ? "v1" : null, cache.put(key, "v2"));
    AssertJUnit.assertEquals("Wrong number of gets after put.", 1, rpcManager.clusterGet);
    AssertJUnit.assertEquals("Wrong replace return value.", "v2", cache.replace(key, "v3"));
    AssertJUnit.assertEquals("Wrong number of gets after replace.", 1, rpcManager.clusterGet);
    AssertJUnit.assertEquals("Wrong conditional replace return value.", true, cache.replace(key, "v3", "v4"));
    AssertJUnit.assertEquals("Wrong number of gets after conditional replace.", 1, rpcManager.clusterGet);
    AssertJUnit.assertEquals("Wrong conditional remove return value.", true, cache.remove(key, "v4"));
    AssertJUnit.assertEquals("Wrong number of gets after conditional remove.", 1, rpcManager.clusterGet);
    AssertJUnit.assertEquals("Wrong conditional put return value.", null, cache.putIfAbsent(key, "v5"));
    AssertJUnit.assertEquals("Wrong number of gets after conditional put.", 1, rpcManager.clusterGet);
    tm.commit();
}
Also used : CountingRpcManager(org.infinispan.util.CountingRpcManager) TransactionManager(javax.transaction.TransactionManager) MagicKey(org.infinispan.distribution.MagicKey)

Aggregations

CountingRpcManager (org.infinispan.util.CountingRpcManager)5 MagicKey (org.infinispan.distribution.MagicKey)3 TransactionManager (javax.transaction.TransactionManager)2 RpcManager (org.infinispan.remoting.rpc.RpcManager)2 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)1