use of org.apache.ignite.internal.cluster.IgniteClusterImpl in project ignite by apache.
the class GridClusterStateProcessor method autoAdjustInMemoryClusterState.
/**
* Update baseline locally if cluster is not persistent and baseline autoadjustment is enabled with zero timeout.
*
* @param nodeId Id of the node that initiated the operation (joined/left/failed).
* @param topSnapshot Topology snapshot from the discovery message.
* @param discoCache Discovery cache from the discovery manager.
* @param topVer Topology version.
* @param minorTopVer Minor topology version.
* @return {@code true} if baseline was changed and discovery cache recalculation is required.
*/
public boolean autoAdjustInMemoryClusterState(UUID nodeId, Collection<ClusterNode> topSnapshot, DiscoCache discoCache, long topVer, int minorTopVer) {
IgniteClusterImpl cluster = ctx.cluster().get();
DiscoveryDataClusterState oldState = globalState;
boolean isInMemoryCluster = CU.isInMemoryCluster(ctx.discovery().allNodes(), ctx.marshallerContext().jdkMarshaller(), U.resolveClassLoader(ctx.config()));
boolean autoAdjustBaseline = isInMemoryCluster && oldState.state().active() && !oldState.transition() && cluster.isBaselineAutoAdjustEnabled() && cluster.baselineAutoAdjustTimeout() == 0L;
if (autoAdjustBaseline) {
BaselineTopology oldBlt = oldState.baselineTopology();
Collection<ClusterNode> bltNodes = topSnapshot.stream().filter(n -> !n.isClient() && !n.isDaemon()).collect(Collectors.toList());
if (!bltNodes.isEmpty()) {
int newBltId = oldBlt == null ? 0 : oldBlt.id();
BaselineTopology newBlt = BaselineTopology.build(bltNodes, newBltId);
ChangeGlobalStateMessage changeGlobalStateMsg = new ChangeGlobalStateMessage(nodeId, nodeId, null, oldState.state(), true, newBlt, true, System.currentTimeMillis());
AffinityTopologyVersion ver = new AffinityTopologyVersion(topVer, minorTopVer);
onStateChangeMessage(ver, changeGlobalStateMsg, discoCache);
ChangeGlobalStateFinishMessage finishMsg = new ChangeGlobalStateFinishMessage(nodeId, oldState.state(), true);
onStateFinishMessage(finishMsg);
globalState.localBaselineAutoAdjustment(true);
return true;
}
}
return false;
}
Aggregations