use of org.infinispan.persistence.dummy.DummyInMemoryStore in project infinispan by infinispan.
the class LocalModePassivationTest method testStoreAndLoadWithGetEntry.
public void testStoreAndLoadWithGetEntry() {
final int numKeys = 300;
for (int i = 0; i < numKeys; i++) {
cache().put(i, i);
}
int keysInDataContainer = cache().getAdvancedCache().getDataContainer().size();
// some keys got evicted
assertTrue(keysInDataContainer != numKeys);
DummyInMemoryStore dims = TestingUtil.getFirstStore(cache());
long keysInCacheStore = dims.size();
if (passivationEnabled) {
assertEquals(numKeys, keysInDataContainer + keysInCacheStore);
} else {
assertEquals(numKeys, keysInCacheStore);
}
// check if keys survive restart
cache().stop();
cache().start();
dims = TestingUtil.getFirstStore(cache());
assertEquals(numKeys, dims.size());
for (int i = 0; i < numKeys; i++) {
assertEquals(i, cache.getAdvancedCache().getCacheEntry(i).getValue());
}
}
use of org.infinispan.persistence.dummy.DummyInMemoryStore in project infinispan by infinispan.
the class EvictionWithPassivationTest method putIntoStore.
private void putIntoStore(String key, String value) {
AdvancedCache<String, String> testCache = cacheManager.<String, String>getCache(CACHE_NAME).getAdvancedCache();
DummyInMemoryStore writer = TestingUtil.getFirstStore(testCache);
Object writerKey = testCache.getKeyDataConversion().toStorage(key);
Object writerValue = testCache.getValueDataConversion().toStorage(value);
MarshallableEntry entry;
if (Configurations.isTxVersioned(testCache.getCacheConfiguration())) {
entry = MarshalledEntryUtil.createWithVersion(writerKey, writerValue, testCache);
} else {
entry = MarshalledEntryUtil.create(writerKey, writerValue, testCache);
}
writer.write(entry);
}
use of org.infinispan.persistence.dummy.DummyInMemoryStore in project infinispan by infinispan.
the class RehashWithSharedStoreTest method testRehashes.
public void testRehashes() throws PersistenceException {
MagicKey k = new MagicKey("k", c1);
c1.put(k, "v");
Cache<Object, String>[] owners = getOwners(k);
log.infof("Initial owners list for key %s: %s", k, Arrays.asList(owners));
// Ensure the loader is shared!
for (Cache<Object, String> c : Arrays.asList(c1, c2, c3)) {
DummyInMemoryStore dims = TestingUtil.getFirstStore(c);
assertTrue("CacheStore on " + c + " should contain key " + k, dims.contains(k));
}
Cache<Object, String> primaryOwner = owners[0];
if (getCacheStoreStats(primaryOwner, "write") == 0)
primaryOwner = owners[1];
for (Cache<Object, String> c : owners) {
int numWrites = getCacheStoreStats(c, "write");
assertEquals(1, numWrites);
}
log.infof("Stopping node %s", primaryOwner);
caches.remove(primaryOwner);
primaryOwner.stop();
primaryOwner.getCacheManager().stop();
TestingUtil.blockUntilViewsReceived(60000, false, caches);
TestingUtil.waitForNoRebalance(caches);
owners = getOwners(k);
log.infof("After shutting one node down, owners list for key %s: %s", k, Arrays.asList(owners));
assertEquals(numOwners, owners.length);
for (Cache<Object, String> o : owners) {
int numWrites = getCacheStoreStats(o, "write");
assertEquals(1, numWrites);
assertEquals("v", o.get(k));
}
}
use of org.infinispan.persistence.dummy.DummyInMemoryStore in project infinispan by infinispan.
the class SharedStoreInvalidationDuringRehashTest method checkContentAndInvalidations.
private void checkContentAndInvalidations(boolean preload) {
int clusterSize = getCacheManagers().size();
HashMap<Object, Integer> currentOwners = new HashMap<>();
for (int i = 0; i < clusterSize; i++) {
Cache<String, String> testCache = manager(i).getCache(TEST_CACHE_NAME);
DistributionManager dm = testCache.getAdvancedCache().getDistributionManager();
DataContainer dataContainer = testCache.getAdvancedCache().getDataContainer();
for (int j = 0; j < NUM_KEYS; j++) {
String key = "key" + j;
if (!dm.getCacheTopology().isReadOwner(key)) {
if (!cacheMode.isScattered()) {
assertFalse("Key '" + key + "' is not owned by node " + address(i) + " but it still appears there", dataContainer.containsKey(key));
}
} else {
currentOwners.put(key, i);
if (preload) {
assertTrue("Key '" + key + "' is owned by node " + address(i) + " but it does not appear there", dataContainer.containsKey(key));
}
}
}
}
DummyInMemoryStore store = TestingUtil.getFirstStore(cache(0, TEST_CACHE_NAME));
for (int i = 0; i < NUM_KEYS; i++) {
String key = "key" + i;
assertTrue("Key " + key + " is missing from the shared store", store.keySet().contains(key));
}
if (cacheMode.isScattered()) {
// In scattered cache the invalidation happens only on some entries and through InvalidateVersionsCommand
return;
}
// Reset stats for the next check
store.clearStats();
}
use of org.infinispan.persistence.dummy.DummyInMemoryStore in project infinispan by infinispan.
the class FlagsEnabledTest method assertLoadsAndReset.
private void assertLoadsAndReset(Cache<?, ?> cache1, int expected1, Cache<?, ?> cache2, int expected2) {
DummyInMemoryStore store1 = getCacheStore(cache1);
DummyInMemoryStore store2 = getCacheStore(cache2);
assertEquals(expected1, (int) store1.stats().get("load"));
assertEquals(expected2, (int) store2.stats().get("load"));
store1.clearStats();
store2.clearStats();
}
Aggregations