public void testBasicDistribution() throws Throwable { for (Cache<Object, String> c : caches) assertTrue(c.isEmpty()); final Object k1 = getKeyForCache(caches.get(1)); getOwners(k1)[0].put(k1, "value"); // No non-owners have requested the key, so no invalidations asyncWait(k1, PutKeyValueCommand.class); // should be available everywhere! assertOnAllCachesAndOwnership(k1, "value"); // and should now be in L1 if (l1CacheEnabled) { for (Cache<Object, String> c : caches) { if (isOwner(c, k1)) { assertIsInContainerImmortal(c, k1); } else { assertIsInL1(c, k1); } } } }
public void testLockedStreamSetValue() { int size = 5; for (int i = 0; i < size; i++) { getOwners("k" + i)[0].put("k" + i, "value" + i); // There will be no caches to invalidate as this is the first command of the test asyncWait("k" + i, PutKeyValueCommand.class); assertOnAllCachesAndOwnership("k" + i, "value" + i); } c1.getAdvancedCache().lockedStream().forEach((c, e) -> e.setValue(e.getValue() + "-changed")); for (int i = 0; i < size; i++) { String key = "k" + i; asyncWait(key, c -> commandIsPutForKey(key, c)); Cache<Object, String>[] caches = getOwners(key); for (Cache<Object, String> cache : caches) { assertEquals("value" + i + "-changed", cache.getAdvancedCache().withFlags(Flag.CACHE_MODE_LOCAL).get(key)); } } }
public void testLockedStreamPutValue() { int size = 5; for (int i = 0; i < size; i++) { getOwners("k" + i)[0].put("k" + i, "value" + i); // There will be no caches to invalidate as this is the first command of the test asyncWait("k" + i, PutKeyValueCommand.class); assertOnAllCachesAndOwnership("k" + i, "value" + i); } c1.getAdvancedCache().lockedStream().forEach((c, e) -> c.put(e.getKey(), e.getValue() + "-changed")); for (int i = 0; i < size; i++) { String key = "k" + i; asyncWait(key, c -> commandIsPutForKey(key, c)); Cache<Object, String>[] caches = getOwners(key); for (Cache<Object, String> cache : caches) { assertEquals("value" + i + "-changed", cache.getAdvancedCache().withFlags(Flag.CACHE_MODE_LOCAL).get(key)); } } }
public void testClear() throws InterruptedException { for (Cache<Object, String> c : caches) assertTrue(c.isEmpty()); for (int i = 0; i < 10; i++) { getOwners("k" + i)[0].put("k" + i, "value" + i); // There will be no caches to invalidate as this is the first command of the test asyncWait("k" + i, PutKeyValueCommand.class); assertOnAllCachesAndOwnership("k" + i, "value" + i); } // this will fill up L1 as well for (int i = 0; i < 10; i++) assertOnAllCachesAndOwnership("k" + i, "value" + i); for (Cache<Object, String> c : caches) assertFalse(c.isEmpty()); c1.clear(); asyncWait(null, ClearCommand.class); for (Cache<Object, String> c : caches) assertTrue(c.isEmpty()); }