Java Code Examples for org.apache.ignite.internal.IgniteEx#active()
The following examples show how to use
org.apache.ignite.internal.IgniteEx#active() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IgnitePdsCacheIntegrationTest.java From ignite with Apache License 2.0 | 6 votes |
/** * @throws Exception if failed. */ @Test public void testPutMultithreaded() throws Exception { startGrids(4); try { final IgniteEx grid = grid(0); grid.active(true); GridTestUtils.runMultiThreaded(new Callable<Object>() { @Override public Object call() throws Exception { for (int i = 0; i < 1000; i++) grid.cache(CACHE_NAME).put(i, i); return null; } }, 8, "updater"); } finally { stopAllGrids(); } }
Example 2
Source File: IgnitePdsExchangeDuringCheckpointTest.java From ignite with Apache License 2.0 | 6 votes |
/** * */ @Test public void testExchangeOnNodeLeft() throws Exception { for (int i = 0; i < SF.applyLB(5, 2); i++) { startGrids(3); IgniteEx ignite = grid(1); ignite.active(true); awaitPartitionMapExchange(); stopGrid(0, true); awaitPartitionMapExchange(); ignite.context().cache().context().database().wakeupForCheckpoint("test").get(10000); afterTest(); } }
Example 3
Source File: IgnitePdsCacheDestroyDuringCheckpointTest.java From ignite with Apache License 2.0 | 6 votes |
/** * @throws Exception If fail. */ @Test public void testCacheCreatePutCheckpointDestroy() throws Exception { IgniteEx ig = startGrid(0); ig.active(true); for (int j = 0; j < NUM_ITERATIONS; j++) { Ignite client = startClientGrid(1); for (int i = 0; i < NUM_CACHES; i++) { IgniteCache<?, ?> cache = ig.cache(NAME_PREFIX + i); if (cache != null) cache.destroy(); } populateCache(client); checkCacheSizes(client); client.close(); } }
Example 4
Source File: IgniteStandByClusterTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @throws Exception if fail. */ @Test public void testActivateDeActivateCallbackForPluginProviders() throws Exception { IgniteEx ig1 = startGrid(getConfiguration("node1")); IgniteEx ig2 = startGrid(getConfiguration("node2")); IgniteEx ig3 = startGrid(getConfiguration("node3")); assertTrue(!ig1.active()); assertTrue(!ig2.active()); assertTrue(!ig3.active()); ig1.active(true); checkPlugin(ig1, 1, 0); checkPlugin(ig2, 1, 0); checkPlugin(ig3, 1, 0); ig2.active(false); ig3.active(true); checkPlugin(ig1, 2, 1); checkPlugin(ig2, 2, 1); checkPlugin(ig3, 2, 1); ig1.active(false); ig2.active(true); checkPlugin(ig1, 3, 2); checkPlugin(ig2, 3, 2); checkPlugin(ig3, 3, 2); }
Example 5
Source File: IgniteStandByClusterTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @throws Exception if fail. */ @Test public void testCheckStatusFromDaemon() throws Exception { IgniteEx ig = startGrid(0); assertFalse(ig.active()); ig.active(true); IgniteEx daemon = startClientGrid( getConfiguration("daemon") .setDaemon(true) ); assertTrue(ig.active()); assertTrue(daemon.active()); daemon.active(false); assertFalse(ig.active()); assertFalse(daemon.active()); daemon.active(true); assertTrue(ig.active()); assertTrue(daemon.active()); }
Example 6
Source File: IgniteNativeIoWithNoPersistenceTest.java From ignite with Apache License 2.0 | 5 votes |
/** * Checks simple launch with native IO. * @throws Exception if failed */ @Test public void testDirectIoHandlesNoPersistentGrid() throws Exception { IgniteEx ignite = startGrid(0); ignite.active(true); IgniteCache<Object, Object> cache = ignite.getOrCreateCache("cache"); for (int i = 0; i < 100; i++) cache.put(i, valueForKey(i)); stopAllGrids(); }
Example 7
Source File: IgnitePdsPageReplacementTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @throws Exception If fail. */ @Test public void testPageReplacement() throws Exception { final IgniteEx ig = startGrid(0); ig.active(true); final PageMemory memory = getMemory(ig); writeData(ig, memory, CU.cacheId(cacheName)); }
Example 8
Source File: IgniteDbPutGetWithCacheStoreTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @param atomicityMode Atomicity mode. * @throws Exception if failed. */ private void checkReadThrough(CacheAtomicityMode atomicityMode) throws Exception { this.atomicityMode = atomicityMode; IgniteEx ig = startGrid(0); try { ig.active(true); for (int i = 0; i < 2000; i++) storeMap.put(i, i); for (int i = 0; i < 2000; i++) assertEquals(i, ig.cache(CACHE_NAME).get(i)); stopAllGrids(false); storeMap.clear(); ig = startGrid(0); ig.active(true); for (int i = 0; i < 2000; i++) assertEquals(i, ig.cache(CACHE_NAME).get(i)); } finally { stopAllGrids(); } }
Example 9
Source File: IgniteMassLoadSandboxTest.java From ignite with Apache License 2.0 | 4 votes |
/** * Runs multithreaded put scenario (no data streamer). Load is generated to page store and to WAL. * * @throws Exception if failed. */ @Test public void testDataStreamerContinuousPutMultithreaded() throws Exception { try { // System.setProperty(IgniteSystemProperties.IGNITE_DIRTY_PAGES_PARALLEL, "true"); // System.setProperty(IgniteSystemProperties.IGNITE_DIRTY_PAGES_SORTED_STORAGE, "true"); System.setProperty(IgniteSystemProperties.IGNITE_USE_ASYNC_FILE_IO_FACTORY, "false"); System.setProperty(IgniteSystemProperties.IGNITE_OVERRIDE_WRITE_THROTTLING_ENABLED, "speed"); System.setProperty(IgniteSystemProperties.IGNITE_DELAYED_REPLACED_PAGE_WRITE, "true"); setWalArchAndWorkToSameVal = true; customWalMode = WALMode.BACKGROUND; final IgniteEx ignite = startGrid(1); ignite.active(true); final int threads = 1; Runtime.getRuntime().availableProcessors(); final int recsPerThread = CONTINUOUS_PUT_RECS_CNT / threads; final ProgressWatchdog watchdog = new ProgressWatchdog(ignite, "put", PUT_THREAD); IgniteDataStreamer<Object, Object> streamer = ignite.dataStreamer(CACHE_NAME); streamer.perNodeBufferSize(12); final Collection<Callable<?>> tasks = new ArrayList<>(); for (int j = 0; j < threads; j++) { final int finalJ = j; tasks.add((Callable<Void>)() -> { for (int i = finalJ * recsPerThread; i < ((finalJ + 1) * recsPerThread); i++) streamer.addData(i, new HugeIndexedObject(i)); return null; }); } final IgniteCache<Object, HugeIndexedObject> cache = ignite.cache(CACHE_NAME); ScheduledExecutorService svcReport = Executors.newScheduledThreadPool(1); AtomicInteger size = new AtomicInteger(); svcReport.scheduleAtFixedRate( () -> { int newSize = cache.size(); int oldSize = size.getAndSet(newSize); watchdog.reportProgress(newSize - oldSize); }, 250, 250, TimeUnit.MILLISECONDS); watchdog.start(); GridTestUtils.runMultiThreaded(tasks, PUT_THREAD); streamer.close(); watchdog.stopping(); stopGrid(1); watchdog.stop(); ProgressWatchdog.stopPool(svcReport); if (VERIFY_STORAGE) runVerification(threads, recsPerThread); } finally { stopAllGrids(); } }
Example 10
Source File: IgniteWalRecoverySeveralRestartsTest.java From ignite with Apache License 2.0 | 4 votes |
/** * @throws Exception if failed. */ @Test public void testWalRecoveryWithDynamicCache() throws Exception { try { IgniteEx ignite = startGrid(1); ignite.active(true); CacheConfiguration<Integer, IndexedObject> dynCacheCfg = new CacheConfiguration<>(); dynCacheCfg.setName("dyncache"); dynCacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); dynCacheCfg.setRebalanceMode(CacheRebalanceMode.NONE); dynCacheCfg.setIndexedTypes(Integer.class, IndexedObject.class); dynCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); dynCacheCfg.setAffinity(new RendezvousAffinityFunction(false, 64 * 4)); // 64 per node dynCacheCfg.setReadFromBackup(true); ignite.getOrCreateCache(dynCacheCfg); try (IgniteDataStreamer<Integer, IndexedObject> dataLdr = ignite.dataStreamer("dyncache")) { for (int i = 0; i < KEYS_COUNT; ++i) { if (i % (KEYS_COUNT / 100) == 0) info("Loading " + i * 100 / KEYS_COUNT + "%"); dataLdr.addData(i, new IndexedObject(i)); } } for (int restartCnt = 0; restartCnt < 5; ++restartCnt) { stopGrid(1, true); info("Restart #" + restartCnt); U.sleep(500); ignite = startGrid(1); ignite.active(true); ThreadLocalRandom locRandom = ThreadLocalRandom.current(); IgniteCache<Integer, IndexedObject> cache = ignite.getOrCreateCache(dynCacheCfg); for (int i = 0; i < KEYS_COUNT; ++i) assertNotNull(cache.get(locRandom.nextInt(KEYS_COUNT))); } } finally { stopAllGrids(); } }
Example 11
Source File: IgniteMassLoadSandboxTest.java From ignite with Apache License 2.0 | 4 votes |
/** * Runs multithreaded put scenario (no data streamer). Load is generated to page store and to WAL. * * @throws Exception if failed. */ @Test public void testContinuousPutMultithreaded() throws Exception { try { // System.setProperty(IgniteSystemProperties.IGNITE_DIRTY_PAGES_PARALLEL, "true"); // System.setProperty(IgniteSystemProperties.IGNITE_DIRTY_PAGES_SORTED_STORAGE, "true"); System.setProperty(IgniteSystemProperties.IGNITE_USE_ASYNC_FILE_IO_FACTORY, "false"); System.setProperty(IgniteSystemProperties.IGNITE_OVERRIDE_WRITE_THROTTLING_ENABLED, "speed"); setWalArchAndWorkToSameVal = true; customWalMode = WALMode.BACKGROUND; final IgniteEx ignite = startGrid(1); ignite.active(true); final IgniteCache<Object, HugeIndexedObject> cache = ignite.cache(CACHE_NAME); final int threads = Runtime.getRuntime().availableProcessors(); final int recsPerThread = CONTINUOUS_PUT_RECS_CNT / threads; final Collection<Callable<?>> tasks = new ArrayList<>(); final ProgressWatchdog watchdog = new ProgressWatchdog(ignite, "put", PUT_THREAD); for (int j = 0; j < threads; j++) { final int finalJ = j; tasks.add(new Callable<Void>() { @Override public Void call() throws Exception { for (int i = finalJ * recsPerThread; i < ((finalJ + 1) * recsPerThread); i++) { HugeIndexedObject v = new HugeIndexedObject(i); cache.put(i, v); watchdog.reportProgress(1); } return null; } }); } watchdog.start(); GridTestUtils.runMultiThreaded(tasks, PUT_THREAD); watchdog.stopping(); stopGrid(1); watchdog.stop(); if (VERIFY_STORAGE) runVerification(threads, recsPerThread); } finally { stopAllGrids(); } }
Example 12
Source File: IgniteStandByClusterTest.java From ignite with Apache License 2.0 | 4 votes |
/** * @throws Exception if fail. */ @Test public void testSimple() throws Exception { IgniteEx ig = startGrid(0); ig.active(true); IgniteCache<Integer, String> cache0 = ig.getOrCreateCache("cache"); cache0.put(1, "1"); assertEquals("1", cache0.get(1)); ig.active(false); assertTrue(!ig.active()); ig.active(true); IgniteCache<Integer, String> cache = ig.cache("cache"); assertEquals("1", cache.get(1)); }
Example 13
Source File: IgniteStandByClusterTest.java From ignite with Apache License 2.0 | 4 votes |
/** * @throws Exception if fail. */ @Test public void testStaticCacheStartAfterActivationWithCacheFilter() throws Exception { String cache1 = "cache1"; String cache2 = "cache2"; String cache3 = "cache3"; IgniteConfiguration cfg1 = getConfiguration("node1"); cfg1.setCacheConfiguration( new CacheConfiguration(cache1).setNodeFilter(new NodeFilterIgnoreByName("node2"))); IgniteConfiguration cfg2 = getConfiguration("node2"); cfg2.setCacheConfiguration( new CacheConfiguration(cache2).setNodeFilter(new NodeFilterIgnoreByName("node3"))); IgniteConfiguration cfg3 = getConfiguration("node3"); cfg3.setCacheConfiguration( new CacheConfiguration(cache3).setNodeFilter(new NodeFilterIgnoreByName("node1"))); IgniteEx ig1 = startGrid(cfg1); IgniteEx ig2 = startGrid(cfg2); IgniteEx ig3 = startGrid(cfg3); assertTrue(!ig1.active()); assertTrue(!ig2.active()); assertTrue(!ig3.active()); ig3.active(true); assertTrue(ig1.active()); assertTrue(ig2.active()); assertTrue(ig3.active()); for (IgniteEx ig : Arrays.asList(ig1, ig2, ig3)) { Map<String, DynamicCacheDescriptor> desc = U.field( (Object)U.field(ig.context().cache(), "cachesInfo"), "registeredCaches"); assertEquals(4, desc.size()); Map<String, GridCacheAdapter<?, ?>> caches = U.field(ig.context().cache(), "caches"); assertEquals(3, caches.keySet().size()); } Map<String, GridCacheAdapter<?, ?>> caches1 = U.field(ig1.context().cache(), "caches"); Assert.assertNotNull(caches1.get(cache1)); Assert.assertNotNull(caches1.get(cache2)); Assert.assertNull(caches1.get(cache3)); Map<String, GridCacheAdapter<?, ?>> caches2 = U.field(ig2.context().cache(), "caches"); Assert.assertNull(caches2.get(cache1)); Assert.assertNotNull(caches2.get(cache2)); Assert.assertNotNull(caches2.get(cache3)); Map<String, GridCacheAdapter<?, ?>> caches3 = U.field(ig3.context().cache(), "caches"); Assert.assertNotNull(caches3.get(cache1)); Assert.assertNull(caches3.get(cache2)); Assert.assertNotNull(caches3.get(cache3)); }
Example 14
Source File: IgniteStandByClusterTest.java From ignite with Apache License 2.0 | 4 votes |
/** * @throws Exception if fail. */ @Test public void testStartDynamicCachesAfterActivation() throws Exception { final String cacheName0 = "cache0"; final String cacheName = "cache"; IgniteConfiguration cfg1 = getConfiguration("serv1"); IgniteConfiguration cfg2 = getConfiguration("serv2"); IgniteConfiguration cfg3 = getConfiguration("client"); cfg3.setCacheConfiguration(new CacheConfiguration(cacheName0)); IgniteEx ig1 = startGrid(cfg1); IgniteEx ig2 = startGrid(cfg2); IgniteEx ig3 = startClientGrid(cfg3); assertTrue(!ig1.active()); assertTrue(!ig2.active()); assertTrue(!ig3.active()); ig3.active(true); assertTrue(ig1.active()); assertTrue(ig2.active()); assertTrue(ig3.active()); ig3.createCache(new CacheConfiguration<>(cacheName)); assertNotNull(ig3.cache(cacheName)); assertNotNull(ig1.cache(cacheName)); assertNotNull(ig2.cache(cacheName)); assertNotNull(ig1.cache(cacheName0)); assertNotNull(ig3.cache(cacheName0)); assertNotNull(ig2.cache(cacheName0)); ig3.active(false); assertTrue(!ig1.active()); assertTrue(!ig2.active()); assertTrue(!ig3.active()); ig3.active(true); assertTrue(ig1.active()); assertTrue(ig2.active()); assertTrue(ig3.active()); assertNotNull(ig1.cache(cacheName)); assertNotNull(ig2.cache(cacheName)); Map<String, GridCacheAdapter<?, ?>> caches = U.field(ig3.context().cache(), "caches"); // Only system cache and cache0 assertEquals("Unexpected caches: " + caches.keySet(), 3, caches.size()); assertTrue(caches.containsKey(CU.UTILITY_CACHE_NAME)); assertTrue(caches.containsKey(cacheName0)); assertTrue(caches.containsKey(cacheName)); assertNotNull(ig3.cache(cacheName)); }
Example 15
Source File: IgnitePdsCheckpointSimpleTest.java From ignite with Apache License 2.0 | 4 votes |
/** * Checks if same data can be loaded after checkpoint. * @throws Exception if failed. */ @Test public void testRecoveryAfterCpEnd() throws Exception { IgniteEx ignite = startGrid(0); ignite.active(true); IgniteCache<Object, Object> cache = ignite.getOrCreateCache("cache"); for (int i = 0; i < 10000; i++) cache.put(i, valueWithRedundancyForKey(i)); ignite.context().cache().context().database().waitForCheckpoint("test"); stopAllGrids(); IgniteEx igniteRestart = startGrid(0); igniteRestart.active(true); IgniteCache<Object, Object> cacheRestart = igniteRestart.getOrCreateCache("cache"); for (int i = 0; i < 10000; i++) assertEquals(valueWithRedundancyForKey(i), cacheRestart.get(i)); stopAllGrids(); }
Example 16
Source File: BinaryMetadataMoveLegacyFolderTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override protected IgniteEx startGrid(IgniteConfiguration cfg) throws Exception { IgniteEx grid = super.startGrid(cfg); grid.active(true); return grid; }
Example 17
Source File: IgniteCheckpointDirtyPagesForLowLoadTest.java From ignite with Apache License 2.0 | 4 votes |
/** * @throws Exception if failed. */ @Test public void testManyCachesAndNotManyPuts() throws Exception { try { IgniteEx ignite = startGrid(0); ignite.active(true); log.info("Saving initial data to caches"); for (int g = 0; g < GROUPS; g++) { for (int c = 0; c < CACHES_IN_GRP; c++) { ignite.cache("dummyCache" + c + "." + g) .putAll(new TreeMap<Long, Long>() {{ for (int j = 0; j < PARTS; j++) { // to fill each partition cache with at least 1 element put((long)j, (long)j); } }}); } } GridCacheDatabaseSharedManager db = (GridCacheDatabaseSharedManager)(ignite.context().cache().context().database()); Collection<Integer> pageCntObserved = new ArrayList<>(); boolean checkpointWithLowNumOfPagesFound = false; for (int i = 0; i < 20; i++) { Random random = new Random(); //touch some entry int d = random.nextInt(PARTS) + PARTS; int cIdx = random.nextInt(CACHES_IN_GRP); int gIdx = random.nextInt(GROUPS); String fullname = "dummyCache" + cIdx + "." + gIdx; ignite.cache(fullname).put(d, d); if (log.isInfoEnabled()) log.info("Put to cache [" + fullname + "] value " + d); long start = System.nanoTime(); try { final int cpTimeout = 25000; db.wakeupForCheckpoint("").get(cpTimeout, TimeUnit.MILLISECONDS); } catch (IgniteFutureTimeoutCheckedException ignored) { long msPassed = U.millisSinceNanos(start); log.error("Timeout during waiting for checkpoint to start:" + " [" + msPassed + "] but checkpoint is not running"); continue; } final int timeout = 5000; int currCpPages = waitForCurrentCheckpointPagesCounterUpdated(db, timeout); if (currCpPages < 0) { log.error("Timeout during waiting for checkpoint counter to be updated"); continue; } pageCntObserved.add(currCpPages); log.info("Current CP pages: " + currCpPages); if (currCpPages < PARTS * GROUPS) { checkpointWithLowNumOfPagesFound = true; //reasonable number of pages in CP break; } } stopGrid(0); assertTrue("All checkpoints mark too much pages: " + pageCntObserved, checkpointWithLowNumOfPagesFound); } finally { stopAllGrids(); } }
Example 18
Source File: FoldersReuseCompatibilityTest.java From ignite with Apache License 2.0 | 4 votes |
/** * Test startup of current ignite version using DB storage folder from previous version of Ignite. Expected to start * successfully with existing DB * * @param ver 3 digit Ignite version to check compatibility with * @throws Exception if failed. */ private void runFoldersReuse(String ver) throws Exception { final IgniteEx oldVer = startGrid(1, ver, new ConfigurationClosure(), new PostStartupClosure()); stopAllGrids(); IgniteEx ignite = startGrid(0); ignite.active(true); ignite.getOrCreateCache("cache2createdForNewGrid").put("Object", "Value"); assertEquals(1, ignite.context().discovery().topologyVersion()); assertPdsDirsDefaultExist(U.maskForFileName(ignite.cluster().node().consistentId().toString())); assertEquals(VAL, ignite.cache(CACHE_NAME).get(KEY)); final PersistenceBasicCompatibilityTest.TestStringContainerToBePrinted actual = (PersistenceBasicCompatibilityTest.TestStringContainerToBePrinted)ignite.cache(CACHE_NAME).get(KEY_OBJ); assertEquals(VAL, actual.data); assertNodeIndexesInFolder();// should not create any new style directories stopAllGrids(); }
Example 19
Source File: IgnitePKIndexesMigrationToUnwrapPkTest.java From ignite with Apache License 2.0 | 3 votes |
/** * Tests opportunity to read data from previous Ignite DB version. * * @param ver 3-digits version of ignite * @throws Exception If failed. */ @SuppressWarnings("unchecked") private void doTestStartupWithOldVersion(String ver) throws Exception { try { startGrid(1, ver, new ConfigurationClosure(), new PostStartupClosure(true)); stopAllGrids(); IgniteEx igniteEx = startGrid(0); new PostStartupClosure(false).apply(igniteEx); igniteEx.active(true); assertDontUsingPkIndex(igniteEx, TABLE_NAME); String newTblName = TABLE_NAME + "_NEW"; initializeTable(igniteEx, newTblName); checkUsingIndexes(igniteEx, newTblName); igniteEx.active(false); } finally { stopAllGrids(); } }
Example 20
Source File: GridIndexRebuildSelfTest.java From ignite with Apache License 2.0 | 2 votes |
/** * Start server node. * * @return Started node. * @throws Exception if failed. */ protected IgniteEx startServer() throws Exception { IgniteEx srvNode = startGrid(serverConfiguration(0)); srvNode.active(true); return srvNode; }