use of org.infinispan.distribution.MagicKey in project infinispan by infinispan.
the class AbstractClusterListenerTxTest method testBatchedCommitOriginatorNotLocal.
@Test
public void testBatchedCommitOriginatorNotLocal() throws SystemException, NotSupportedException, HeuristicRollbackException, HeuristicMixedException, RollbackException {
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 = new ClusterListener();
cache0.addListener(clusterListener);
MagicKey key1 = new MagicKey(cache1, cache2);
MagicKey key2 = new MagicKey(cache2, cache1);
TransactionManager tm = cache2.getAdvancedCache().getTransactionManager();
tm.begin();
cache2.put(key1, FIRST_VALUE);
assertEquals(clusterListener.events.size(), 0);
cache2.put(key2, SECOND_VALUE);
assertEquals(clusterListener.events.size(), 0);
tm.commit();
assertEquals(clusterListener.events.size(), 2);
verifyCreation(clusterListener.events, key1, FIRST_VALUE);
verifyCreation(clusterListener.events, key2, SECOND_VALUE);
}
use of org.infinispan.distribution.MagicKey in project infinispan by infinispan.
the class AbstractClusterListenerTxTest method testRolledBackLocal.
@Test
public void testRolledBackLocal() throws SystemException, NotSupportedException {
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 = new ClusterListener();
cache0.addListener(clusterListener);
MagicKey key1 = new MagicKey(cache0);
MagicKey key2 = new MagicKey(cache1, cache0);
TransactionManager tm = cache2.getAdvancedCache().getTransactionManager();
tm.begin();
cache0.put(key1, FIRST_VALUE);
assertEquals(clusterListener.events.size(), 0);
cache0.put(key2, SECOND_VALUE);
assertEquals(clusterListener.events.size(), 0);
tm.rollback();
assertEquals(clusterListener.events.size(), 0);
}
use of org.infinispan.distribution.MagicKey in project infinispan by infinispan.
the class AbstractClusterListenerTxTest method testBatchedCommitLocal.
@Test
public void testBatchedCommitLocal() throws HeuristicRollbackException, RollbackException, HeuristicMixedException, SystemException, NotSupportedException {
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 = new ClusterListener();
cache0.addListener(clusterListener);
MagicKey key1 = new MagicKey(cache0);
MagicKey key2 = new MagicKey(cache1, cache0);
TransactionManager tm = cache2.getAdvancedCache().getTransactionManager();
tm.begin();
cache0.put(key1, FIRST_VALUE);
assertEquals(clusterListener.events.size(), 0);
cache0.put(key2, SECOND_VALUE);
assertEquals(clusterListener.events.size(), 0);
tm.commit();
assertEquals(clusterListener.events.size(), 2);
verifyCreation(clusterListener.events, key1, FIRST_VALUE);
verifyCreation(clusterListener.events, key2, SECOND_VALUE);
}
use of org.infinispan.distribution.MagicKey in project infinispan by infinispan.
the class AbstractClusterListenerTxTest method testMultipleKeysSameOwnerBatchNotified.
@Test
public void testMultipleKeysSameOwnerBatchNotified() throws SystemException, NotSupportedException, HeuristicRollbackException, HeuristicMixedException, RollbackException {
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 = new ClusterListener();
cache0.addListener(clusterListener);
MagicKey key1 = new MagicKey(cache1);
MagicKey key2 = new MagicKey(cache1);
TransactionManager tm = cache2.getAdvancedCache().getTransactionManager();
tm.begin();
cache2.put(key1, FIRST_VALUE);
assertEquals(clusterListener.events.size(), 0);
cache2.put(key2, SECOND_VALUE);
assertEquals(clusterListener.events.size(), 0);
tm.commit();
assertEquals(clusterListener.events.size(), 2);
verifyCreation(clusterListener.events, key1, FIRST_VALUE);
verifyCreation(clusterListener.events, key2, SECOND_VALUE);
}
use of org.infinispan.distribution.MagicKey in project infinispan by infinispan.
the class StreamDistPartitionHandlingTest method testRetrievalWhenPartitionIsDegradedButLocal.
public void testRetrievalWhenPartitionIsDegradedButLocal() {
Cache<MagicKey, String> cache0 = cache(0);
cache0.put(new MagicKey(cache(1), cache(2)), "not-local");
cache0.put(new MagicKey(cache(0), cache(1)), "local");
splitCluster(new int[] { 0, 1 }, new int[] { 2, 3 });
partition(0).assertDegradedMode();
try (CloseableIterator<Map.Entry<MagicKey, String>> iterator = Closeables.iterator(cache0.getAdvancedCache().withFlags(Flag.CACHE_MODE_LOCAL).entrySet().stream())) {
assertEquals("local", iterator.next().getValue());
assertFalse(iterator.hasNext());
}
}
Aggregations