/** * Populate cache with {@code 'dimensions'} which in our case are {@link DimStore} and {@link * DimProduct} instances. * * @param dimCache Cache to populate. * @throws IgniteException If failed. */ private static void populateDimensions(Cache<Integer, Object> dimCache) throws IgniteException { DimStore store1 = new DimStore(idGen++, "Store1", "12345", "321 Chilly Dr, NY"); DimStore store2 = new DimStore(idGen++, "Store2", "54321", "123 Windy Dr, San Francisco"); // Populate stores. dimCache.put(store1.getId(), store1); dimCache.put(store2.getId(), store2); dataStore.put(store1.getId(), store1); dataStore.put(store2.getId(), store2); // Populate products for (int i = 0; i < 20; i++) { int id = idGen++; DimProduct product = new DimProduct(id, "Product" + i, i + 1, (i + 1) * 10); dimCache.put(id, product); dataProduct.put(id, product); } }
/** {@inheritDoc} */ @Override public void testClear() throws Exception { IgniteCache<String, Integer> nearCache = jcache(); IgniteCache<String, Integer> primary = fullCache(); Collection<String> keys = primaryKeysForCache(primary, 3); Map<String, Integer> vals = new HashMap<>(); int i = 0; for (String key : keys) { nearCache.put(key, i); vals.put(key, i); i++; } i = 0; for (String key : keys) assertEquals((Integer) i++, nearCache.localPeek(key, CachePeekMode.ONHEAP)); nearCache.clear(); for (String key : keys) assertNull(nearCache.localPeek(key, CachePeekMode.ONHEAP)); for (Map.Entry<String, Integer> entry : vals.entrySet()) nearCache.put(entry.getKey(), entry.getValue()); i = 0; for (String key : keys) assertEquals((Integer) i++, nearCache.localPeek(key, CachePeekMode.ONHEAP)); }