/** * @param msg State change message. * @param state Current cluster state. * @return {@code True} if states are equivalent. */ protected static boolean isEquivalent(ChangeGlobalStateMessage msg, DiscoveryDataClusterState state) { return (msg.activate() == state.active() && BaselineTopology.equals(msg.baselineTopology(), state.baselineTopology())); }
/** {@inheritDoc} */ @Override public DiscoveryDataClusterState pendingState(ChangeGlobalStateMessage stateMsg) { return DiscoveryDataClusterState.createState(stateMsg.activate() || stateMsg.forceChangeBaselineTopology(), stateMsg.baselineTopology()); }
/** {@inheritDoc} */ @Override public IgniteInternalFuture<?> changeGlobalState( final boolean activate, Collection<? extends BaselineNode> baselineNodes, boolean forceChangeBaselineTopology ) { if (inMemoryMode) return changeGlobalState0(activate, null, false); BaselineTopology newBlt = (compatibilityMode && !forceChangeBaselineTopology) ? null : calculateNewBaselineTopology(activate, baselineNodes, forceChangeBaselineTopology); return changeGlobalState0(activate, newBlt, forceChangeBaselineTopology); }
/** {@inheritDoc} */ @Override public long getRowCount() { BaselineTopology blt = ctx.state().clusterState().baselineTopology(); return blt == null ? 0 : blt.consistentIds().size(); } }
/** */ private void onStateRestored(BaselineTopology blt) { DiscoveryDataClusterState state = globalState; if (!state.active() && !state.transition() && state.baselineTopology() == null) { DiscoveryDataClusterState newState = DiscoveryDataClusterState.createState(false, blt); globalState = newState; } }
/** Returns current baseline topology id of {@code -1} if there's no baseline topology found. */ private int getBaselineTopologyId() { BaselineTopology baselineTop = ctx.state().clusterState().baselineTopology(); return baselineTop != null ? baselineTop.id() : -1; }
/** * * @return {@code True} If baseLine changed, {@code False} if not. */ public boolean baselineChanged() { BaselineTopology prevBLT = previousBaselineTopology(); BaselineTopology curBLT = baselineTopology(); if (prevBLT == null && curBLT != null) return true; if (prevBLT!= null && curBLT != null) return !prevBLT.equals(curBLT); return false; }
/** */ boolean isCompatibleWith(BaselineTopology blt) { BaselineTopologyHistoryItem histBlt = hist.get(blt.id()); return histBlt.branchingHistory().contains(blt.branchingPointHash()); }
/** {@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); }
/** * @return {@code True} if cluster was in active state. */ boolean clusterActive() { return state.active() && !state.transition(); } }
/** * @param msg State change message. * @return Local future for state change process. */ @Nullable private GridChangeGlobalStateFuture changeStateFuture(ChangeGlobalStateMessage msg) { return changeStateFuture(msg.initiatorNodeId(), msg.requestId()); }
/** * @return Latest version string. */ public String latestVersion() { return verChecker != null ? verChecker.latestVersion() : null; }
/** */ BaselineTopologyHistory tailFrom(int id) { BaselineTopologyHistory tail = new BaselineTopologyHistory(); for (BaselineTopologyHistoryItem item : hist) { if (item.id() >= id) tail.hist.add(item); } return tail; }
/** * @param res Response. */ public void onResponse(IgniteDiagnosticInfo res) { onDone(res); }
/** * @return State change message ID. */ public IgniteUuid id() { return msg.id(); }
/** * @return New state. */ public boolean activate() { return msg.activate(); }
/** * @param blt1 Baseline topology instance. * @param blt2 Baseline topology instance. * @return {@code True} if equals. */ public static boolean equals(BaselineTopology blt1, BaselineTopology blt2) { if (blt1 == null && blt2 == null) return true; if (blt1 == null ^ blt2 == null) return false; return blt1.equals(blt2); }
/** * @return State change request ID. */ public UUID requestId() { return msg.requestId(); }
/** * @return Node initiated state change process. */ public UUID initiatorNodeId() { return msg.initiatorNodeId(); }
/** * @param msg State change message. * @param state Current cluster state. * @return {@code True} if state change from message can be applied to the current state. */ protected boolean isApplicable(ChangeGlobalStateMessage msg, DiscoveryDataClusterState state) { return !isEquivalent(msg, state); }