use of org.apache.ignite.events.EventType.EVT_CLUSTER_ACTIVATED in project ignite by apache.
the class GridCachePartitionExchangeManager method onClusterStateChangeFinish.
/**
*/
private void onClusterStateChangeFinish(IgniteInternalFuture<AffinityTopologyVersion> fut, ExchangeActions exchActions, boolean baselineChanging) {
A.notNull(exchActions, "exchActions");
GridEventStorageManager evtMngr = cctx.kernalContext().event();
if (exchActions.activate() && evtMngr.isRecordable(EVT_CLUSTER_ACTIVATED) || exchActions.deactivate() && evtMngr.isRecordable(EVT_CLUSTER_DEACTIVATED) || exchActions.changedClusterState() && evtMngr.isRecordable(EVT_CLUSTER_STATE_CHANGED)) {
List<Event> evts = new ArrayList<>(2);
ClusterNode locNode = cctx.kernalContext().discovery().localNode();
Collection<BaselineNode> bltNodes = cctx.kernalContext().cluster().get().currentBaselineTopology();
boolean collectionUsed = false;
if (exchActions.activate() && evtMngr.isRecordable(EVT_CLUSTER_ACTIVATED)) {
assert !exchActions.deactivate() : exchActions;
collectionUsed = true;
evts.add(new ClusterActivationEvent(locNode, "Cluster activated.", EVT_CLUSTER_ACTIVATED, bltNodes));
}
if (exchActions.deactivate() && evtMngr.isRecordable(EVT_CLUSTER_DEACTIVATED)) {
assert !exchActions.activate() : exchActions;
collectionUsed = true;
evts.add(new ClusterActivationEvent(locNode, "Cluster deactivated.", EVT_CLUSTER_DEACTIVATED, bltNodes));
}
if (exchActions.changedClusterState() && evtMngr.isRecordable(EVT_CLUSTER_STATE_CHANGED)) {
StateChangeRequest req = exchActions.stateChangeRequest();
if (collectionUsed && bltNodes != null)
bltNodes = new ArrayList<>(bltNodes);
evts.add(new ClusterStateChangeEvent(req.prevState(), req.state(), bltNodes, locNode, "Cluster state changed."));
}
A.notEmpty(evts, "events " + exchActions);
cctx.kernalContext().pools().getSystemExecutorService().submit(() -> evts.forEach(e -> cctx.kernalContext().event().record(e)));
}
GridKernalContext ctx = cctx.kernalContext();
DiscoveryDataClusterState state = ctx.state().clusterState();
if (baselineChanging) {
ctx.pools().getStripedExecutorService().execute(new Runnable() {
@Override
public void run() {
if (ctx.event().isRecordable(EventType.EVT_BASELINE_CHANGED)) {
ctx.event().record(new BaselineChangedEvent(ctx.discovery().localNode(), "Baseline changed.", EventType.EVT_BASELINE_CHANGED, ctx.cluster().get().currentBaselineTopology()));
}
}
});
}
}
Aggregations