@Override public Void call() throws Exception { grid().cache(cacheName); return null; } }, IllegalStateException.class, null);
@Override public Void call() throws Exception { grid(0).<Integer, Integer>cache(DEFAULT_CACHE_NAME).invoke(key, new EntryProcessor<Integer, Integer, Void>() { @Override public Void process(MutableEntry<Integer, Integer> e, Object... args) { e.setValue(2); return null; } }); return null; } }, CacheWriterException.class, null);
@Override public Void call() throws Exception { int idx = cacheIdx.getAndIncrement(); log.info("Use cache " + idx); IgniteCache<Object, Object> cache = grid(idx).cache(DEFAULT_CACHE_NAME); for (int i = 0; i < 100; i++) putAndCheckEntrySet(cache); return null; } }, GRID_CNT, "test");
/** * @return Cache. */ protected IgniteCache getCache(){ return grid(1).cache(DEFAULT_CACHE_NAME); }
@Override public Void call() throws Exception { grid(0).cache(DEFAULT_CACHE_NAME).putAll(m); return null; } }, TransactionHeuristicException.class, null);
/** * @return Cache context. */ protected GridCacheContext cacheContext() { return ((IgniteCacheProxy)grid(0).cache(DEFAULT_CACHE_NAME)).context(); }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { grid(0).cache("cacheA").removeAll(); grid(0).cache("cacheB").removeAll(); grid(0).cache("cacheC").removeAll(); for (CacheStore store : firstStores.values()) ((TestStore)store).clear(); for (CacheStore store : secondStores.values()) ((TestStore)store).clear(); }
@Override public Object call() throws Exception { barrier.await(MAX_AWAIT, TimeUnit.MILLISECONDS); return ((BinaryObject) ignite2.cache(DEFAULT_CACHE_NAME).withKeepBinary().get(1)).field("f1"); } });
/** * @throws Exception If failed. */ @Test public void testGet() throws Exception { grid().cache(DEFAULT_CACHE_NAME).put("key", "val"); Assert.assertEquals("val", client.cacheGet(null, "key")); grid().cache(CACHE_NAME).put("key", "val"); Assert.assertEquals("val", client.cacheGet(CACHE_NAME, "key")); }
/** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { super.beforeTestsStarted(); startGridsMultiThreaded(NODES_COUNT); for (int i = 0; i < MAX_ROWS; ++i) grid(0).cache(DEFAULT_CACHE_NAME).put(i, i); for (int i = 0; i < MAX_ROWS; ++i) grid(0).cache(DEFAULT_CACHE_NAME).put((long)i, (long)i); }
/** * @return DHT cache for this test. */ protected IgniteCache<Object, Object> dhtCache() { for (int i = 0; i < gridCount(); i++) { if (!nearOnlyIgniteInstanceName.equals(grid(i).name())) return grid(i).cache(DEFAULT_CACHE_NAME); } assert false : "Cannot find DHT cache for this test."; return null; }
/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { super.beforeTest(); Cache<Integer, String> cache = grid(0).cache(DEFAULT_CACHE_NAME); for (int i = 0 ; i < ENTRIES_NUM; i++) cache.put(i, "value_" + i); }
/** * Asserts that cache doesn't contains key. * * @param cacheName cache name. */ void assertEmpty(String cacheName) { assertNull(grid(0).cache(cacheName).get(KEY_VAL)); }
/** * @throws Exception If failed. */ @Test public void testMarshaller() throws Exception { grid(0).cache(CACHE_NAME1).put("key1", new UserObject("key1")); stopGrid(0); startGrid(1); //Checking that marshaller works correct after all nodes was stopped. UserObject obj = grid(1).<Object, UserObject>cache(CACHE_NAME1).get("key1"); assert obj.field.equals("key1"); }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override protected void beforeTestsStarted() throws Exception { super.beforeTestsStarted(); int gridCnt = gridCount(); cachesAtomic = new IgniteCache[gridCnt]; for (int i = 0; i < gridCount(); i++) cachesAtomic[i] = grid(i).cache(ATOMIC_CACHE); }
/** * @param i Grid index. * @return Topology. */ private GridDhtPartitionTopology topology(int i) { return near(grid(i).cache(DEFAULT_CACHE_NAME)).dht().topology(); }
/** * @param cache Cache. * @throws Exception If failed. */ private void checkDestroyed(IgniteCache<Object, Object> cache) throws Exception { checkUsageFails(cache); awaitPartitionMapExchange(); String cacheName = cache.getName(); for (int i = 0; i < 3; i++) assertNull("Unexpected cache for node: " + i, grid(i).cache(cacheName)); }
/** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { startGridsMultiThreaded(3); IgniteCache<String, Person> cache = grid(0).cache(DEFAULT_CACHE_NAME); assert cache != null; cache.put("p1", new Person(1, "John", "White", 25)); cache.put("p2", new Person(2, "Joe", "Black", 35)); cache.put("p3", new Person(3, "Mike", "Green", 40)); }
/** * @throws Exception If failed. */ @Test public void testPutAsyncAvgTime() throws Exception { IgniteCache<Object, Object> cache = grid(0).cache(DEFAULT_CACHE_NAME); assertEquals(0.0, cache.localMetrics().getAveragePutTime(), 0.0); assertEquals(0, cache.localMetrics().getCachePuts()); cache.putAsync(1, 1).get(); TimeUnit.MILLISECONDS.sleep(100L); assert cache.localMetrics().getAveragePutTime() > 0; }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { TestIndexingSpi.forceFail(false); Transaction tx = jcache().unwrap(Ignite.class).transactions().tx(); if (tx != null) { tx.close(); fail("Cache transaction remained after test completion: " + tx); } for (int key = 0; key <= lastKey; key++) grid(0).cache(DEFAULT_CACHE_NAME).remove(key); assertEquals(0, jcache(0).size(CachePeekMode.ALL)); }