@Override public void applyx(IgniteCache cache) { for (int i = 0; i < cnt; i++) cache.put("key" + i, i); } });
@Override public Object call() throws Exception { Thread.currentThread().setName("put-thread"); if (putAll) cache.putAll(map); else cache.put(0, 0); return null; } });
@Nullable @Override public Object call() throws Exception { cache.put("key1", null); return null; } }, NullPointerException.class, A.NULL_MSG_PREFIX);
/** * @param c Cache. * @param cnt Key count. */ private void putKeys(IgniteCache<Integer, String> c, int cnt) { for (int i = 0; i < cnt; i++) c.put(i, Integer.toString(i)); }
@Override public void apply(Ignite ignite, IgniteCache<Integer, Integer> cache) { ThreadLocalRandom rnd = ThreadLocalRandom.current(); Integer key = rnd.nextInt(MULTITHREADED_TEST_KEYS); cache.put(key, rnd.nextInt()); } });
@Override public void applyx() { while (true) { int i = cnt.getAndIncrement(); if (i >= PUT_CNT) break; jcache().put("key" + i, i); set.add(i); if (i > 10) guard.compareAndSet(false, true); } } }, WRITE_THREAD_CNT, WRITE_THREAD_NAME);
/** * @param c Cache. * @param cnt Key count. */ @SuppressWarnings("TypeMayBeWeakened") private void populate(IgniteCache<Integer, String> c, int cnt) { for (int i = 0; i < cnt; i++) c.put(i, value(1024)); }
@Override public Object call() throws Exception { Thread.currentThread().setName("put-thread"); try (Transaction tx = ignite2.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { for (Map.Entry<Integer, Integer> e : map.entrySet()) cache.put(e.getKey(), e.getValue()); tx.commit(); } return null; } });
@Override public Object call() throws Exception { Thread.currentThread().setName("put-thread"); try (Transaction tx = ignite3.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { for (Map.Entry<Integer, Integer> e : map.entrySet()) cache.put(e.getKey(), e.getValue()); tx.commit(); } return null; } });
/** * @param cache Ignite cache. * @param arr Array to check. */ private void checkArrayClass(IgniteCache<Integer, Object> cache, Object arr) { cache.put(0, arr); Object res = cache.get(0); assertEquals(arr.getClass(), res.getClass()); GridTestUtils.deepEquals(arr, res); }
/** * Executes simple operation on the cache. * * @param cache Cache instance to use. */ private void performSimpleOperationsOnCache(IgniteCache<Integer, Integer> cache) { for (int i = 100; i < 200; i++) cache.put(i, i); for (int i = 100; i < 200; i++) assertEquals(i, (int) cache.get(i)); } }
/** * @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)); } }
/** * @param client Client. * @param cacheName Cache name. */ private void checkFineCache(Ignite client, String cacheName) { IgniteCache<Integer, String> cache = client.getOrCreateCache(cacheName); cache.put(1, "1"); assertEquals("1", cache.get(1)); }
/** */ private void createAndFillCache(Ignite srv) { IgniteCache cache = srv.getOrCreateCache(cacheConfiguration()); for (int i = 0; i < ENTRIES_COUNT; i++) cache.put(i, new TestValue(i, "str" + i)); }
/** */ 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)); }); }
@Override public Void call() throws Exception { IgniteTransactions txs = transactions(); try (Transaction tx = txs.txStart()) { cache.put(key, 2); cache.remove(null); tx.commit(); } return null; } }, NullPointerException.class, null);
/** * Create cache at server node and put some values into the cache. */ private void createAndFillServerCache() { srvNode.createCache(cacheConfiguration()); for (int i = 0; i < CACHE_ELEMENT_COUNT; i++) srvNode.cache(PERSON_CACHE).put(i, new Person(i, "name-" + i)); }
/** * @throws Exception In case of error. */ @Test public void testRemove() throws Exception { IgniteCache<String, Integer> cache = jcache(); cache.put("key1", 1); assert cache.remove("key1"); assert cache.get("key1") == null; assert !cache.remove("key1"); }
/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { CacheConfiguration<Integer, Person> ccfg = new CacheConfiguration<>(CACHE_NAME); ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT); ccfg.setIndexedTypes(Integer.class, Person.class); node.createCache(ccfg); for (int i = 0; i < 100; i++) cache().put(i, new Person("Name" + i, "LastName" + i)); }
/** * @throws IgniteCheckedException If failed. */ @Test public void testRemove() throws IgniteCheckedException { jcache().put("key", 1); assert jcache().remove("key", 1); assert !jcache().remove("key", 1); } }