@Override public boolean apply() { for (int i = 0; i < gridCount(); i++) { if (jcache(i).localPeek(key) != null) return false; } return true; } }, ttl + 1000);
@Override public boolean apply() { return cache.localPeek(key) == null; } }, ttl + 1000);
/** {@inheritDoc} */ @Override public V call() throws Exception { return cache().localPeek(key, peekModes); } }
@Override public void run() { Long val = cache.localPeek(new GridTestKey(key), CachePeekMode.ONHEAP); if (val == null || val != key) throw new RuntimeException("Invalid value found [key=" + key + ", val=" + val + ']'); } });
@Override public void applyx(IgniteCache<String, Integer> cache) { int rnd = random(); Set<Integer> ids = new HashSet<>(set); cache.removeAll(rangeKeys(0, rnd)); for (int i = 0; i < rnd; i++) { if (ids.contains(i)) assertNull(cache.localPeek("key" + i)); } } });
@Override public Void call() throws Exception { IgniteCache<Integer, String> cache = ignite.cache(DEFAULT_CACHE_NAME); assertNotNull(cache); assertEquals(partial ? initVal : val, cache.localPeek(key)); return null; } });
@Override public Void call() throws Exception { IgniteCache<Integer, String> cache = ignite.cache(DEFAULT_CACHE_NAME); assertNotNull(cache); if (atomicityMode() != TRANSACTIONAL_SNAPSHOT) { assertEquals("Failed to check entry value on node: " + checkNodeId, fullFailure ? initVal : val, cache.localPeek(key)); } return null; } });
@Override public Void call() throws Exception { IgniteCache<Integer, String> cache = ignite.cache(DEFAULT_CACHE_NAME); assertNotNull(cache); assertEquals("Failed to check entry value on node: " + checkNodeId, !commmit ? initVal : val, cache.localPeek(key)); return null; } });
@Override public void applyx(IgniteCache<String, Integer> cache) { int rnd = random(); Set<Integer> ids = new HashSet<>(set); cache.removeAllAsync(rangeKeys(0, rnd)).get(); for (int i = 0; i < rnd; i++) { if (ids.contains(i)) assertNull(cache.localPeek("key" + i)); } } });
/** */ private void checkPeekNearCache() throws Exception { Stream.of(primaryKey(cache), backupKey(cache), nearKey(cache)).forEach(key -> { cache.put(key, 1); assertNull(cache.localPeek(key, CachePeekMode.NEAR)); }); } }
/** */ private void checkPeekOnheap() throws Exception { Stream.of(primaryKey(cache), backupKey(cache), nearKey(cache)).forEach(key -> { cache.put(key, 1); assertNull(cache.localPeek(key, CachePeekMode.ONHEAP)); }); }
/** * @param key Key. */ private void checkExpired(Integer key) { for (int i = 0; i < gridCount(); i++) { IgniteCache<Integer, Integer> cache = jcache(i); assertNull(cache.localPeek(key, CachePeekMode.ONHEAP)); } }
/** * @throws Exception In case of error. */ @Test public void testPeek() throws Exception { Ignite ignite = primaryIgnite("key"); IgniteCache<String, Integer> cache = ignite.cache(cacheName()); assertNull(cache.localPeek("key")); cache.put("key", 1); cache.replace("key", 2); assertEquals(2, cache.localPeek("key").intValue()); }
/** {@inheritDoc} */ @Override public void run(int idx) throws Exception { assertEquals(0, ((IgniteKernal)ignite).<String, Integer>internalCache(DEFAULT_CACHE_NAME).context().tm().idMapSize()); IgniteCache<Object, Object> cache = ignite.cache(DEFAULT_CACHE_NAME); ClusterNode node = ((IgniteKernal)ignite).localNode(); for (int k = 0; k < size; k++) { if (affinity(cache).isPrimaryOrBackup(node, k)) assertEquals("Check failed for node: " + node.id(), k, cache.localPeek(k, CachePeekMode.ONHEAP, CachePeekMode.OFFHEAP)); } } }
/** * @throws Exception If failed. */ @Test public void testPeekRemove() throws Exception { IgniteCache<String, Integer> cache = primaryCache("key"); cache.put("key", 1); cache.remove("key"); assertNull(cache.localPeek("key")); }
/** * @throws Exception If failed. */ @Test public void testCasRemove() throws Exception { jcache().put("casKey", "casVal"); assertEquals("casVal", jcache().localPeek("casKey")); String ret = content(DEFAULT_CACHE_NAME, GridRestCommand.CACHE_CAS, "key", "casKey"); info("CAS Remove command result: " + ret); assertNull(jcache().localPeek("casKey")); assertCacheOperation(ret, true); }
/** * @throws Exception If failed. */ @Test public void testRemove() throws Exception { jcache().put("rmvKey", "rmvVal"); assertEquals("rmvVal", jcache().localPeek("rmvKey")); String ret = content(DEFAULT_CACHE_NAME, GridRestCommand.CACHE_REMOVE, "key", "rmvKey"); info("Remove command result: " + ret); assertNull(jcache().localPeek("rmvKey")); assertCacheOperation(ret, true); }
/** */ private void checkPeekDoesNotSeeAbortedVersions() throws Exception { Integer pk = primaryKey(cache); cache.put(pk, 1); try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { cache.put(pk, 2); tx.rollback(); } assertEquals(1, cache.localPeek(pk)); }
/** @throws Exception If failed. */ @Test public void testNoTransactionSinglePutx() throws Exception { IgniteCache<Integer, String> near = jcache(0); near.put(2, "2"); assertEquals("2", near.localPeek(2)); assertEquals("2", near.get(2)); assertEquals("2", localPeek(dht(primaryGrid(2)), 2)); assertEquals(1, near.localSize()); assertEquals(1, near.localSize()); assertEquals(1, dht(primaryGrid(2)).size()); }