Search in sources :

Example 71 with MagicKey

use of org.infinispan.distribution.MagicKey in project infinispan by infinispan.

the class AbstractClusterListenerTest method testCreateFromNonOwnerWithListenerNotOwner.

@Test
public void testCreateFromNonOwnerWithListenerNotOwner() {
    Cache<Object, String> cache0 = cache(0, CACHE_NAME);
    Cache<Object, String> cache1 = cache(1, CACHE_NAME);
    Cache<Object, String> cache2 = cache(2, CACHE_NAME);
    ClusterListener clusterListener = listener();
    cache0.addListener(clusterListener);
    MagicKey key = new MagicKey(cache1, cache2);
    verifySimpleInsertion(cache2, key, FIRST_VALUE, null, clusterListener, FIRST_VALUE);
}
Also used : MagicKey(org.infinispan.distribution.MagicKey) Test(org.testng.annotations.Test)

Example 72 with MagicKey

use of org.infinispan.distribution.MagicKey in project infinispan by infinispan.

the class AbstractClusterListenerTest method testMetadataFilterLocalOnly.

@Test
public void testMetadataFilterLocalOnly() {
    final String keyToFilterOut = "filter-me";
    testFilter(keyToFilterOut, new MagicKey(cache(0, CACHE_NAME)), 1000l, new KeyValueFilterAsCacheEventFilter(new LifespanFilter<Object, String>(100)));
}
Also used : KeyValueFilterAsCacheEventFilter(org.infinispan.notifications.cachelistener.filter.KeyValueFilterAsCacheEventFilter) MagicKey(org.infinispan.distribution.MagicKey) Test(org.testng.annotations.Test)

Example 73 with MagicKey

use of org.infinispan.distribution.MagicKey in project infinispan by infinispan.

the class AbstractClusterListenerTest method testMetadataConverterNoPassReturnNullNotOwner.

@Test
public void testMetadataConverterNoPassReturnNullNotOwner() {
    long lifespan = 25000;
    LifespanConverter converter = new LifespanConverter(false, Long.MAX_VALUE);
    testConverter(new MagicKey(cache(1, CACHE_NAME), cache(2, CACHE_NAME)), FIRST_VALUE, null, lifespan, converter);
}
Also used : MagicKey(org.infinispan.distribution.MagicKey) Test(org.testng.annotations.Test)

Example 74 with MagicKey

use of org.infinispan.distribution.MagicKey in project infinispan by infinispan.

the class AbstractClusterListenerTest method testListenerOnBackupOwnerNodeBackupRead.

public void testListenerOnBackupOwnerNodeBackupRead() {
    Cache<Object, String> cache0 = cache(0, CACHE_NAME);
    Cache<Object, String> cache1 = cache(1, CACHE_NAME);
    MagicKey key = new MagicKey(cache0, cache1);
    String expectedValue = key + "-expiring";
    cache0.put(key, key + "-expiring", 10, TimeUnit.MILLISECONDS);
    ClusterListener clusterListener = listener();
    cache0.addListener(clusterListener);
    ts1.advance(11);
    assertNull(cache1.get(key));
    int expectCount = clusterListener.hasIncludeState() ? 2 : 1;
    eventually(() -> clusterListener.events.size() >= expectCount);
    assertEquals(expectCount, clusterListener.events.size());
    CacheEntryEvent event = clusterListener.events.get(clusterListener.hasIncludeState() ? 1 : 0);
    assertEquals(Event.Type.CACHE_ENTRY_EXPIRED, event.getType());
    assertEquals(key, event.getKey());
    assertEquals(expectedValue, event.getValue());
}
Also used : MagicKey(org.infinispan.distribution.MagicKey) CacheEntryEvent(org.infinispan.notifications.cachelistener.event.CacheEntryEvent)

Example 75 with MagicKey

use of org.infinispan.distribution.MagicKey in project infinispan by infinispan.

the class AbstractClusterListenerTest method testLocalNodeNonOwnerAndClusterListener.

@Test
public void testLocalNodeNonOwnerAndClusterListener() {
    Cache<Object, String> cache0 = cache(0, CACHE_NAME);
    Cache<Object, String> cache1 = cache(1, CACHE_NAME);
    Cache<Object, String> cache2 = cache(2, CACHE_NAME);
    ClusterListener clusterListener = listener();
    cache0.addListener(clusterListener);
    MagicKey key = new MagicKey(cache1, cache2);
    verifySimpleInsertion(cache0, key, FIRST_VALUE, null, clusterListener, FIRST_VALUE);
}
Also used : MagicKey(org.infinispan.distribution.MagicKey) Test(org.testng.annotations.Test)

Aggregations

MagicKey (org.infinispan.distribution.MagicKey)185 Test (org.testng.annotations.Test)74 TransactionManager (javax.transaction.TransactionManager)23 CheckPoint (org.infinispan.test.fwk.CheckPoint)20 HashMap (java.util.HashMap)16 Map (java.util.Map)16 Transaction (javax.transaction.Transaction)16 Cache (org.infinispan.Cache)16 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)15 CountDownLatch (java.util.concurrent.CountDownLatch)10 CacheMode (org.infinispan.configuration.cache.CacheMode)10 CacheEntry (org.infinispan.container.entries.CacheEntry)10 Address (org.infinispan.remoting.transport.Address)10 StateSequencer (org.infinispan.test.concurrent.StateSequencer)9 AssertJUnit.assertEquals (org.testng.AssertJUnit.assertEquals)9 ArrayList (java.util.ArrayList)8 CyclicBarrier (java.util.concurrent.CyclicBarrier)8 DistributionManager (org.infinispan.distribution.DistributionManager)8 MultipleCacheManagersTest (org.infinispan.test.MultipleCacheManagersTest)8 RollbackException (javax.transaction.RollbackException)7