use of org.infinispan.persistence.dummy.DummyInMemoryStore in project infinispan by infinispan.
the class DistSyncStoreNotSharedTest method prepareClearTest.
private void prepareClearTest() throws PersistenceException {
for (Cache<Object, String> c : caches) assert c.isEmpty() : "Data container " + c + " should be empty, instead it contains keys " + c.keySet();
for (int i = 0; i < 5; i++) {
getOwners("k" + i)[0].put("k" + i, "value" + i);
}
// this will fill up L1 as well
for (int i = 0; i < 5; i++) assertOnAllCachesAndOwnership("k" + i, "value" + i);
for (Cache<Object, String> c : caches) {
assertFalse(c.isEmpty());
DummyInMemoryStore store = TestingUtil.getFirstStore(c);
for (int i = 0; i < 5; i++) {
String key = "k" + i;
if (isOwner(c, key)) {
assertTrue("Cache store " + c + " does not contain key " + key, store.contains(key));
}
}
}
}
use of org.infinispan.persistence.dummy.DummyInMemoryStore in project infinispan by infinispan.
the class DistSyncStoreNotSharedTest method testPutFromNonOwner.
public void testPutFromNonOwner(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(nonOwnerLoader.contains(key));
assertFalse(ownerLoader.contains(key));
Object retval = nonOwner.put(key, value);
assertInStores(key, value, true);
if (testRetVals)
assert retval == null;
assertOnAllCachesAndOwnership(key, value);
}
use of org.infinispan.persistence.dummy.DummyInMemoryStore in project infinispan by infinispan.
the class DistSyncStoreNotSharedTest method testGetFromNonOwnerWithFlags.
public void testGetFromNonOwnerWithFlags(Method m) throws Exception {
String key = k(m), value = "value2";
Cache<Object, String> nonOwner = getFirstNonOwner(key);
Cache<Object, String> owner = getFirstOwner(key);
DummyInMemoryStore ownerLoader = TestingUtil.getFirstStore(owner);
owner.put(key, value);
assertEquals(value, ownerLoader.loadEntry(key).getValue());
owner.getAdvancedCache().withFlags(Flag.SKIP_CACHE_STORE).clear();
assertEquals(value, ownerLoader.loadEntry(key).getValue());
assertNull(owner.getAdvancedCache().withFlags(Flag.SKIP_CACHE_LOAD).get(key));
assertNull(nonOwner.getAdvancedCache().withFlags(Flag.SKIP_CACHE_LOAD).get(key));
assertEquals(value, nonOwner.get(key));
// need to do the get() on all the owners first to load the values, otherwise assertOwnershipAndNonOwnership might fail
assertOnAllCaches(key, value);
assertOwnershipAndNonOwnership(key, true);
}
use of org.infinispan.persistence.dummy.DummyInMemoryStore in project infinispan by infinispan.
the class DistSyncStoreNotSharedTest method testAtomicPutIfAbsentFromNonOwnerWithFlag.
public void testAtomicPutIfAbsentFromNonOwnerWithFlag(Method m) throws Exception {
String key = k(m), value = "value";
String replaced = getFirstNonOwner(key).getAdvancedCache().withFlags(Flag.SKIP_CACHE_STORE).putIfAbsent(key, value);
assertNull(replaced);
// interesting case: fails to put as value exists, put actually missing in Store
replaced = getFirstNonOwner(key).putIfAbsent(key, value);
assertEquals(replaced, value);
for (Cache<Object, String> c : caches) {
assertEquals(replaced, c.get(key));
DummyInMemoryStore store = TestingUtil.getFirstStore(c);
assertFalse(store.contains(key));
}
}
use of org.infinispan.persistence.dummy.DummyInMemoryStore in project infinispan by infinispan.
the class DistSyncStoreSharedTest method testPutFromOwner.
public void testPutFromOwner() throws Exception {
String key = "k5", value = "value5";
for (Cache<Object, String> c : caches) assert c.isEmpty();
Cache[] owners = getOwners(key);
Object retval = owners[0].put(key, value);
asyncWait(key, PutKeyValueCommand.class);
DummyInMemoryStore store = TestingUtil.<DummyInMemoryStore, Object, Object>getFirstStore(owners[0]);
assertIsInContainerImmortal(owners[0], key);
assert store.contains(key);
for (int i = 1; i < owners.length; i++) {
store = TestingUtil.<DummyInMemoryStore, Object, Object>getFirstStore(owners[i]);
assertIsInContainerImmortal(owners[i], key);
assert store.contains(key);
}
for (Cache<Object, String> c : caches) {
store = TestingUtil.getFirstStore(c);
if (isOwner(c, key)) {
assertIsInContainerImmortal(c, key);
}
assert store.contains(key);
assertNumberOfInvocations(store, "write", 1);
}
if (testRetVals)
assert retval == null;
assertOnAllCachesAndOwnership(key, value);
}
Aggregations