Search in sources :

Example 1 with IgniteClusterImpl

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;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridFutureAdapter(org.apache.ignite.internal.util.future.GridFutureAdapter) EVT_NODE_LEFT(org.apache.ignite.events.EventType.EVT_NODE_LEFT) BaselineConfigurationChangedEvent(org.apache.ignite.events.BaselineConfigurationChangedEvent) GridFinishedFuture(org.apache.ignite.internal.util.future.GridFinishedFuture) MetastorageLifecycleListener(org.apache.ignite.internal.processors.cache.persistence.metastorage.MetastorageLifecycleListener) DistributedBaselineConfiguration(org.apache.ignite.internal.cluster.DistributedBaselineConfiguration) ReadOnlyMetastorage(org.apache.ignite.internal.processors.cache.persistence.metastorage.ReadOnlyMetastorage) Map(java.util.Map) IgniteUtils.toStringSafe(org.apache.ignite.internal.util.IgniteUtils.toStringSafe) BaselineNodeView(org.apache.ignite.spi.systemview.view.BaselineNodeView) IgniteInClosure(org.apache.ignite.lang.IgniteInClosure) INACTIVE(org.apache.ignite.cluster.ClusterState.INACTIVE) BaselineNodeAttributeViewWalker(org.apache.ignite.internal.managers.systemview.walker.BaselineNodeAttributeViewWalker) GridToStringExclude(org.apache.ignite.internal.util.tostring.GridToStringExclude) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) Event(org.apache.ignite.events.Event) Set(java.util.Set) GridCacheUtils.extractDataStorage(org.apache.ignite.internal.processors.cache.GridCacheUtils.extractDataStorage) Serializable(java.io.Serializable) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BaselineNodeAttributeView(org.apache.ignite.spi.systemview.view.BaselineNodeAttributeView) BaselineAutoAdjustStatus(org.apache.ignite.internal.processors.cluster.baseline.autoadjust.BaselineAutoAdjustStatus) IgniteFutureImpl(org.apache.ignite.internal.util.future.IgniteFutureImpl) CLUSTER_READ_ONLY_MODE(org.apache.ignite.internal.IgniteFeatures.CLUSTER_READ_ONLY_MODE) IgniteCompute(org.apache.ignite.IgniteCompute) ClusterStateChangeStartedEvent(org.apache.ignite.events.ClusterStateChangeStartedEvent) IgniteBiPredicate(org.apache.ignite.lang.IgniteBiPredicate) ClusterState(org.apache.ignite.cluster.ClusterState) U(org.apache.ignite.internal.util.typedef.internal.U) DFLT_STATE_ON_START(org.apache.ignite.configuration.IgniteConfiguration.DFLT_STATE_ON_START) IgniteLogger(org.apache.ignite.IgniteLogger) ClusterGroupAdapter(org.apache.ignite.internal.cluster.ClusterGroupAdapter) IgniteDiscoverySpi(org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi) ArrayList(java.util.ArrayList) GridKernalContext(org.apache.ignite.internal.GridKernalContext) ClusterNode(org.apache.ignite.cluster.ClusterNode) CI1(org.apache.ignite.internal.util.typedef.CI1) ACTIVE_READ_ONLY(org.apache.ignite.cluster.ClusterState.ACTIVE_READ_ONLY) ReadWriteMetastorage(org.apache.ignite.internal.processors.cache.persistence.metastorage.ReadWriteMetastorage) S(org.apache.ignite.internal.util.typedef.internal.S) C1(org.apache.ignite.internal.util.typedef.C1) ACTIVE(org.apache.ignite.cluster.ClusterState.ACTIVE) EVT_BASELINE_AUTO_ADJUST_ENABLED_CHANGED(org.apache.ignite.events.EventType.EVT_BASELINE_AUTO_ADJUST_ENABLED_CHANGED) A(org.apache.ignite.internal.util.typedef.internal.A) Field(java.lang.reflect.Field) BaselineNode(org.apache.ignite.cluster.BaselineNode) STATE_PROC(org.apache.ignite.internal.GridComponent.DiscoveryDataExchangeType.STATE_PROC) IgniteClusterImpl(org.apache.ignite.internal.cluster.IgniteClusterImpl) GridCacheSharedContext(org.apache.ignite.internal.processors.cache.GridCacheSharedContext) IgniteFinishedFutureImpl(org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl) GridProcessorAdapter(org.apache.ignite.internal.processors.GridProcessorAdapter) GridCacheProcessor(org.apache.ignite.internal.processors.cache.GridCacheProcessor) IgniteUuid(org.apache.ignite.lang.IgniteUuid) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) DiscoveryDataBag(org.apache.ignite.spi.discovery.DiscoveryDataBag) StateChangeRequest(org.apache.ignite.internal.processors.cache.StateChangeRequest) StoredCacheData(org.apache.ignite.internal.processors.cache.StoredCacheData) SYSTEM_POOL(org.apache.ignite.internal.managers.communication.GridIoPolicy.SYSTEM_POOL) GridChangeGlobalStateMessageResponse(org.apache.ignite.internal.processors.cache.GridChangeGlobalStateMessageResponse) SAFE_CLUSTER_DEACTIVATION(org.apache.ignite.internal.IgniteFeatures.SAFE_CLUSTER_DEACTIVATION) MetricUtils.metricName(org.apache.ignite.internal.processors.metric.impl.MetricUtils.metricName) IgniteFuture(org.apache.ignite.lang.IgniteFuture) DistributePropertyListener(org.apache.ignite.internal.processors.configuration.distributed.DistributePropertyListener) EventType(org.apache.ignite.events.EventType) IgniteFeatures.allNodesSupports(org.apache.ignite.internal.IgniteFeatures.allNodesSupports) Collection(java.util.Collection) IgniteException(org.apache.ignite.IgniteException) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) ExchangeActions(org.apache.ignite.internal.processors.cache.ExchangeActions) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) EVT_NODE_FAILED(org.apache.ignite.events.EventType.EVT_NODE_FAILED) CU(org.apache.ignite.internal.util.typedef.internal.CU) BaselineTopologyUpdater(org.apache.ignite.internal.processors.cluster.baseline.autoadjust.BaselineTopologyUpdater) IgniteProductVersion(org.apache.ignite.lang.IgniteProductVersion) NodeStoppingException(org.apache.ignite.internal.NodeStoppingException) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) BaselineNodeViewWalker(org.apache.ignite.internal.managers.systemview.walker.BaselineNodeViewWalker) EVT_BASELINE_AUTO_ADJUST_AWAITING_TIME_CHANGED(org.apache.ignite.events.EventType.EVT_BASELINE_AUTO_ADJUST_AWAITING_TIME_CHANGED) HashMap(java.util.HashMap) IgniteFeatures(org.apache.ignite.internal.IgniteFeatures) DiscoCache(org.apache.ignite.internal.managers.discovery.DiscoCache) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) ConcurrentMap(java.util.concurrent.ConcurrentMap) HashSet(java.util.HashSet) IgniteNodeValidationResult(org.apache.ignite.spi.IgniteNodeValidationResult) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) F(org.apache.ignite.internal.util.typedef.F) EVT_NODE_JOINED(org.apache.ignite.events.EventType.EVT_NODE_JOINED) JdkMarshaller(org.apache.ignite.marshaller.jdk.JdkMarshaller) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) DynamicCacheDescriptor(org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException) GridToStringInclude(org.apache.ignite.internal.util.tostring.GridToStringInclude) GridPlainRunnable(org.apache.ignite.internal.util.lang.GridPlainRunnable) Collections(java.util.Collections) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) GridLocalEventListener(org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) IgniteClusterImpl(org.apache.ignite.internal.cluster.IgniteClusterImpl)

Aggregations

Serializable (java.io.Serializable)1 Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 UUID (java.util.UUID)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgniteCompute (org.apache.ignite.IgniteCompute)1 IgniteException (org.apache.ignite.IgniteException)1 IgniteLogger (org.apache.ignite.IgniteLogger)1