use of org.apache.ignite.internal.processors.cluster.IgniteChangeGlobalStateSupport in project ignite by apache.
the class DataStructuresProcessor method onActivate.
/** {@inheritDoc} */
@Override
public void onActivate(GridKernalContext ctx) throws IgniteCheckedException {
if (log.isDebugEnabled())
log.debug("Activate data structure processor [nodeId=" + ctx.localNodeId() + " topVer=" + ctx.discovery().topologyVersionEx() + " ]");
this.initFailed = false;
this.initLatch = new CountDownLatch(1);
this.qryId = null;
ctx.event().addLocalEventListener(lsnr, EVT_NODE_LEFT, EVT_NODE_FAILED);
onKernalStart0(true);
for (Map.Entry<GridCacheInternal, GridCacheRemovable> e : dsMap.entrySet()) {
GridCacheRemovable v = e.getValue();
if (v instanceof IgniteChangeGlobalStateSupport)
((IgniteChangeGlobalStateSupport) v).onActivate(ctx);
}
}
use of org.apache.ignite.internal.processors.cluster.IgniteChangeGlobalStateSupport in project ignite by apache.
the class GridDhtPartitionsExchangeFuture method onClusterStateChangeRequest.
/**
* @param crd Coordinator flag.
* @return Exchange type.
*/
private ExchangeType onClusterStateChangeRequest(boolean crd) {
assert exchActions != null && !exchActions.empty() : this;
StateChangeRequest req = exchActions.stateChangeRequest();
assert req != null : exchActions;
GridKernalContext kctx = cctx.kernalContext();
DiscoveryDataClusterState state = kctx.state().clusterState();
if (state.transitionError() != null)
exchangeLocE = state.transitionError();
if (req.activeChanged()) {
if (req.state().active()) {
if (log.isInfoEnabled()) {
log.info("Start activation process [nodeId=" + cctx.localNodeId() + ", client=" + kctx.clientNode() + ", topVer=" + initialVersion() + "]. New state: " + req.state());
}
try {
cctx.exchange().exchangerBlockingSectionBegin();
try {
cctx.activate();
} finally {
cctx.exchange().exchangerBlockingSectionEnd();
}
assert registerCachesFuture == null : "No caches registration should be scheduled before new caches have started.";
cctx.exchange().exchangerBlockingSectionBegin();
try {
registerCachesFuture = cctx.affinity().onCacheChangeRequest(this, crd, exchActions);
if (!kctx.clientNode())
cctx.cache().shutdownNotFinishedRecoveryCaches();
} finally {
cctx.exchange().exchangerBlockingSectionEnd();
}
if (log.isInfoEnabled()) {
log.info("Successfully activated caches [nodeId=" + cctx.localNodeId() + ", client=" + kctx.clientNode() + ", topVer=" + initialVersion() + ", newState=" + req.state() + "]");
}
} catch (Exception e) {
U.error(log, "Failed to activate node components [nodeId=" + cctx.localNodeId() + ", client=" + kctx.clientNode() + ", topVer=" + initialVersion() + ", newState=" + req.state() + "]", e);
exchangeLocE = e;
if (crd) {
cctx.exchange().exchangerBlockingSectionBegin();
try {
synchronized (mux) {
exchangeGlobalExceptions.put(cctx.localNodeId(), e);
}
} finally {
cctx.exchange().exchangerBlockingSectionEnd();
}
}
}
} else {
if (log.isInfoEnabled()) {
log.info("Start deactivation process [nodeId=" + cctx.localNodeId() + ", client=" + kctx.clientNode() + ", topVer=" + initialVersion() + "]");
}
cctx.exchange().exchangerBlockingSectionBegin();
try {
kctx.dataStructures().onDeActivate(kctx);
assert registerCachesFuture == null : "No caches registration should be scheduled before new caches have started.";
registerCachesFuture = cctx.affinity().onCacheChangeRequest(this, crd, exchActions);
kctx.encryption().onDeActivate(kctx);
((IgniteChangeGlobalStateSupport) kctx.distributedMetastorage()).onDeActivate(kctx);
if (log.isInfoEnabled()) {
log.info("Successfully deactivated data structures, services and caches [" + "nodeId=" + cctx.localNodeId() + ", client=" + kctx.clientNode() + ", topVer=" + initialVersion() + "]");
}
} catch (Exception e) {
U.error(log, "Failed to deactivate node components [nodeId=" + cctx.localNodeId() + ", client=" + kctx.clientNode() + ", topVer=" + initialVersion() + "]", e);
exchangeLocE = e;
} finally {
cctx.exchange().exchangerBlockingSectionEnd();
}
}
} else if (req.state().active()) {
cctx.exchange().exchangerBlockingSectionBegin();
// TODO: BLT changes on inactive cluster can't be handled easily because persistent storage hasn't been initialized yet.
try {
if (!forceAffReassignment) {
// possible only if cluster contains nodes without forceAffReassignment mode
assert firstEventCache().minimumNodeVersion().compareToIgnoreTimestamp(FORCE_AFF_REASSIGNMENT_SINCE) < 0 : firstEventCache().minimumNodeVersion();
cctx.affinity().onBaselineTopologyChanged(this, crd);
}
if (CU.isPersistenceEnabled(kctx.config()) && !kctx.clientNode())
kctx.state().onBaselineTopologyChanged(req.baselineTopology(), req.prevBaselineTopologyHistoryItem());
} catch (Exception e) {
U.error(log, "Failed to change baseline topology [nodeId=" + cctx.localNodeId() + ", client=" + kctx.clientNode() + ", topVer=" + initialVersion() + "]", e);
exchangeLocE = e;
} finally {
cctx.exchange().exchangerBlockingSectionEnd();
}
}
return kctx.clientNode() ? ExchangeType.CLIENT : ExchangeType.ALL;
}
Aggregations