/** {@inheritDoc} */ @Override public void onGridDataReceived(DiscoveryDataBag.GridDiscoveryData data) { if (data.commonData() instanceof DiscoveryDataClusterState) { if (globalState != null && globalState.baselineTopology() != null) //node with BaselineTopology is not allowed to join mixed cluster // (where some nodes don't support BaselineTopology) throw new IgniteException("Node with BaselineTopology cannot join" + " mixed cluster running in compatibility mode"); globalState = (DiscoveryDataClusterState) data.commonData(); compatibilityMode = true; return; } BaselineStateAndHistoryData stateDiscoData = (BaselineStateAndHistoryData)data.commonData(); if (stateDiscoData != null) { DiscoveryDataClusterState state = stateDiscoData.globalState; if (state.transition()) transitionFuts.put(state.transitionRequestId(), new GridFutureAdapter<Void>()); globalState = state; if (stateDiscoData.recentHistory != null) { for (BaselineTopologyHistoryItem item : stateDiscoData.recentHistory.history()) bltHist.bufferHistoryItemForStore(item); } } }
/** */ BaselineTopologyHistory tailFrom(int id) { BaselineTopologyHistory tail = new BaselineTopologyHistory(); for (BaselineTopologyHistoryItem item : hist) { if (item.id() >= id) tail.hist.add(item); } return tail; }
/** {@inheritDoc} */ @Override public void onReadyForReadWrite(ReadWriteMetastorage metastorage) throws IgniteCheckedException { this.metastorage = metastorage; if (compatibilityMode) { if (log.isInfoEnabled()) log.info("BaselineTopology won't be stored as this node is running in compatibility mode"); return; } writeBaselineTopology(globalState.baselineTopology(), null); bltHist.flushHistoryItems(metastorage); }
@Override public void verify(BaselineTopologyHistory bltHist) { assertNotNull(bltHist); assertEquals(1, bltHist.history().size()); BaselineTopologyHistoryItem histItem = bltHist.history().get(0); assertEquals(1, histItem.branchingHistory().size()); long actualBranchingHash = histItem.branchingHistory().get(0); assertEquals(expectedBranchingHash, actualBranchingHash); } };
/** * @param blt Blt. */ private void writeBaselineTopology(BaselineTopology blt, BaselineTopologyHistoryItem prevBltHistItem) throws IgniteCheckedException { assert metastorage != null; if (inMemoryMode) return; sharedCtx.database().checkpointReadLock(); try { if (blt != null) { if (log.isInfoEnabled()) { U.log(log, "Writing BaselineTopology[id=" + blt.id() + "]"); if (prevBltHistItem != null) U.log(log, "Writing BaselineTopologyHistoryItem[id=" + prevBltHistItem.id() + "]"); } bltHist.writeHistoryItem(metastorage, prevBltHistItem); metastorage.write(METASTORE_CURR_BLT_KEY, blt); } else { if (log.isInfoEnabled()) U.log(log, "Removing BaselineTopology and history"); metastorage.remove(METASTORE_CURR_BLT_KEY); bltHist.removeHistory(metastorage); } } finally { sharedCtx.database().checkpointReadUnlock(); } }
/** {@inheritDoc} */ @Override public void onReadyForRead(ReadOnlyMetastorage metastorage) throws IgniteCheckedException { BaselineTopology blt = (BaselineTopology) metastorage.read(METASTORE_CURR_BLT_KEY); if (blt != null) { if (log.isInfoEnabled()) U.log(log, "Restoring history for BaselineTopology[id=" + blt.id() + "]"); bltHist.restoreHistory(metastorage, blt.id()); } onStateRestored(blt); }
if (!bltHist.isCompatibleWith(joiningNodeBlt)) { String msg = "BaselineTopology of joining node (" + node.consistentId()
@Override public void verify(BaselineTopologyHistory bltHist) { assertNotNull(bltHist); assertEquals(2, bltHist.history().size()); BaselineTopologyHistoryItem histItem = bltHist.history().get(0); assertEquals(1, histItem.branchingHistory().size()); long actualBranchingHash0 = histItem.branchingHistory().get(0); assertEquals(expectedBranchingHash0, actualBranchingHash0); histItem = bltHist.history().get(1); assertEquals(1, histItem.branchingHistory().size()); long actualBranchingHash1 = histItem.branchingHistory().get(0); assertEquals(expectedBranchingHash1, actualBranchingHash1); } };
/** * @param blt Blt. */ private void writeBaselineTopology(BaselineTopology blt, BaselineTopologyHistoryItem prevBltHistItem) throws IgniteCheckedException { assert metastorage != null; if (inMemoryMode) return; sharedCtx.database().checkpointReadLock(); try { if (blt != null) { if (log.isInfoEnabled()) { U.log(log, "Writing BaselineTopology[id=" + blt.id() + "]"); if (prevBltHistItem != null) U.log(log, "Writing BaselineTopologyHistoryItem[id=" + prevBltHistItem.id() + "]"); } bltHist.writeHistoryItem(metastorage, prevBltHistItem); metastorage.write(METASTORE_CURR_BLT_KEY, blt); } else { if (log.isInfoEnabled()) U.log(log, "Removing BaselineTopology and history"); metastorage.remove(METASTORE_CURR_BLT_KEY); bltHist.removeHistory(metastorage); } } finally { sharedCtx.database().checkpointReadUnlock(); } }
/** {@inheritDoc} */ @Override public void onReadyForRead(ReadOnlyMetastorage metastorage) throws IgniteCheckedException { BaselineTopology blt = (BaselineTopology) metastorage.read(METASTORE_CURR_BLT_KEY); if (blt != null) { if (log.isInfoEnabled()) U.log(log, "Restoring history for BaselineTopology[id=" + blt.id() + "]"); bltHist.restoreHistory(metastorage, blt.id()); } onStateRestored(blt); }
if (!bltHist.isCompatibleWith(joiningNodeBlt)) { String msg = "BaselineTopology of joining node (" + node.consistentId()
/** {@inheritDoc} */ @Override public void onGridDataReceived(DiscoveryDataBag.GridDiscoveryData data) { if (data.commonData() instanceof DiscoveryDataClusterState) { if (globalState != null && globalState.baselineTopology() != null) //node with BaselineTopology is not allowed to join mixed cluster // (where some nodes don't support BaselineTopology) throw new IgniteException("Node with BaselineTopology cannot join" + " mixed cluster running in compatibility mode"); globalState = (DiscoveryDataClusterState) data.commonData(); compatibilityMode = true; return; } BaselineStateAndHistoryData stateDiscoData = (BaselineStateAndHistoryData)data.commonData(); if (stateDiscoData != null) { DiscoveryDataClusterState state = stateDiscoData.globalState; if (state.transition()) transitionFuts.put(state.transitionRequestId(), new GridFutureAdapter<Void>()); globalState = state; if (stateDiscoData.recentHistory != null) { for (BaselineTopologyHistoryItem item : stateDiscoData.recentHistory.history()) bltHist.bufferHistoryItemForStore(item); } } }
/** * @param ig Ignite. * @param expBltId Expected BaselineTopology ID. * @param expBltHistSize Expected Baseline history size. * @param expBranchingHistSize Expected branching history size. * @param expActivationHash Expected activation hash. */ private void checkBaselineTopologyOnNode( Ignite ig, int expBltId, int expBltHistSize, int expBranchingHistSize, long expActivationHash) { BaselineTopology blt = getBaselineTopology(ig); BaselineTopologyHistory bltHist = getBaselineTopologyHistory(ig); assertNotNull(bltHist); assertEquals(expBltId, blt.id()); assertEquals(expBltHistSize, bltHist.history().size()); BaselineTopologyHistoryItem histItem = bltHist.history().get(0); assertEquals(expBranchingHistSize, histItem.branchingHistory().size()); assertEquals(expActivationHash, (long)histItem.branchingHistory().get(0)); }
/** {@inheritDoc} */ @Override public void onReadyForReadWrite(ReadWriteMetastorage metastorage) throws IgniteCheckedException { this.metastorage = metastorage; if (compatibilityMode) { if (log.isInfoEnabled()) log.info("BaselineTopology won't be stored as this node is running in compatibility mode"); return; } writeBaselineTopology(globalState.baselineTopology(), null); bltHist.flushHistoryItems(metastorage); }
/** */ BaselineTopologyHistory tailFrom(int id) { BaselineTopologyHistory tail = new BaselineTopologyHistory(); for (BaselineTopologyHistoryItem item : hist) { if (item.id() >= id) tail.hist.add(item); } return tail; }
/** * Verifies that neither BaselineTopology nor BaselineTopologyHistory are changed when cluster is deactivated. */ @Test public void testBaselineTopologyRemainsTheSameOnClusterDeactivation() throws Exception { startGrids(2); IgniteEx srv = grid(0); srv.cluster().active(true); awaitPartitionMapExchange(); assertTrue(srv.cluster().active()); srv.cluster().active(false); BaselineTopology blt = getBaselineTopology(srv); BaselineTopologyHistory bltHist = getBaselineTopologyHistory(srv); assertEquals(0, blt.id()); assertEquals(2, blt.consistentIds().size()); assertEquals(1, blt.branchingHistory().size()); assertEquals(0, bltHist.history().size()); }