@Override public Object call() throws Exception { ignite.cache(CU.UTILITY_CACHE_NAME); return null; } }, IllegalStateException.class, null);
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { super.afterTest(); for(String cacheName : ignite().cacheNames()) ignite().cache(cacheName).destroy(); }
/** * Get cache for node. * * @param node Node. * @return Cache. */ private static IgniteCache<Long, Person> cache(Ignite node) { return node.cache(CACHE_NAME); }
@Override public void onLifecycleEvent(LifecycleEventType evt) { if (evt == LifecycleEventType.AFTER_NODE_START) { IgniteCache<Integer, byte[]> c = ignite.cache(DEFAULT_CACHE_NAME); if (c.putIfAbsent(-1, new byte[1])) { populate(c, cnt, KBSIZE); info(">>> POPULATED GRID <<<"); } } } };
/** * */ @NotNull private IgniteCache insertSomeData(Ignite ignite) { if (!ignite.active()) ignite.active(true); IgniteCache<String, Person> cache = ignite.cache("cache"); for (int i=0; i<10; i++) cache.put(String.valueOf(System.currentTimeMillis()), new Person("Name " + i, i)); return cache; }
@Override public Void call() throws Exception { Lock lock = ignite1.cache(DEFAULT_CACHE_NAME).lock(key); log.info("Start lock."); lock.lock(); log.info("Locked."); return null; } }, "lock-thread2");
/** * @throws Exception If failed. */ @Test public void testStoreMap() throws Exception { IgniteCache<Object, Object> cache1 = ignite(0).cache(CACHE1); IgniteCache<Object, Object> cache2 = ignite(0).cache(CACHE2); IgniteCache<Object, Object> cache3 = ignite(0).cache(CACHE3); checkStoreMap(cache1); checkStoreMap(cache2); checkStoreMap(cache3); }
@Override public Void call() throws Exception { IgniteCache<Object, Object> cache = node1.cache(DEFAULT_CACHE_NAME); try (Transaction tx = node1.transactions().txStart()) { Integer key = keys.get(idx.getAndIncrement()); cache.getAndPut(key, "new-" + key); tx.commit(); } return null; } }, txCnt, "tx");
/** * @param caches Cache names to put data into. * @param node Ignite node. */ private void putPersons(String[] caches, Ignite node) { for (String cacheName : caches) { IgniteCache<Object, Object> cache = node.cache(cacheName); for (int i = 0; i < entriesCount(); i++) cache.put(i, new Person("" + i, cacheName)); } }
@Override public Void call() throws Exception { Transaction tx = ignite0.transactions().txStart(PESSIMISTIC, REPEATABLE_READ); ignite0.cache(DEFAULT_CACHE_NAME).get(key); return null; } }, "lock-thread1");
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { super.afterTest(); for (Ignite g : G.allGrids()) g.cache(DEFAULT_CACHE_NAME).removeAll(); }
/** {@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)); } } }
/** {@inheritDoc} */ @Override public List<Cache.Entry<Integer, GridCacheQueryTestValue>> call() throws Exception { IgniteCache<Integer, GridCacheQueryTestValue> c = ignite.cache(CACHE_NAME); String sqlStr = "FROM GridCacheQueryTestValue WHERE fieldname = ?"; SqlQuery<Integer, GridCacheQueryTestValue> sql = new SqlQuery<>(GridCacheQueryTestValue.class, sqlStr); sql.setArgs("C"); return c.query(sql.setSql(sqlStr)).getAll(); } }
/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.METRICS); super.beforeTest(); for (int i = 0; i < gridCount(); i++) { Ignite g = grid(i); IgniteCache cache = g.cache(DEFAULT_CACHE_NAME); cache.enableStatistics(true); } }
/** {@inheritDoc} */ @Override public void run(int idx) throws Exception { GridCacheContext<String, Integer> ctx = ((IgniteKernal)ignite).<String, Integer>internalCache(cacheName).context(); int size = 0; for (String key : keys) if (ctx.affinity().keyLocalNode(key, ctx.discovery().topologyVersionEx())) size++; assertEquals("Incorrect key size on cache #" + idx, size, ignite.cache(cacheName).localSize(ALL)); } }
/** {@inheritDoc} */ @Override protected void initCacheAndDbData() throws Exception { Integer k1 = primaryKey(ignite(0).cache(pCache.getName())); Integer k2 = primaryKey(ignite(1).cache(pCache.getName())); Organization org1 = new Organization(k1, "org", "org1"); Organization org2 = new Organization(k2, "org", "org2"); pCache.put(k1, org1); pCache.put(k2, org2); insertInDb(org1); insertInDb(org2); }
@Override public Void call() throws Exception { try (Transaction tx = ignite1.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { log.info("Start tx lock."); ignite1.cache(DEFAULT_CACHE_NAME).get(key); log.info("Tx locked key."); tx.commit(); } return null; } }, "lock-thread2");
/** * */ @Test public void testPrimitives() { IgniteCache<Integer, Integer> p = ignite(0).cache("I2I").withKeepBinary(); p.query(new SqlFieldsQuery("merge into Integer(_key, _val) values (1, ?), " + "(?, 4)").setArgs(2, 3)); assertEquals(2, (int)p.get(1)); assertEquals(4, (int)p.get(3)); } }
/** * */ @Test public void testFieldsCaseSensitivity() { IgniteCache<Key2, Person> p = ignite(0).cache("K22P").withKeepBinary(); p.query(new SqlFieldsQuery("insert into \"Person2\" (\"Id\", \"id\", \"firstName\", \"IntVal\") " + "values (1, ?, ?, 5), (2, 3, 'Alex', 6)").setArgs(4, "Sergi")); assertEquals(createPerson2(4, "Sergi", 5), p.get(new Key2(1))); assertEquals(createPerson2(3, "Alex", 6), p.get(new Key2(2))); }