Search in sources :

Example 41 with DummyInMemoryStore

use of org.infinispan.persistence.dummy.DummyInMemoryStore in project infinispan by infinispan.

the class DistSyncStoreNotSharedTest method testRemoveFromNonOwnerWithFlags.

public void testRemoveFromNonOwnerWithFlags() throws Exception {
    String key = "k1", value = "value";
    initAndTest();
    Object retval = getFirstNonOwner(key).getAdvancedCache().withFlags(Flag.SKIP_CACHE_STORE).remove(key);
    if (testRetVals)
        assert value.equals(retval);
    for (Cache<Object, String> c : caches) {
        if (isOwner(c, key)) {
            DummyInMemoryStore store = TestingUtil.getFirstStore(c);
            assertTrue(store.contains(key));
        }
    }
}
Also used : DummyInMemoryStore(org.infinispan.persistence.dummy.DummyInMemoryStore)

Example 42 with DummyInMemoryStore

use of org.infinispan.persistence.dummy.DummyInMemoryStore in project infinispan by infinispan.

the class DistSyncStoreNotSharedTest method testPutFromNonOwnerWithFlags.

public void testPutFromNonOwnerWithFlags(Method m) throws Exception {
    String key = k(m), value = "value2";
    Cache<Object, String> nonOwner = getFirstNonOwner(key);
    Cache<Object, String> owner = getFirstOwner(key);
    DummyInMemoryStore nonOwnerLoader = TestingUtil.getFirstStore(nonOwner);
    DummyInMemoryStore ownerLoader = TestingUtil.getFirstStore(owner);
    assertFalse(ownerLoader.contains(key));
    assertFalse(nonOwnerLoader.contains(key));
    Object retval = nonOwner.getAdvancedCache().withFlags(Flag.SKIP_CACHE_STORE).put(key, value);
    assertFalse(ownerLoader.contains(key));
    assertFalse(nonOwnerLoader.contains(key));
    if (testRetVals)
        assert retval == null;
    assertOnAllCachesAndOwnership(key, value);
}
Also used : DummyInMemoryStore(org.infinispan.persistence.dummy.DummyInMemoryStore)

Example 43 with DummyInMemoryStore

use of org.infinispan.persistence.dummy.DummyInMemoryStore in project infinispan by infinispan.

the class DistSyncStoreNotSharedTest method testPutForStateTransfer.

public void testPutForStateTransfer() throws Exception {
    MagicKey k1 = getMagicKey();
    DummyInMemoryStore store2 = TestingUtil.getFirstStore(c2);
    c2.put(k1, v1);
    assertTrue(store2.contains(k1));
    assertEquals(v1, store2.loadEntry(k1).getValue());
    c2.getAdvancedCache().withFlags(Flag.CACHE_MODE_LOCAL).put(k1, v2);
    assertEquals(v2, store2.loadEntry(k1).getValue());
}
Also used : DummyInMemoryStore(org.infinispan.persistence.dummy.DummyInMemoryStore)

Example 44 with DummyInMemoryStore

use of org.infinispan.persistence.dummy.DummyInMemoryStore in project infinispan by infinispan.

the class DistSyncStoreNotSharedTest method testAtomicPutIfAbsentFromNonOwner.

public void testAtomicPutIfAbsentFromNonOwner(Method m) throws Exception {
    String key = k(m), value = "value", value2 = "v2";
    String replaced = getFirstNonOwner(key).putIfAbsent(key, value);
    assertNull(replaced);
    replaced = getFirstNonOwner(key).putIfAbsent(key, value2);
    assertEquals(replaced, value);
    for (Cache<Object, String> c : caches) {
        assertEquals(replaced, c.get(key));
        if (isOwner(c, key)) {
            DummyInMemoryStore store = TestingUtil.getFirstStore(c);
            assertTrue(store.contains(key));
            assertEquals(value, store.loadEntry(key).getValue());
        }
    }
}
Also used : DummyInMemoryStore(org.infinispan.persistence.dummy.DummyInMemoryStore)

Example 45 with DummyInMemoryStore

use of org.infinispan.persistence.dummy.DummyInMemoryStore in project infinispan by infinispan.

the class DistSyncStoreNotSharedTest method assertInStores.

protected void assertInStores(String key, String value, boolean allowL1) {
    for (Cache<Object, String> c : caches) {
        DummyInMemoryStore store = TestingUtil.getFirstStore(c);
        if (isOwner(c, key)) {
            assertIsInContainerImmortal(c, key);
            assertEquals(value, store.loadEntry(key).getValue());
        } else {
            if (!allowL1) {
                assertIsNotInL1(c, key);
            }
            assertFalse(store.contains(key));
        }
    }
}
Also used : DummyInMemoryStore(org.infinispan.persistence.dummy.DummyInMemoryStore)

Aggregations

DummyInMemoryStore (org.infinispan.persistence.dummy.DummyInMemoryStore)74 PersistenceManager (org.infinispan.persistence.manager.PersistenceManager)14 Test (org.testng.annotations.Test)13 MarshallableEntry (org.infinispan.persistence.spi.MarshallableEntry)11 HashMap (java.util.HashMap)9 TestObjectStreamMarshaller (org.infinispan.marshall.TestObjectStreamMarshaller)7 Map (java.util.Map)6 Cache (org.infinispan.Cache)6 DataContainer (org.infinispan.container.DataContainer)6 CacheEntry (org.infinispan.container.entries.CacheEntry)6 ImmortalCacheEntry (org.infinispan.container.entries.ImmortalCacheEntry)6 CheckPoint (org.infinispan.test.fwk.CheckPoint)6 MagicKey (org.infinispan.distribution.MagicKey)5 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)4 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)4 DummyInMemoryStoreConfigurationBuilder (org.infinispan.persistence.dummy.DummyInMemoryStoreConfigurationBuilder)4 Set (java.util.Set)3 PersistenceException (org.infinispan.persistence.spi.PersistenceException)3 List (java.util.List)2 TimeUnit (java.util.concurrent.TimeUnit)2