/** {@inheritDoc} */ @Override public DiscoveryDataClusterState pendingState(ChangeGlobalStateMessage stateMsg) { return DiscoveryDataClusterState.createState(stateMsg.activate() || stateMsg.forceChangeBaselineTopology(), stateMsg.baselineTopology()); }
/** * @return State change message ID. */ public IgniteUuid id() { return msg.id(); }
/** * @param msg State change message. * @return Local future for state change process. */ @Nullable private GridChangeGlobalStateFuture changeStateFuture(ChangeGlobalStateMessage msg) { return changeStateFuture(msg.initiatorNodeId(), msg.requestId()); }
/** * @param msg Message. */ private void processChangeGlobalStateRequest(ChangeGlobalStateMessage msg) { if (msg.activate() && registeredServices.isEmpty()) return; ServiceDeploymentActions depActions = new ServiceDeploymentActions(); if (msg.activate()) depActions.servicesToDeploy(new HashMap<>(registeredServices)); else depActions.deactivate(true); msg.servicesDeploymentActions(depActions); }
ExchangeActions exchangeActions = new ExchangeActions(); if (msg.activate() == curState.active()) return exchangeActions; if (msg.activate()) { for (DynamicCacheDescriptor desc : orderedCaches(CacheComparators.DIRECT)) { desc.startTopologyVersion(topVer); DynamicCacheChangeRequest req = new DynamicCacheChangeRequest(msg.requestId(), desc.cacheName(), msg.initiatorNodeId()); exchangeActions.addCacheGroupToStart(grpDesc); List<StoredCacheData> storedCfgs = msg.storedCacheConfigurations(); IgniteUuid deploymentId = msg.id(); DynamicCacheChangeRequest req = new DynamicCacheChangeRequest(msg.requestId(), ccfg.getName(), msg.initiatorNodeId());
U.log(log, "Received " + prettyStr(msg.activate()) + " request with BaselineTopology" + (msg.baselineTopology() == null ? ": null" : "[id=" + msg.baselineTopology().id() + "]")); if (msg.baselineTopology() != null) compatibilityMode = false; fut.onDone(concurrentStateChangeError(msg.activate())); log.info("Started state transition: " + msg.activate()); transitionFuts.put(msg.requestId(), new GridFutureAdapter<Void>()); msg.activate(), msg.activate() ? msg.baselineTopology() : prevState.baselineTopology(), msg.requestId(), topVer, nodeIds ); if (msg.forceChangeBaselineTopology()) globalState.setTransitionResult(msg.requestId(), msg.activate()); StateChangeRequest req = new StateChangeRequest(msg, bltHistItem, msg.activate() != state.active(), stateChangeTopVer); msg.exchangeActions(exchangeActions);
/** * @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())); }
/** * @return New state. */ public boolean activate() { return msg.activate(); }
/** * @return Baseline topology. */ @Nullable public BaselineTopology baselineTopology() { return msg.baselineTopology(); }
/** * @return State change request ID. */ public UUID requestId() { return msg.requestId(); }
/** * @return Node initiated state change process. */ public UUID initiatorNodeId() { return msg.initiatorNodeId(); }
ChangeGlobalStateMessage msg = new ChangeGlobalStateMessage(startedFut.requestId, ctx.localNodeId(), storedCfgs,
ChangeGlobalStateMessage stateChangeMsg = (ChangeGlobalStateMessage)customMsg; ExchangeActions exchActions = stateChangeMsg.exchangeActions();
depActions = ((ChangeGlobalStateMessage)msg).servicesDeploymentActions(); else if (msg instanceof ServiceChangeBatchRequest) { depActions = ((ServiceChangeBatchRequest)msg)
ExchangeActions exchangeActions = new ExchangeActions(); if (msg.activate() == curState.active()) return exchangeActions; if (msg.activate()) { for (DynamicCacheDescriptor desc : orderedCaches(CacheComparators.DIRECT)) { desc.startTopologyVersion(topVer); DynamicCacheChangeRequest req = new DynamicCacheChangeRequest(msg.requestId(), desc.cacheName(), msg.initiatorNodeId()); exchangeActions.addCacheGroupToStart(grpDesc); List<StoredCacheData> storedCfgs = msg.storedCacheConfigurations(); IgniteUuid deploymentId = msg.id(); DynamicCacheChangeRequest req = new DynamicCacheChangeRequest(msg.requestId(), ccfg.getName(), msg.initiatorNodeId());
U.log(log, "Received " + prettyStr(msg.activate()) + " request with BaselineTopology" + (msg.baselineTopology() == null ? ": null" : "[id=" + msg.baselineTopology().id() + "]")); if (msg.baselineTopology() != null) compatibilityMode = false; fut.onDone(concurrentStateChangeError(msg.activate())); log.info("Started state transition: " + msg.activate()); transitionFuts.put(msg.requestId(), new GridFutureAdapter<Void>()); msg.activate(), msg.activate() ? msg.baselineTopology() : prevState.baselineTopology(), msg.requestId(), topVer, nodeIds ); if (msg.forceChangeBaselineTopology()) globalState.setTransitionResult(msg.requestId(), msg.activate()); StateChangeRequest req = new StateChangeRequest(msg, bltHistItem, msg.activate() != state.active(), stateChangeTopVer); msg.exchangeActions(exchangeActions);
/** * @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())); }
/** * @param msg Discovery custom message. * @return {@code True} if message belongs to event that requires centralized affinity assignment. */ public static boolean requiresCentralizedAffinityAssignment(@Nullable DiscoveryCustomMessage msg) { if (msg == null) return false; if (msg instanceof ChangeGlobalStateMessage && ((ChangeGlobalStateMessage)msg).activate()) return true; if (msg instanceof SnapshotDiscoveryMessage) { SnapshotDiscoveryMessage snapMsg = (SnapshotDiscoveryMessage) msg; return snapMsg.needExchange() && snapMsg.needAssignPartitions(); } return false; } }
/** * @return Baseline topology. */ @Nullable public BaselineTopology baselineTopology() { return msg.baselineTopology(); }
/** * @return State change request ID. */ public UUID requestId() { return msg.requestId(); }