final GridCacheInternalKey key = new GridCacheInternalKeyImpl(name, grpName);
((IgniteKernal)grid(0)).getCache(cacheName).getAndPut(new GridCacheInternalKeyImpl("LONG", ""), new GridCacheAtomicLongValue(0)); ((IgniteKernal)grid(0)).getCache(intCache.getName()).remove(new GridCacheInternalKeyImpl("LONG", ""));
/** * @throws Exception If failed. */ @Test public void testCacheSets() throws Exception { // Make new atomic sequence in cache. IgniteAtomicSequence seq = grid().atomicSequence(UUID.randomUUID().toString(), 0, true); seq.incrementAndGet(); final String cacheName = DataStructuresProcessor.ATOMICS_CACHE_NAME + "@default-ds-group"; GridCacheAdapter cache = ((IgniteKernal)grid()).internalCache(cacheName); assertNotNull(cache); GridTestUtils.assertThrows(log, new Callable<Void>() { @Override public Void call() throws Exception { grid().cache(cacheName); return null; } }, IllegalStateException.class, null); for (String seqName : seqNames) assert null != cache.get(new GridCacheInternalKeyImpl(seqName, "default-ds-group")); }
corruptDataEntry(storedSysCacheCtx.caches().get(0), new GridCacheInternalKeyImpl("sq0", "default-ds-group"), true, false); corruptDataEntry(storedSysCacheCtx.caches().get(0), new GridCacheInternalKeyImpl("sq" + parts / 2, "default-ds-group"), false, true); corruptDataEntry(memorySysCacheCtx.caches().get(0), new GridCacheInternalKeyImpl("s0", "default-volatile-ds-group"), true, false); corruptDataEntry(memorySysCacheCtx.caches().get(0), new GridCacheInternalKeyImpl("s" + parts / 2, "default-volatile-ds-group"), false, true);
final GridCacheInternalKey key = new GridCacheInternalKeyImpl(name, grpName);
/** * @throws Exception If failed. */ @Test public void testInternalKey() throws Exception { if (atomicityMode() == ATOMIC) return; IgniteCache<Object, Object> cache = grid(0).cache(DEFAULT_CACHE_NAME); ContinuousQuery<Object, Object> qry = new ContinuousQuery<>(); final Map<Object, Object> map = new ConcurrentHashMap<>(); final CountDownLatch latch = new CountDownLatch(2); qry.setLocalListener(new CacheEntryUpdatedListener<Object, Object>() { @Override public void onUpdated(Iterable<CacheEntryEvent<?, ?>> evts) { for (CacheEntryEvent<?, ?> e : evts) { map.put(e.getKey(), e.getValue()); latch.countDown(); } } }); try (QueryCursor<Cache.Entry<Object, Object>> ignored = cache.query(qry)) { cache.put(new GridCacheInternalKeyImpl("test", "test"), 1); cachePut(cache, 1, 1); cachePut(cache, 2, 2); assert latch.await(LATCH_TIMEOUT, MILLISECONDS); assertEquals(2, map.size()); assertEquals(1, (int)map.get(1)); assertEquals(2, (int)map.get(2)); } }
oldVal = metaCache.getAndPutIfAbsent(new GridCacheInternalKeyImpl(name, grpName), newVal); oldVal = metaCache.get(new GridCacheInternalKeyImpl(name, grpName));
/** * Prepare test environment. * @param key Key. * @throws Exception If failed. */ private void prepareCustom(String key) throws Exception { // Start nodes. for (int i = 0; i < INIT_GRID_NUM; i++) assert startGrid(i) != null; for (int i = 0; i < INIT_GRID_NUM; i++) assert PARTITIONED == grid(i).cache(DEFAULT_CACHE_NAME).getConfiguration(CacheConfiguration.class).getCacheMode(); // Init cache data. try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { // Put custom data grid(0).cache(DEFAULT_CACHE_NAME).put(new GridCacheInternalKeyImpl(key, "testGroup"), new GridCacheAtomicLongValue(INIT_GRID_NUM)); tx.commit(); } stopGrid(0); }
/** * Test {@link GridCacheInternalKey}/{@link GridCacheAtomicLongValue}. * @param name Name. * @throws Exception If failed. */ private void checkCustom(String name) throws Exception { for (int i = INIT_GRID_NUM; i < 20; i++) { startGrid(i); assert PARTITIONED == grid(i).cache(DEFAULT_CACHE_NAME).getConfiguration(CacheConfiguration.class).getCacheMode(); try (Transaction tx = grid(i).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { GridCacheInternalKey key = new GridCacheInternalKeyImpl(name, "testGroup"); GridCacheAtomicLongValue atomicVal = ((GridCacheAtomicLongValue) grid(i).cache(DEFAULT_CACHE_NAME).get(key)); assertNotNull(atomicVal); assertEquals("Custom check failed for node: " + i, (long) i, atomicVal.get()); atomicVal.set(i + 1); grid(i).cache(DEFAULT_CACHE_NAME).put(key, atomicVal); tx.commit(); } stopGrid(i); } }
final GridCacheInternalKey key = new GridCacheInternalKeyImpl(name, grpName);
final GridCacheInternalKey key = new GridCacheInternalKeyImpl(name, grpName);
oldVal = metaCache.getAndPutIfAbsent(new GridCacheInternalKeyImpl(name, grpName), newVal); oldVal = metaCache.get(new GridCacheInternalKeyImpl(name, grpName));