use of org.infinispan.persistence.dummy.DummyInMemoryStore in project infinispan by infinispan.
the class CacheManagerTest method testRemoveCacheLocal.
public void testRemoveCacheLocal(Method m) {
EmbeddedCacheManager manager = getManagerWithStore(m, false, false);
try {
Cache<String, String> cache = manager.getCache("cache");
cache.put(k(m, 1), v(m, 1));
cache.put(k(m, 2), v(m, 2));
cache.put(k(m, 3), v(m, 3));
DummyInMemoryStore store = getDummyStore(cache);
DataContainer<?, ?> data = getDataContainer(cache);
assertFalse(store.isEmpty());
assertTrue(0 != data.size());
manager.administration().removeCache("cache");
assertEquals(0, DummyInMemoryStore.getStoreDataSize(store.getStoreName()));
assertEquals(0, data.size());
// Try removing the cache again, it should be a no-op
manager.administration().removeCache("cache");
assertEquals(0, DummyInMemoryStore.getStoreDataSize(store.getStoreName()));
assertEquals(0, data.size());
} finally {
manager.stop();
}
}
use of org.infinispan.persistence.dummy.DummyInMemoryStore in project infinispan by infinispan.
the class DistSyncStoreSharedTest method testClear.
public void testClear() throws Exception {
for (Cache<Object, String> c : caches) assert c.isEmpty();
for (int i = 0; i < 5; i++) {
getOwners("k" + i)[0].put("k" + i, "value" + i);
asyncWait("k" + i, PutKeyValueCommand.class);
}
// 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) assert !c.isEmpty();
c1.clear();
asyncWait(null, ClearCommand.class);
for (Cache<Object, String> c : caches) assert c.isEmpty();
/* We only check c1 because on a shared situation, no matter where the clear is called,
* it should clear the whole store regardless. Bear in mind that in the test, even though
* the cache store is shared, each cache has each own cache store, that allows for checking
* who execute puts, removes...etc. */
DummyInMemoryStore store = TestingUtil.getFirstStore(c1);
// DummyInMemoryStore is segmented, so only 1 clear should be invoked
assertNumberOfInvocations(store, "clear", 1);
for (int i = 0; i < 5; i++) {
String key = "k" + i;
assert !store.contains(key);
}
}
use of org.infinispan.persistence.dummy.DummyInMemoryStore in project infinispan by infinispan.
the class PessimisticDistSyncTxStoreSharedTest method testInvalidPut.
@Test
public void testInvalidPut() throws Exception {
Cache<String, String> cache = cacheManagers.get(0).getCache("P006");
IntSet allSegments = IntSets.immutableRangeSet(cache.getCacheConfiguration().clustering().hash().numSegments());
// add 1st 4 elements
for (int i = 0; i < 4; i++) {
cache.put(cacheManagers.get(0).getAddress().toString() + "-" + i, "42");
}
// lets check if all elements arrived
DummyInMemoryStore cs1 = TestingUtil.getFirstStore(cache);
Set<Object> keys = PersistenceUtil.toKeySet(cs1, allSegments, null);
Assert.assertEquals(keys.size(), 4);
// now start 2nd node
addClusterEnabledCacheManager(getCB()).defineConfiguration("P006", getCB().build());
waitForClusterToForm("P006");
cache = cacheManagers.get(1).getCache("P006");
// add next 4 elements
for (int i = 0; i < 4; i++) {
cache.put(cacheManagers.get(1).getAddress().toString() + "-" + i, "42");
}
Set mergedKeys = new HashSet();
// add keys from all cache stores
DummyInMemoryStore cs2 = TestingUtil.getFirstStore(cache);
log.debugf("Load from cache store via cache 1");
mergedKeys.addAll(PersistenceUtil.toKeySet(cs1, allSegments, null));
log.debugf("Load from cache store via cache 2");
mergedKeys.addAll(PersistenceUtil.toKeySet(cs2, allSegments, null));
Assert.assertEquals(mergedKeys.size(), 8);
}
use of org.infinispan.persistence.dummy.DummyInMemoryStore in project infinispan by infinispan.
the class DistSyncStoreNotSharedTest method testGetOnlyQueriesCacheOnOwners.
public void testGetOnlyQueriesCacheOnOwners() throws PersistenceException {
// Make a key that own'ers is c1 and c2
final MagicKey k = getMagicKey();
final String v1 = "real-data";
final String v2 = "stale-data";
// Simulate a cache had it by itself and someone wrote a value that is now stale
Cache<Object, String> c = getFirstOwner(k);
DummyInMemoryStore store = TestingUtil.getFirstStore(c);
store.write(MarshalledEntryUtil.create(k, v2, c3));
getFirstNonOwner(k).put(k, v1);
assertEquals(v1, c.get(k));
}
use of org.infinispan.persistence.dummy.DummyInMemoryStore in project infinispan by infinispan.
the class DistSyncStoreNotSharedTest method assertRemovedFromStores.
protected void assertRemovedFromStores(String key) {
for (Cache<Object, String> c : caches) {
DummyInMemoryStore store = TestingUtil.getFirstStore(c);
MarshallableEntry me = store.loadEntry(key);
// handle possible tombstones
assert me == null || me.getValue() == null;
}
}
Aggregations