/** {@inheritDoc} */ @Override public void put(Object key, Object val) { if (val == null) cache.withSkipStore().put(key, NULL); else cache.put(key, val); }
/** {@inheritDoc} */ @Override public ValueWrapper putIfAbsent(Object key, Object val) { Object old; if (val == null) old = cache.withSkipStore().getAndPutIfAbsent(key, NULL); else old = cache.getAndPutIfAbsent(key, val); return old != null ? fromValue(old) : null; }
@Override public Object call() throws Exception { clientCache.withKeepBinary(); clientCache.withSkipStore(); return null; } });
/** * @throws Exception If failed. */ @Test public void testWithSkipStoreTx() throws Exception { if (txShouldBeUsed()) { IgniteCache<String, Integer> cache = grid(0).cache(DEFAULT_CACHE_NAME); IgniteCache<String, Integer> cacheSkipStore = cache.withSkipStore(); final int KEYS = 250; // Put/remove data from multiple nodes. List<String> keys = new ArrayList<>(KEYS); for (int i = 0; i < KEYS; i++) keys.add("key_" + i); Map<String, Integer> data = new LinkedHashMap<>(); for (int i = 0; i < keys.size(); i++) data.put(keys.get(i), i); checkSkipStoreWithTransaction(cache, cacheSkipStore, data, keys, OPTIMISTIC, READ_COMMITTED); checkSkipStoreWithTransaction(cache, cacheSkipStore, data, keys, OPTIMISTIC, REPEATABLE_READ); checkSkipStoreWithTransaction(cache, cacheSkipStore, data, keys, OPTIMISTIC, SERIALIZABLE); checkSkipStoreWithTransaction(cache, cacheSkipStore, data, keys, PESSIMISTIC, READ_COMMITTED); checkSkipStoreWithTransaction(cache, cacheSkipStore, data, keys, PESSIMISTIC, REPEATABLE_READ); checkSkipStoreWithTransaction(cache, cacheSkipStore, data, keys, PESSIMISTIC, SERIALIZABLE); } }
/** * @throws Exception If failed. */ @Test public void testWithSkipStoreTx() throws Exception { if (txShouldBeUsed() && storeEnabled()) { IgniteCache<String, Integer> cache = grid(0).cache(cacheName()); IgniteCache<String, Integer> cacheSkipStore = cache.withSkipStore(); final int KEYS = 250; // Put/remove data from multiple nodes. List<String> keys = new ArrayList<>(KEYS); for (int i = 0; i < KEYS; i++) keys.add("key_" + i); Map<String, Integer> data = new LinkedHashMap<>(); for (int i = 0; i < keys.size(); i++) data.put(keys.get(i), i); checkSkipStoreWithTransaction(cache, cacheSkipStore, data, keys, OPTIMISTIC, READ_COMMITTED); checkSkipStoreWithTransaction(cache, cacheSkipStore, data, keys, OPTIMISTIC, REPEATABLE_READ); checkSkipStoreWithTransaction(cache, cacheSkipStore, data, keys, OPTIMISTIC, SERIALIZABLE); checkSkipStoreWithTransaction(cache, cacheSkipStore, data, keys, PESSIMISTIC, READ_COMMITTED); checkSkipStoreWithTransaction(cache, cacheSkipStore, data, keys, PESSIMISTIC, REPEATABLE_READ); checkSkipStoreWithTransaction(cache, cacheSkipStore, data, keys, PESSIMISTIC, SERIALIZABLE); } }
/** * @throws Exception If failed. */ @Test public void testEntryProcessorNoUpdate() throws Exception { IgniteCache<Object, Object> cache = ignite(0).cache(THROTTLES_CACHE_NAME); IgniteCache<Object, Object> skipStore = cache.withSkipStore(); int entryCnt = 500; Set<String> keys = new HashSet<>(); for (int i = 0; i < entryCnt; i++) { skipStore.put(String.valueOf(i), i); keys.add(String.valueOf(i)); } TestCacheStore testStore = (TestCacheStore)grid(0).context().cache().cache(THROTTLES_CACHE_NAME).context() .store().configuredStore(); assertEquals(0, testStore.writeCnt.get()); cache.invokeAll(keys, new NoOpEntryProcessor()); assertEquals(0, testStore.writeCnt.get()); cache.invokeAll(keys, new OpEntryProcessor()); assertEquals(1, testStore.writeCnt.get()); }
/** * @throws Exception If failed. */ @Test public void testRemoveAllSkipStore() throws Exception { IgniteCache<String, Integer> jcache = jcache(); jcache.putAll(F.asMap("1", 1, "2", 2, "3", 3)); jcache.withSkipStore().removeAll(); assertEquals((Integer)1, jcache.get("1")); assertEquals((Integer)2, jcache.get("2")); assertEquals((Integer)3, jcache.get("3")); }
/** {@inheritDoc} */ @Override public PlatformTarget processOutObject(int type) throws IgniteCheckedException { switch (type) { case OP_WITH_PARTITION_RECOVER: { return copy(rawCache.withPartitionRecover(), keepBinary); } case OP_WITH_KEEP_BINARY: { if (keepBinary) return this; return copy(rawCache.withKeepBinary(), true); } case OP_WITH_NO_RETRIES: { CacheOperationContext opCtx = cache.context().operationContextPerCall(); if (opCtx != null && opCtx.noRetries()) return this; return copy(rawCache.withNoRetries(), keepBinary); } case OP_WITH_SKIP_STORE: { CacheOperationContext opCtx = cache.context().operationContextPerCall(); if (opCtx != null && opCtx.skipStore()) return this; return copy(rawCache.withSkipStore(), keepBinary); } case OP_ITERATOR: { Iterator<Cache.Entry> iter = cache.iterator(); return new PlatformCacheIterator(platformCtx, iter); } } return super.processOutObject(type); }
IgniteCache<String, Integer> cacheSkipStore = cache.withSkipStore();
/** * @throws Exception If failed. */ @Test public void testRemoveAllSkipStore() throws Exception { if (!storeEnabled()) return; IgniteCache<String, Integer> jcache = jcache(); jcache.putAll(F.asMap("1", 1, "2", 2, "3", 3)); jcache.withSkipStore().removeAll(); assertEquals((Integer)1, jcache.get("1")); assertEquals((Integer)2, jcache.get("2")); assertEquals((Integer)3, jcache.get("3")); }
IgniteCache<String, Integer> cacheSkipStore = cache.withSkipStore();
/** * Checks that skipStore flag gets overridden inside a transaction. */ @Test public void testWriteThroughTx() { String key = "writeThroughKey"; storeStgy.removeFromStore(key); IgniteCache<String, Integer> cache = jcache(0); try (final Transaction transaction = grid(0).transactions().txStart()) { // retrieve market type from the grid Integer old = cache.withSkipStore().get(key); assertNull(old); // update the grid cache.put(key, 2); // finally commit the transaction transaction.commit(); } assertEquals(2, storeStgy.getFromStore(key)); }
.withSkipStore().withAllowAtomicOpsInTx();
/** * @throws Exception if failed. */ @Test public void testReadThroughSkipStore() throws Exception { Ignite ig = testedGrid(); CacheConfiguration<Object, Object> cc = variationConfig("skipStore"); final IgniteCache<Object, Object> cache = ig.createCache(cc); try { for (int i = 0; i < KEYS; i++) { cache.put(key(i), value(i)); cache.withSkipStore().remove(key(i)); } waitEmpty(cc.getName()); for (int i = 0; i < KEYS; i++) assertEquals(value(i), cache.get(key(i))); } finally { destroyCacheSafe(ig, cc.getName()); } }
IgniteCache<String, Integer> cache = jcache(0); IgniteCache<String, Integer> cacheSkipStore = cache.withSkipStore();
IgniteCache<String, Integer> cacheSkipStore = cache.withSkipStore();
/** {@inheritDoc} */ @Override public void put(Object key, Object val) { if (val == null) cache.withSkipStore().put(key, NULL); else cache.put(key, val); }
/** {@inheritDoc} */ @Override public ValueWrapper putIfAbsent(Object key, Object val) { Object old; if (val == null) old = cache.withSkipStore().getAndPutIfAbsent(key, NULL); else old = cache.getAndPutIfAbsent(key, val); return old != null ? fromValue(old) : null; }
/** {@inheritDoc} */ @Override public PlatformTarget processOutObject(int type) throws IgniteCheckedException { switch (type) { case OP_WITH_PARTITION_RECOVER: { return copy(rawCache.withPartitionRecover(), keepBinary); } case OP_WITH_KEEP_BINARY: { if (keepBinary) return this; return copy(rawCache.withKeepBinary(), true); } case OP_WITH_NO_RETRIES: { CacheOperationContext opCtx = cache.context().operationContextPerCall(); if (opCtx != null && opCtx.noRetries()) return this; return copy(rawCache.withNoRetries(), keepBinary); } case OP_WITH_SKIP_STORE: { CacheOperationContext opCtx = cache.context().operationContextPerCall(); if (opCtx != null && opCtx.skipStore()) return this; return copy(rawCache.withSkipStore(), keepBinary); } case OP_ITERATOR: { Iterator<Cache.Entry> iter = cache.iterator(); return new PlatformCacheIterator(platformCtx, iter); } } return super.processOutObject(type); }