/** * Set new baseline. * * @param baselineTop Collection of baseline node. * @return Baseline descriptor. */ private VisorBaselineTaskResult set0(Collection<BaselineNode> baselineTop) { ignite.cluster().setBaselineTopology(baselineTop); return collect(); }
/** * Set baseline by topology version. * * @param targetVer Target topology version. * @return New baseline. */ private VisorBaselineTaskResult version(long targetVer) { IgniteClusterEx cluster = ignite.cluster(); if (targetVer > cluster.topologyVersion()) throw new IllegalArgumentException("Topology version is ahead of time: " + targetVer); cluster.setBaselineTopology(targetVer); return collect(); }
/** {@inheritDoc} */ @Override public long processInLongOutLong(int type, long val) throws IgniteCheckedException { switch (type) { case OP_LOGGER_IS_LEVEL_ENABLED: { return loggerIsLevelEnabled((int) val) ? TRUE : FALSE; } case OP_RELEASE_START: { releaseStart(); return 0; } case OP_SET_BASELINE_TOPOLOGY_VER: { ctx.grid().cluster().setBaselineTopology(val); return 0; } } return PlatformAbstractTarget.throwUnsupported(type); }
@SuppressWarnings({"BusyWait"}) @Override public Object call() throws Exception { while (!done.get()) { if (lastOpChangeUp) { //need to do change down: stop node, set new BLT without it stopGrid(gridCount()); lastOpChangeUp = false; } else { startGrid(gridCount()); lastOpChangeUp = true; } grid(0).cluster().setBaselineTopology(baselineNodes(grid(0).cluster().forServers().nodes())); Thread.sleep(baselineTopChangeInterval); int c = restartCnt.incrementAndGet(); if (c % logFreq == 0) info("BaselineTopology changes: " + c); } return true; } }, 1, "restart-thread");
cluster.setBaselineTopology(topVer); else cluster.setBaselineTopology(filterServerNodesByConsId(consistentIds)); cluster.setBaselineTopology(baselineTop); cluster.setBaselineTopology(baselineTop);
/** * @throws Exception If failed. */ @Params(timeout = 5000L, atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) @Test public void testUpdateBaselineTopologyTransactionalReplicated() throws Exception { doTest( asMessagePredicate(discoEvt -> { if (discoEvt instanceof DiscoveryCustomEvent) { DiscoveryCustomEvent discoCustomEvt = (DiscoveryCustomEvent)discoEvt; DiscoveryCustomMessage customMsg = discoCustomEvt.customMessage(); return customMsg instanceof ChangeGlobalStateMessage; } return false; }), () -> { startNodesInClientMode(false); IgniteEx ignite = startGrid(UUID.randomUUID().toString()); baseline.get(0).cluster().setBaselineTopology(baseline.get(0).context().discovery().topologyVersion()); baseline.add(ignite); } ); }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { super.afterTest(); grid(0).cluster().setBaselineTopology(grid(0).cluster().topologyVersion()); }
/** * */ @Test public void testAddNodeToBaselineTopology() throws Exception { final long expectedActivationHash = (long)"A".hashCode() + "B".hashCode() + "C".hashCode() + "D".hashCode(); BaselineTopologyVerifier verifier = new BaselineTopologyVerifier() { @Override public void verify(BaselineTopology blt) { assertNotNull(blt); assertEquals(4, blt.consistentIds().size()); long activationHash = U.field(blt, "branchingPntHash"); assertEquals(expectedActivationHash, activationHash); } }; Ignite nodeA = startGridWithConsistentId("A"); Ignite nodeB = startGridWithConsistentId("B"); Ignite nodeC = startGridWithConsistentId("C"); nodeC.cluster().active(true); IgniteEx nodeD = (IgniteEx) startGridWithConsistentId("D"); nodeD.cluster().setBaselineTopology(baselineNodes(nodeA.cluster().forServers().nodes())); verifyBaselineTopologyOnNodes(verifier, new Ignite[]{nodeA, nodeB, nodeC, nodeD}); }
ctx.grid().cluster().setBaselineTopology(nodes);
/** * @throws Exception if failed. */ @Test public void testRebalancingWithTtlExpirable() throws Exception { IgniteEx srv = startGrid(0); srv.cluster().active(true); fillCache(srv.cache(CACHE_NAME)); srv = startGrid(1); //causes rebalancing start srv.cluster().setBaselineTopology(srv.cluster().topologyVersion()); final IgniteCache<Integer, byte[]> cache = srv.cache(CACHE_NAME); pringStatistics((IgniteCacheProxy)cache, "After rebalancing start"); waitAndCheckExpired(cache); stopAllGrids(); }
/** * Test ignite kernal node in baseline test. * * @throws Exception Thrown if test fails. */ @Test public void testIgniteKernalNodeInBaselineTest() throws Exception { try { IgniteEx ignite0 = (IgniteEx)startGrids(NODES); startGrid(CLIENT_IDX); ignite0.cluster().active(true); checkBaselineInFromMBean(ignite0); startGrid(NODES); checkBaselineInFromMBean(ignite0); ignite0.cluster().setBaselineTopology(ignite0.cluster().topologyVersion()); checkBaselineInFromMBean(ignite0); } finally { stopAllGrids(); } }
/** * @throws Exception If failed. */ @Test public void testDataClearedAfterRestartWithDisabledWal() throws Exception { Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-10421", MvccFeatureChecker.forcedMvcc()); Ignite ignite = startGrid(0); ignite.cluster().active(true); IgniteCache<Integer, Integer> cache = ignite.cache(DEFAULT_CACHE_NAME); int keysCnt = getKeysCount(); for (int k = 0; k < keysCnt; k++) cache.put(k, k); IgniteEx newIgnite = startGrid(1); newIgnite.cluster().setBaselineTopology(2); // Await fully exchange complete. awaitExchange(newIgnite); CacheGroupContext grpCtx = newIgnite.cachex(DEFAULT_CACHE_NAME).context().group(); assertFalse(grpCtx.localWalEnabled()); stopGrid(1); stopGrid(0); newIgnite = startGrid(1); newIgnite.cluster().active(true); newIgnite.cluster().setBaselineTopology(newIgnite.cluster().nodes()); cache = newIgnite.cache(DEFAULT_CACHE_NAME); for (int k = 0; k < keysCnt; k++) assertFalse("k=" + k +", v=" + cache.get(k), cache.containsKey(k)); }
/** * @throws Exception if failed. */ @Test public void testClusterActiveWhileBaselineChanging() throws Exception { startGrids(NODE_COUNT); IgniteEx ig = grid(0); ig.cluster().active(true); assertTrue(ig.cluster().active()); startGrid(NODE_COUNT); IgniteInternalFuture fut = GridTestUtils.runAsync(() -> { try { U.sleep(100); } catch (IgniteInterruptedCheckedException e) { e.printStackTrace(); } ig.cluster().setBaselineTopology(NODE_COUNT + 1); }); while (!fut.isDone()) { assertTrue(grid(0).cluster().active()); assertTrue(grid(0).context().state().publicApiActiveState(false)); assertTrue(grid(NODE_COUNT).cluster().active()); assertTrue(grid(NODE_COUNT).context().state().publicApiActiveState(false)); } assertNull(String.valueOf(fut.error()), fut.error()); assertEquals(NODE_COUNT + 1, ig.cluster().currentBaselineTopology().size()); }
/** * @throws Exception If failed. */ @Test public void testLocalAndGlobalWalStateInterdependence() throws Exception { Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-10421", MvccFeatureChecker.forcedMvcc()); Ignite ignite = startGrids(3); ignite.cluster().active(true); IgniteCache<Integer, Integer> cache = ignite.cache(DEFAULT_CACHE_NAME); for (int k = 0; k < getKeysCount(); k++) cache.put(k, k); IgniteEx newIgnite = startGrid(3); newIgnite.cluster().setBaselineTopology(ignite.cluster().nodes()); awaitExchange(newIgnite); CacheGroupContext grpCtx = newIgnite.cachex(DEFAULT_CACHE_NAME).context().group(); assertFalse(grpCtx.walEnabled()); ignite.cluster().disableWal(DEFAULT_CACHE_NAME); for (Ignite g : G.allGrids()) g.cache(DEFAULT_CACHE_NAME).rebalance(); awaitPartitionMapExchange(); assertFalse(grpCtx.walEnabled()); // WAL is globally disabled ignite.cluster().enableWal(DEFAULT_CACHE_NAME); assertTrue(grpCtx.walEnabled()); }
/** * Set new baseline. * * @param baselineTop Collection of baseline node. * @return Baseline descriptor. */ private VisorBaselineTaskResult set0(Collection<BaselineNode> baselineTop) { ignite.cluster().setBaselineTopology(baselineTop); return collect(); }
/** * Set baseline by topology version. * * @param targetVer Target topology version. * @return New baseline. */ private VisorBaselineTaskResult version(long targetVer) { IgniteClusterEx cluster = ignite.cluster(); if (targetVer > cluster.topologyVersion()) throw new IllegalArgumentException("Topology version is ahead of time: " + targetVer); cluster.setBaselineTopology(targetVer); return collect(); }
/** {@inheritDoc} */ @Override public long processInLongOutLong(int type, long val) throws IgniteCheckedException { switch (type) { case OP_LOGGER_IS_LEVEL_ENABLED: { return loggerIsLevelEnabled((int) val) ? TRUE : FALSE; } case OP_RELEASE_START: { releaseStart(); return 0; } case OP_SET_BASELINE_TOPOLOGY_VER: { ctx.grid().cluster().setBaselineTopology(val); return 0; } } return PlatformAbstractTarget.throwUnsupported(type); }
ctx.grid().cluster().setBaselineTopology(nodes);