/** * Check cluster state. */ private void checkActivate() { if (!ctx.state().publicApiActiveState(true)) { throw new IgniteException("Can not perform the operation because the cluster is inactive. Note, that " + "the cluster is considered inactive by default if Ignite Persistent Store is used to let all the nodes " + "join the cluster. To activate the cluster call Ignite.active(true)."); } }
/** * */ public void onDisconnected() { cachesOnDisconnect = new CachesOnDisconnect( ctx.state().clusterState(), new HashMap<>(registeredCacheGrps), new HashMap<>(registeredCaches)); registeredCacheGrps.clear(); registeredCaches.clear(); registeredTemplates.clear(); clientReconnectReqs = null; }
return (T)new GridClusterStateProcessor(ctx);
/** {@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); }
/** * Log exchange event. * * @param evt Discovery event. */ private void logExchange(DiscoveryEvent evt) { if (cctx.kernalContext().state().publicApiActiveState(false) && cctx.wal() != null) { if (cctx.wal().serializerVersion() > 1) try { ExchangeRecord.Type type = null; if (evt.type() == EVT_NODE_JOINED) type = ExchangeRecord.Type.JOIN; else if (evt.type() == EVT_NODE_LEFT || evt.type() == EVT_NODE_FAILED) type = ExchangeRecord.Type.LEFT; BaselineTopology blt = cctx.kernalContext().state().clusterState().baselineTopology(); if (type != null && blt != null) { Short constId = blt.consistentIdMapping().get(evt.eventNode().consistentId()); if (constId != null) cctx.wal().log(new ExchangeRecord(constId, type)); } } catch (IgniteCheckedException e) { U.error(log, "Fail during log exchange record.", e); } } }
stateFinishMsg = ctx.state().onNodeLeft(node); incMinorTopVer = ctx.state().onStateChangeMessage( new AffinityTopologyVersion(topVer, minorTopVer), (ChangeGlobalStateMessage)customMsg, ctx.state().onStateFinishMessage((ChangeGlobalStateFinishMessage)customMsg); DiscoCache discoCache = snapshot.discoCache.copy(snapshot.topVer, ctx.state().clusterState()); ctx.cache().onDiscoveryEvent(type, customMsg, node, nextTopVer, ctx.state().clusterState()); ctx.cache().onDiscoveryEvent(type, customMsg, node, nextTopVer, ctx.state().clusterState()); discoCache = createDiscoCache( nextTopVer, ctx.state().clusterState(), locNode, topSnapshot); discoCache = createDiscoCache( nextTopVer, ctx.state().pendingState((ChangeGlobalStateMessage)customMsg), locNode, topSnapshot); IgniteInternalFuture<Boolean> transitionWaitFut = ctx.state().onLocalJoin(discoCache); ctx.state().clusterState().active()));
DiscoveryDataClusterState state = kctx.state().clusterState(); kctx.state().onBaselineTopologyChanged(req.baselineTopology(), req.prevBaselineTopologyHistoryItem());
/** {@inheritDoc} */ @Override public void onStateFinishMessage(ChangeGlobalStateFinishMessage msg) { DiscoveryDataClusterState state = globalState; if (msg.requestId().equals(state.transitionRequestId())) { log.info("Received state change finish message: " + msg.clusterActive()); globalState = state.finish(msg.success()); afterStateChangeFinished(msg.id(), msg.success()); ctx.cache().onStateChangeFinish(msg); TransitionOnJoinWaitFuture joinFut = this.joinFut; if (joinFut != null) joinFut.onDone(false); GridFutureAdapter<Void> transitionFut = transitionFuts.remove(state.transitionRequestId()); if (transitionFut != null) { state.setTransitionResult(msg.requestId(), msg.clusterActive()); transitionFut.onDone(); } } else U.warn(log, "Received state finish message with unexpected ID: " + msg); }
/** {@inheritDoc} */ @SuppressWarnings({"unchecked"}) @Override public void start() throws IgniteCheckedException { ctx.internalSubscriptionProcessor().registerMetastorageListener(recovery); ctx.internalSubscriptionProcessor().registerDatabaseListener(recovery); cachesInfo = new ClusterCachesInfo(ctx); DeploymentMode depMode = ctx.config().getDeploymentMode(); if (!F.isEmpty(ctx.config().getCacheConfiguration())) { if (depMode != CONTINUOUS && depMode != SHARED) U.warn(log, "Deployment mode for cache is not CONTINUOUS or SHARED " + "(it is recommended that you change deployment mode and restart): " + depMode); } initializeInternalCacheNames(); Collection<CacheStoreSessionListener> sessionListeners = CU.startStoreSessionListeners(ctx, ctx.config().getCacheStoreSessionListenerFactories()); sharedCtx = createSharedContext(ctx, sessionListeners); transactions = new IgniteTransactionsImpl(sharedCtx, null); // Start shared managers. for (GridCacheSharedManager mgr : sharedCtx.managers()) mgr.start(sharedCtx); if (!ctx.isDaemon() && (!CU.isPersistenceEnabled(ctx.config())) || ctx.config().isClientMode()) restoreCacheConfigurations(); if (log.isDebugEnabled()) log.debug("Started cache processor."); ctx.state().cacheProcessorStarted(); ctx.authentication().cacheProcessorStarted(); }
else if (activate) { if (baselineNodes == null) baselineNodes = baselineNodes();
DiscoveryDataClusterState clusterState = crd.context().state().clusterState(); Assert.assertFalse(crd.context().state().publicApiActiveState(true));
stateFinishMsg = ctx.state().onNodeLeft(node); incMinorTopVer = ctx.state().onStateChangeMessage( new AffinityTopologyVersion(topVer, minorTopVer), (ChangeGlobalStateMessage)customMsg, ctx.state().onStateFinishMessage((ChangeGlobalStateFinishMessage)customMsg); DiscoCache discoCache = snapshot.discoCache.copy(snapshot.topVer, ctx.state().clusterState()); ctx.cache().onDiscoveryEvent(type, customMsg, node, nextTopVer, ctx.state().clusterState()); ctx.cache().onDiscoveryEvent(type, customMsg, node, nextTopVer, ctx.state().clusterState()); discoCache = createDiscoCache( nextTopVer, ctx.state().clusterState(), locNode, topSnapshot); discoCache = createDiscoCache( nextTopVer, ctx.state().pendingState((ChangeGlobalStateMessage)customMsg), locNode, topSnapshot); IgniteInternalFuture<Boolean> transitionWaitFut = ctx.state().onLocalJoin(discoCache); ctx.state().clusterState().active()));
DiscoveryDataClusterState state = cctx.kernalContext().state().clusterState(); cctx.kernalContext().state().onBaselineTopologyChanged(req.baselineTopology(), req.prevBaselineTopologyHistoryItem());
/** {@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 void onStateFinishMessage(ChangeGlobalStateFinishMessage msg) { DiscoveryDataClusterState state = globalState; if (msg.requestId().equals(state.transitionRequestId())) { log.info("Received state change finish message: " + msg.clusterActive()); globalState = globalState.finish(msg.success()); afterStateChangeFinished(msg.id(), msg.success()); ctx.cache().onStateChangeFinish(msg); TransitionOnJoinWaitFuture joinFut = this.joinFut; if (joinFut != null) joinFut.onDone(false); GridFutureAdapter<Void> transitionFut = transitionFuts.remove(state.transitionRequestId()); if (transitionFut != null) { state.setTransitionResult(msg.requestId(), msg.clusterActive()); transitionFut.onDone(); } } else U.warn(log, "Received state finish message with unexpected ID: " + msg); }
/** {@inheritDoc} */ @SuppressWarnings({"unchecked"}) @Override public void start() throws IgniteCheckedException { ctx.internalSubscriptionProcessor().registerMetastorageListener(this); cachesInfo = new ClusterCachesInfo(ctx); DeploymentMode depMode = ctx.config().getDeploymentMode(); if (!F.isEmpty(ctx.config().getCacheConfiguration())) { if (depMode != CONTINUOUS && depMode != SHARED) U.warn(log, "Deployment mode for cache is not CONTINUOUS or SHARED " + "(it is recommended that you change deployment mode and restart): " + depMode); } initializeInternalCacheNames(); Collection<CacheStoreSessionListener> sessionListeners = CU.startStoreSessionListeners(ctx, ctx.config().getCacheStoreSessionListenerFactories()); sharedCtx = createSharedContext(ctx, sessionListeners); transactions = new IgniteTransactionsImpl(sharedCtx, null); // Start shared managers. for (GridCacheSharedManager mgr : sharedCtx.managers()) mgr.start(sharedCtx); if (!ctx.isDaemon() && (!CU.isPersistenceEnabled(ctx.config())) || ctx.config().isClientMode()) startCachesOnStart(); if (log.isDebugEnabled()) log.debug("Started cache processor."); ctx.state().cacheProcessorStarted(); ctx.authentication().cacheProcessorStarted(); }
else if (activate) { if (baselineNodes == null) baselineNodes = baselineNodes();
/** * @param ctx Context. * * @return instance of current baseline topology if it exists */ public static BaselineTopology getBaselineTopology(@NotNull GridKernalContext ctx) { return ctx.state().clusterState().baselineTopology(); }
/** * Validate operation on cluster. Check current cluster state. * * @throws IgniteException if cluster in inActive state */ private void checkClusterState() throws IgniteException { if (!ctx.state().publicApiActiveState(true)) { throw new IgniteException("Can not perform the operation because the cluster is inactive. Note, that " + "the cluster is considered inactive by default if Ignite Persistent Store is used to let all the nodes " + "join the cluster. To activate the cluster call Ignite.active(true)."); } }
/** * Log exchange event. * * @param evt Discovery event. */ private void logExchange(DiscoveryEvent evt) { if (cctx.kernalContext().state().publicApiActiveState(false) && cctx.wal() != null) { if (cctx.wal().serializerVersion() > 1) try { ExchangeRecord.Type type = null; if (evt.type() == EVT_NODE_JOINED) type = ExchangeRecord.Type.JOIN; else if (evt.type() == EVT_NODE_LEFT || evt.type() == EVT_NODE_FAILED) type = ExchangeRecord.Type.LEFT; BaselineTopology blt = cctx.kernalContext().state().clusterState().baselineTopology(); if (type != null && blt != null) { Short constId = blt.consistentIdMapping().get(evt.eventNode().consistentId()); if (constId != null) cctx.wal().log(new ExchangeRecord(constId, type)); } } catch (IgniteCheckedException e) { U.error(log, "Fail during log exchange record.", e); } } }