use of org.apache.ignite.internal.processors.cache.GridChangeGlobalStateMessageResponse in project ignite by apache.
the class GridClusterStateProcessor method start.
/** {@inheritDoc} */
@Override
public void start(boolean activeOnStart) throws IgniteCheckedException {
super.start(activeOnStart);
globalState = activeOnStart ? ACTIVE : INACTIVE;
cacheProc = ctx.cache();
sharedCtx = cacheProc.context();
sharedCtx.io().addHandler(0, GridChangeGlobalStateMessageResponse.class, new CI2<UUID, GridChangeGlobalStateMessageResponse>() {
@Override
public void apply(UUID nodeId, GridChangeGlobalStateMessageResponse msg) {
processChangeGlobalStateResponse(nodeId, msg);
}
});
ctx.discovery().setCustomEventListener(ChangeGlobalStateMessage.class, new CustomEventListener<ChangeGlobalStateMessage>() {
@Override
public void onCustomEvent(AffinityTopologyVersion topVer, ClusterNode snd, ChangeGlobalStateMessage msg) {
assert topVer != null;
assert snd != null;
assert msg != null;
boolean activate = msg.activate();
ChangeGlobalStateContext actx = lastCgsCtx;
if (actx != null && globalState == TRANSITION) {
GridChangeGlobalStateFuture f = cgsLocFut.get();
if (log.isDebugEnabled())
log.debug("Concurrent " + prettyStr(activate) + " [id=" + ctx.localNodeId() + " topVer=" + topVer + " actx=" + actx + ", msg=" + msg + "]");
if (f != null && f.requestId.equals(msg.requestId()))
f.onDone(new IgniteCheckedException("Concurrent change state, now in progress=" + (activate) + ", initiatingNodeId=" + actx.initiatingNodeId + ", you try=" + (prettyStr(activate)) + ", locNodeId=" + ctx.localNodeId()));
msg.concurrentChangeState();
} else {
if (log.isInfoEnabled())
log.info("Create " + prettyStr(activate) + " context [id=" + ctx.localNodeId() + " topVer=" + topVer + ", reqId=" + msg.requestId() + ", initiatingNodeId=" + msg.initiatorNodeId() + "]");
lastCgsCtx = new ChangeGlobalStateContext(msg.requestId(), msg.initiatorNodeId(), msg.getDynamicCacheChangeBatch(), msg.activate());
globalState = TRANSITION;
}
}
});
ctx.event().addLocalEventListener(lsr, EVT_NODE_LEFT, EVT_NODE_FAILED);
}
Aggregations