/** Get {@link CollectionConfiguration} with number of backups equal to {@link AtomicConfiguration} default */ private CollectionConfiguration getCollectionConfiguration() { return new CollectionConfiguration().setBackups(AtomicConfiguration.DFLT_BACKUPS); } }
/** * @param cacheAtomicityMode Atomicity mode. * @return Configuration. */ private static CollectionConfiguration collectionConfiguration(CacheAtomicityMode cacheAtomicityMode) { CollectionConfiguration colCfg = new CollectionConfiguration(); colCfg.setAtomicityMode(cacheAtomicityMode); return colCfg; }
/** * @throws Exception If failed. */ @Test public void testCanCloseSetInInterruptedThread() throws Exception { doCloseByInterruptedThread(grid(0).set(STRUCTURE_NAME, new CollectionConfiguration())); }
/** * @throws Exception If failed. */ @Test public void testCanCloseQueueInInterruptedThread() throws Exception { doCloseByInterruptedThread(grid(0).queue(STRUCTURE_NAME, 0, new CollectionConfiguration())); }
@Override public void apply(Ignite ignite) { for (int i = 0; i < 100; i++) { CollectionConfiguration colCfg = new CollectionConfiguration(); colCfg.setBackups(1); colCfg.setCacheMode(PARTITIONED); colCfg.setAtomicityMode(i % 2 == 0 ? TRANSACTIONAL : ATOMIC); IgniteQueue q = ignite.queue("q-" + i, 0, colCfg); q.close(); } } });
@Override public void apply(Ignite ignite) { for (int i = 0; i < 100; i++) { CollectionConfiguration colCfg = new CollectionConfiguration(); colCfg.setCollocated(collocated); colCfg.setBackups(1); colCfg.setCacheMode(PARTITIONED); colCfg.setAtomicityMode(i % 2 == 0 ? TRANSACTIONAL : ATOMIC); IgniteSet set = ignite.set("set-" + i, colCfg); set.close(); } } });
/** * @return Collection configuration. */ protected CollectionConfiguration collectionConfiguration() { CollectionConfiguration colCfg = new CollectionConfiguration(); colCfg.setCacheMode(collectionCacheMode()); colCfg.setAtomicityMode(collectionCacheAtomicityMode()); colCfg.setOffHeapMaxMemory(collectionOffHeapMaxMemory()); if (colCfg.getCacheMode() == PARTITIONED) colCfg.setBackups(1); return colCfg; }
/** * @throws Exception If failed. */ @Test public void testQueue() throws Exception { Ignite ignite = startGrids(4); ignite.active(true); IgniteQueue<Object> queue = ignite.queue("testQueue", 100, new CollectionConfiguration()); for (int i = 0; i < 100; i++) queue.offer(i); stopAllGrids(); ignite = startGrids(4); ignite.active(true); queue = ignite.queue("testQueue", 0, null); for (int i = 0; i < 100; i++) assertEquals(i, queue.poll()); }
/** * @param creator Creator node. * @param other Other node. * @throws Exception If failed. */ private void testQueue(Ignite creator, final Ignite other) throws Exception { assertNull(creator.queue("q1", 0, null)); assertNull(other.queue("q1", 0, null)); try (IgniteQueue<Integer> queue = creator.queue("q1", 0, new CollectionConfiguration())) { assertNotNull(queue); queue.add(1); assertEquals(1, queue.poll().intValue()); IgniteInternalFuture<?> fut = GridTestUtils.runAsync(new Callable<Object>() { @Override public Object call() throws Exception { U.sleep(1000); IgniteQueue<Integer> queue0 = other.queue("q1", 0, null); assertEquals(0, queue0.size()); log.info("Add in queue."); queue0.add(2); return null; } }); log.info("Try take."); assertEquals(2, queue.take().intValue()); log.info("Finished take."); fut.get(); } assertNull(creator.queue("q1", 0, null)); assertNull(other.queue("q1", 0, null)); }
/** * @throws Exception If failed. */ @Test public void testSet() throws Exception { Ignite ignite = startGrids(4); ignite.active(true); IgniteSet<Object> set = ignite.set("testSet", new CollectionConfiguration()); for (int i = 0; i < 100; i++) set.add(i); assertEquals(100, set.size()); stopAllGrids(); ignite = startGrids(4); ignite.active(true); set = ignite.set("testSet", null); assertFalse(set.add(99)); for (int i = 0; i < 100; i++) assertTrue(set.contains(i)); assertEquals(100, set.size()); }
/** * @param creator Creator node. * @param other Other node. * @throws Exception If failed. */ private void testSet(Ignite creator, Ignite other) throws Exception { assertNull(creator.set("set1", null)); assertNull(other.set("set1", null)); CollectionConfiguration colCfg = new CollectionConfiguration(); try (IgniteSet<Integer> set = creator.set("set1", colCfg)) { assertNotNull(set); assertEquals(0, set.size()); assertFalse(set.contains(1)); assertTrue(set.add(1)); assertTrue(set.contains(1)); IgniteSet<Integer> set0 = other.set("set1", null); assertTrue(set0.contains(1)); assertEquals(1, set0.size()); assertTrue(set0.remove(1)); assertFalse(set.contains(1)); } assertNull(creator.set("set1", null)); assertNull(other.set("set1", null)); }
public void initializeCache() throws Exception { CacheConfiguration<String, Integer> cacheCfg = new CacheConfiguration<>(); cacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); cacheCfg.setName(CHANNELS); cacheCfg.setBackups(2); channelCache = ignite.getOrCreateCache(cacheCfg); logger.info("Channel cache:"+channelCache); colCfg = new CollectionConfiguration(); colCfg.setCollocated(true); colCfg.setBackups(1); channelSize = Integer.parseInt(System.getProperty(CHANNEL_CAPACITY, DEFAULT_CHANNEL_CAPACITY)); logger.info("Starting alert receiver"); }
public void initIgniteCache() { cacheCfg = new CacheConfiguration<>(); cacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); cacheCfg.setName(MCM_METRICS); cacheCfg.setBackups(2); seriesLookup = ignite.getOrCreateCache(cacheCfg); colCfg = new CollectionConfiguration(); colCfg.setCollocated(true); colCfg.setBackups(1); colCfg.setCacheMode(CacheMode.REPLICATED); seriesSize = Integer.parseInt(System.getProperty(SERIES_CAPACITY, DEFAULT_SERIES_CAPACITY)); cfg = new CollectionConfiguration(); cfg.setBackups(1); cfg.setCacheMode(CacheMode.REPLICATED); logger.info("Initialized Ignite cache for performance monitoring"); }
collectionCfg = new CollectionConfiguration(); collectionCfg.setAtomicityMode(cacheCfg.getAtomicityMode()); collectionCfg.setBackups(cacheCfg.getBackups()); collectionCfg = new CollectionConfiguration();
collectionCfg = new CollectionConfiguration(); collectionCfg.setAtomicityMode(cacheCfg.getAtomicityMode()); collectionCfg.setBackups(cacheCfg.getBackups()); collectionCfg = new CollectionConfiguration();