private static void assertNoEntry(Cache<Object, String> cache, Object KEY) { assertEquals(null, cache.getAdvancedCache().getDataContainer().get(KEY)); }
public static void assertIsNotInL1(Cache<?, ?> cache, Object key) { DataContainer dc = cache.getAdvancedCache().getDataContainer(); InternalCacheEntry ice = dc.get(key); assert ice == null : "Entry for key [" + key + "] should not be in data container at all on cache at [" + addressOf(cache) + "]!"; }
public void testShort() throws Exception { long numberInserted = CACHE_SIZE / 2; Random random = new Random(); // Note that there is overhead for the map itself, so we will not get exactly the same amount // More than likely there will be a few hundred byte overhead for (short i = 0; i < numberInserted; i++) { cache.put(i, Short.valueOf((short) random.nextInt(Short.MAX_VALUE + 1))); } assertTrue(cache.getAdvancedCache().getDataContainer().size() < numberInserted); }
public void testBaseCustomInterceptorInjection() { AsyncInterceptor interceptor = cache.getAdvancedCache().getInterceptorChain().get(0); assertEquals(SomeInterceptor.class, interceptor.getClass()); SomeInterceptor someInterceptor = (SomeInterceptor) interceptor; assertSame(cache.getAdvancedCache().getLockManager(), someInterceptor.lm); assertSame(cache.getAdvancedCache().getDataContainer(), someInterceptor.dc); }
public void testRemoveFromMainOwner() { Object k = getKeyForCache(0); cache(0).put(k, "0"); cache(0).remove(k, "1"); assertEquals(advancedCache(0).getDataContainer().get(k).getValue(), "0"); assertEquals(advancedCache(1).getDataContainer().get(k).getValue(), "0"); cache(0).remove(k, "0"); assertNull(advancedCache(0).getDataContainer().get(k)); assertNull(advancedCache(1).getDataContainer().get(k)); }
public void testPutIfAbsentFromMainOwner() { Object k = getKeyForCache(0); cache(0).put(k, "0"); cache(0).putIfAbsent(k, "1"); assertEquals(advancedCache(0).getDataContainer().get(k).getValue(), "0"); assertEquals(advancedCache(1).getDataContainer().get(k).getValue(), "0"); cache(0).remove(k); cache(0).putIfAbsent(k, "1"); assertEquals(advancedCache(0).getDataContainer().get(k).getValue(), "1"); assertEquals(advancedCache(1).getDataContainer().get(k).getValue(), "1"); } }
private void assertNotInCacheAndStore(Object... keys) throws PersistenceException { for (Object key : keys) { assert !cache.getAdvancedCache().getDataContainer().containsKey(key) : "Cache should not contain key " + key; assert !store.contains(key) : "Store should not contain key " + key; } }
public void testInvalidation() throws Exception { assertEquals(Collections.singletonList(address(0)), advancedCache(0).getDistributionManager().locate(k0)); assertEquals(Collections.singletonList(address(0)), advancedCache(1).getDistributionManager().locate(k0)); advancedCache(1).put(k0, "k1"); assertTrue(advancedCache(1).getDataContainer().containsKey(k0)); assertTrue(advancedCache(0).getDataContainer().containsKey(k0)); tm(0).begin(); cache(0).put(k0, "v2"); tm(0).commit(); assertFalse(advancedCache(1).getDataContainer().containsKey(k0)); }
protected boolean checkOwners(List<Address> owners) { assert owners.size() == 2; InternalCacheEntry entry0 = advancedCache(owners.get(0)).getDataContainer().get("k"); InternalCacheEntry entry1 = advancedCache(owners.get(1)).getDataContainer().get("k"); return checkOwnerEntries(entry0, entry1, owners.get(0), owners.get(1)); }
@Override public void call() { cache.put("k1", "v1"); cache.put("k2", "v2"); assertEquals("cache size must be 1", 1, cache.getAdvancedCache().getDataContainer().size()); } });
public void testInteger() throws Exception { long numberInserted = CACHE_SIZE / 8; Random random = new Random(); // Note that there is overhead for the map itself, so we will not get exactly the same amount // More than likely there will be a few hundred byte overhead for (int i = 0; i < numberInserted; i++) { cache.put(i, Integer.valueOf(random.nextInt())); } assertTrue(cache.getAdvancedCache().getDataContainer().size() < numberInserted); }
@Override public void call() { AdvancedCache<Object, Object> cache = cm.getCache().getAdvancedCache(); assertEquals(3, cache.getDataContainer().size()); int found = 0; for (int i = 0; i < 10; i++) { Person p = new Person("name" + i, "surname" + i, 30); if (cache.getDataContainer().containsKey(p)) { found++; } } assertEquals(3, found); } });
protected boolean isInL1(Cache<?, ?> cache, Object key) { DataContainer dc = cache.getAdvancedCache().getDataContainer(); InternalCacheEntry ice = dc.get(key); return ice != null && ice.getValue() != null && !(ice instanceof ImmortalCacheEntry); }
public void testRemoveFromMainOwner() { Object k = getKeyForCache(0); cache(0).put(k, "0"); cache(0).remove(k, "1"); assertEquals(advancedCache(0).getDataContainer().get(k).getValue(), "0"); assertEquals(advancedCache(1).getDataContainer().get(k).getValue(), "0"); cache(0).remove(k, "0"); assertNull(advancedCache(0).getDataContainer().get(k)); assertNull(advancedCache(1).getDataContainer().get(k)); }
public void testPutIfAbsentFromMainOwner() { Object k = getKeyForCache(0); cache(0).put(k, "0"); cache(0).putIfAbsent(k, "1"); assertEquals(advancedCache(0).getDataContainer().get(k).getValue(), "0"); assertEquals(advancedCache(1).getDataContainer().get(k).getValue(), "0"); cache(0).remove(k); cache(0).putIfAbsent(k, "1"); assertEquals(advancedCache(0).getDataContainer().get(k).getValue(), "1"); assertEquals(advancedCache(1).getDataContainer().get(k).getValue(), "1"); } }
private void checkValue(Object key, String value) { if (!waitForStateTransfer) { TestingUtil.waitForNoRebalance(originatorCache, otherCache); } log.tracef("Checking key: %s", key); InternalCacheEntry d0 = advancedCache(ORIGINATOR_INDEX).getDataContainer().get(key); InternalCacheEntry d1 = advancedCache(OTHER_INDEX).getDataContainer().get(key); assertEquals(d0.getValue(), value); assertEquals(d1.getValue(), value); }
protected void assertNoLocalValue(int node, MagicKey key) { InternalCacheEntry<Object, Object> ice = cache(node, cacheName).getAdvancedCache().getDataContainer().get(key); assertEquals(null, ice); }
public void testFloat() throws Exception { long numberInserted = CACHE_SIZE / 4; Random random = new Random(); // Note that there is overhead for the map itself, so we will not get exactly the same amount // More than likely there will be a few hundred byte overhead for (float i = 0; i < numberInserted; i++) { cache.put(i, Float.valueOf(random.nextFloat())); } assertTrue(cache.getAdvancedCache().getDataContainer().size() < numberInserted); }
public void testBaseCustomAsyncInterceptorInjection() { AsyncInterceptor interceptor = cache.getAdvancedCache().getAsyncInterceptorChain().getInterceptors().get(0); assertEquals(SomeAsyncInterceptor.class, interceptor.getClass()); SomeAsyncInterceptor someAsyncInterceptor = (SomeAsyncInterceptor) interceptor; assertSame(cache.getAdvancedCache().getLockManager(), someAsyncInterceptor.lm); assertSame(cache.getAdvancedCache().getDataContainer(), someAsyncInterceptor.dc); }
public static void assertIsInL1(Cache<?, ?> cache, Object key) { DataContainer dc = cache.getAdvancedCache().getDataContainer(); InternalCacheEntry ice = dc.get(key); assert ice != null : "Entry for key [" + key + "] should be in L1 on cache at [" + addressOf(cache) + "]!"; assert !(ice instanceof ImmortalCacheEntry) : "Entry for key [" + key + "] should have a lifespan on cache at [" + addressOf(cache) + "]!"; }