This is an automated email from the ASF dual-hosted git repository.

alexpl pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new a15a25a  IGNITE-13144 Refactor ClusterState.active(), 
ClusterState.lesserOf() methods - Fixes #7924.
a15a25a is described below

commit a15a25aef132c6d712d7f5d3f7dec8caa35cfe1a
Author: Sergey Antonov <[email protected]>
AuthorDate: Mon Jun 22 19:46:48 2020 +0500

    IGNITE-13144 Refactor ClusterState.active(), ClusterState.lesserOf() 
methods - Fixes #7924.
    
    Signed-off-by: Aleksey Plekhanov <[email protected]>
---
 .../rest/ChangeStateCommandHandlerTest.java        |   5 +-
 .../rest/JettyRestProcessorAbstractSelfTest.java   |   2 +-
 .../org/apache/ignite/cluster/ClusterState.java    |  47 ++---
 .../managers/discovery/GridDiscoveryManager.java   |   3 +-
 .../internal/processors/cache/ExchangeActions.java |   6 +-
 .../processors/cache/StateChangeRequest.java       |   4 +-
 .../preloader/GridDhtPartitionsExchangeFuture.java |   5 +-
 .../snapshot/IgniteSnapshotManager.java            |   3 +-
 .../cluster/ChangeGlobalStateFinishMessage.java    |   4 +-
 .../cluster/ChangeGlobalStateMessage.java          |   2 +-
 .../ClientGetClusterStateComputeRequest.java       |  42 ++++
 .../ClientSetClusterStateComputeRequest.java       |  84 ++++++++
 .../cluster/DiscoveryDataClusterState.java         |   2 +-
 .../cluster/GridClusterStateProcessor.java         | 217 +++++++--------------
 .../cluster/ClientClusterGetStateRequest.java      |   2 +-
 .../main/resources/META-INF/classnames.properties  |   5 +-
 ...ActiveStateChangeWithNodeOutOfBaselineTest.java |   6 +-
 .../cache/IgniteClusterActivateDeactivateTest.java |  41 ++--
 .../eviction/EvictionPolicyFailureHandlerTest.java |   2 +-
 .../apache/ignite/testframework/GridTestUtils.java |   8 +-
 20 files changed, 260 insertions(+), 230 deletions(-)

diff --git 
a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/ChangeStateCommandHandlerTest.java
 
b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/ChangeStateCommandHandlerTest.java
index 7101144..93670d7 100644
--- 
a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/ChangeStateCommandHandlerTest.java
+++ 
b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/ChangeStateCommandHandlerTest.java
@@ -31,7 +31,6 @@ import org.junit.Test;
 
 import static org.apache.ignite.cluster.ClusterState.ACTIVE;
 import static org.apache.ignite.cluster.ClusterState.INACTIVE;
-import static org.apache.ignite.cluster.ClusterState.active;
 import static org.apache.ignite.internal.client.GridClientProtocol.TCP;
 
 /**
@@ -90,9 +89,7 @@ public class ChangeStateCommandHandlerTest extends 
GridCommonAbstractTest {
     public void testActivateDeActivate() throws GridClientException {
         GridClientClusterState state = client.state();
 
-        boolean active = active(state.state());
-
-        assertTrue(active);
+        assertTrue(state.state().toString(), state.state().active());
 
         state.state(INACTIVE, true);
 
diff --git 
a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
 
b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
index 1c897f0..5216255 100644
--- 
a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
+++ 
b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
@@ -4056,7 +4056,7 @@ public abstract class JettyRestProcessorAbstractSelfTest 
extends JettyRestProces
      */
     private void checkState(ClusterState expState) throws Exception {
         assertClusterState(expState);
-        assertClusterState(ClusterState.active(expState));
+        assertClusterState(expState.active());
     }
 
     /**
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cluster/ClusterState.java 
b/modules/core/src/main/java/org/apache/ignite/cluster/ClusterState.java
index 85d95d6..88baf07 100644
--- a/modules/core/src/main/java/org/apache/ignite/cluster/ClusterState.java
+++ b/modules/core/src/main/java/org/apache/ignite/cluster/ClusterState.java
@@ -29,13 +29,28 @@ public enum ClusterState {
      * <b>NOTE:</b>
      * Deactivation clears in-memory caches (without persistence) including 
the system caches.
      */
-    INACTIVE,
+    INACTIVE(false),
 
     /** Cluster activated. All cache operations are allowed. */
-    ACTIVE,
+    ACTIVE(true),
 
     /** Cluster activated. Cache read operation allowed, Cache data change 
operation aren't allowed. */
-    ACTIVE_READ_ONLY;
+    ACTIVE_READ_ONLY(true);
+
+    /** Cluster activated flag. */
+    private final boolean active;
+
+    /** */
+    ClusterState(boolean active) {
+        this.active = active;
+    }
+
+    /**
+     * @return {@code True} if cluster activated in this state and {@code 
false} otherwise.
+     */
+    public boolean active() {
+        return active;
+    }
 
     /** Enumerated values. */
     private static final ClusterState[] VALS = values();
@@ -49,30 +64,4 @@ public enum ClusterState {
     @Nullable public static ClusterState fromOrdinal(int ord) {
         return ord >= 0 && ord < VALS.length ? VALS[ord] : null;
     }
-
-    /**
-     * @param state Cluster state
-     * @return {@code True} if cluster in given cluster {@code state} is 
activated and {@code False} otherwise.
-     */
-    public static boolean active(ClusterState state) {
-        return state != INACTIVE;
-    }
-
-    /**
-     * @param state1 First given state.
-     * @param state2 Second given state.
-     * @return Lesser of given states. The order: {@link #ACTIVE} > {@link 
#ACTIVE_READ_ONLY} > {@link #INACTIVE}.
-     */
-    public static ClusterState lesserOf(ClusterState state1, ClusterState 
state2) {
-        if (state1 == state2)
-            return state1;
-
-        if (state1 == INACTIVE || state2 == INACTIVE)
-            return INACTIVE;
-
-        if (state1 == ACTIVE_READ_ONLY || state2 == ACTIVE_READ_ONLY)
-            return ACTIVE_READ_ONLY;
-
-        throw new IllegalArgumentException("Unknown cluster states. state1: " 
+ state1 + ", state2: " + state2);
-    }
 }
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
index 828f18e..f3107f4 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
@@ -144,7 +144,6 @@ import static 
org.apache.ignite.IgniteSystemProperties.IGNITE_SECURITY_COMPATIBI
 import static org.apache.ignite.IgniteSystemProperties.getInteger;
 import static org.apache.ignite.cluster.ClusterState.ACTIVE;
 import static org.apache.ignite.cluster.ClusterState.INACTIVE;
-import static org.apache.ignite.cluster.ClusterState.active;
 import static org.apache.ignite.events.EventType.EVT_CLIENT_NODE_DISCONNECTED;
 import static org.apache.ignite.events.EventType.EVT_CLIENT_NODE_RECONNECTED;
 import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
@@ -1540,7 +1539,7 @@ public class GridDiscoveryManager extends 
GridManagerAdapter<DiscoverySpi> {
             if (targetState == null)
                 targetState = ctx.config().isAutoActivationEnabled() ? ACTIVE 
: INACTIVE;
 
-            if (!active(state.state()) && active(targetState)) {
+            if (!state.state().active() && targetState.active()) {
                 String offlineConsistentIds = "";
 
                 if (bltOffline > 0 && bltOffline <= 5) {
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeActions.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeActions.java
index 5382a91..b31c6f0 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeActions.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeActions.java
@@ -30,8 +30,6 @@ import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.jetbrains.annotations.Nullable;
 
-import static org.apache.ignite.cluster.ClusterState.active;
-
 /**
  * Cache change requests to execute when receive {@link 
DynamicCacheChangeBatch} event.
  */
@@ -204,14 +202,14 @@ public class ExchangeActions {
      * @return {@code True} if has deactivate request.
      */
     public boolean deactivate() {
-        return stateChangeReq != null && stateChangeReq.activeChanged() && 
!active(stateChangeReq.state());
+        return stateChangeReq != null && stateChangeReq.activeChanged() && 
!stateChangeReq.state().active();
     }
 
     /**
      * @return {@code True} if has activate request.
      */
     public boolean activate() {
-        return stateChangeReq != null && stateChangeReq.activeChanged() && 
active(stateChangeReq.state());
+        return stateChangeReq != null && stateChangeReq.activeChanged() && 
stateChangeReq.state().active();
     }
 
     /**
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StateChangeRequest.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StateChangeRequest.java
index 5d06855..faeba83 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StateChangeRequest.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StateChangeRequest.java
@@ -27,8 +27,6 @@ import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.lang.IgniteUuid;
 import org.jetbrains.annotations.Nullable;
 
-import static org.apache.ignite.cluster.ClusterState.active;
-
 /**
  *
  */
@@ -111,7 +109,7 @@ public class StateChangeRequest {
      * @return {@code True} if active state was changed.
      */
     public boolean activeChanged() {
-        return active(prevState) && !active(msg.state()) || !active(prevState) 
&& active(msg.state());
+        return prevState.active() != msg.state().active();
     }
 
     /**
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
index 1df01f5..4f9e1dd 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
@@ -133,7 +133,6 @@ import static 
org.apache.ignite.IgniteSystemProperties.IGNITE_PARTITION_RELEASE_
 import static 
org.apache.ignite.IgniteSystemProperties.IGNITE_THREAD_DUMP_ON_EXCHANGE_TIMEOUT;
 import static org.apache.ignite.IgniteSystemProperties.getBoolean;
 import static org.apache.ignite.IgniteSystemProperties.getLong;
-import static org.apache.ignite.cluster.ClusterState.active;
 import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
 import static org.apache.ignite.events.EventType.EVT_NODE_JOINED;
 import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
@@ -1193,7 +1192,7 @@ public class GridDhtPartitionsExchangeFuture extends 
GridDhtTopologyFutureAdapte
             exchangeLocE = state.transitionError();
 
         if (req.activeChanged()) {
-            if (active(req.state())) {
+            if (req.state().active()) {
                 if (log.isInfoEnabled()) {
                     log.info("Start activation process [nodeId=" + 
cctx.localNodeId() +
                         ", client=" + kctx.clientNode() +
@@ -1293,7 +1292,7 @@ public class GridDhtPartitionsExchangeFuture extends 
GridDhtTopologyFutureAdapte
                 }
             }
         }
-        else if (active(req.state())) {
+        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.
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
index e0bba84..0a05790 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
@@ -111,7 +111,6 @@ import org.apache.ignite.thread.OomExceptionHandler;
 import org.jetbrains.annotations.Nullable;
 
 import static java.nio.file.StandardOpenOption.READ;
-import static org.apache.ignite.cluster.ClusterState.active;
 import static 
org.apache.ignite.configuration.DataStorageConfiguration.DFLT_BINARY_METADATA_PATH;
 import static 
org.apache.ignite.configuration.DataStorageConfiguration.DFLT_MARSHALLER_PATH;
 import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
@@ -736,7 +735,7 @@ public class IgniteSnapshotManager extends 
GridCacheSharedManagerAdapter
             if 
(!IgniteFeatures.allNodesSupports(cctx.discovery().aliveServerNodes(), 
PERSISTENCE_CACHE_SNAPSHOT))
                 throw new IgniteException("Not all nodes in the cluster 
support a snapshot operation.");
 
-            if (!active(cctx.kernalContext().state().clusterState().state()))
+            if (!cctx.kernalContext().state().clusterState().state().active())
                 throw new IgniteException("Snapshot operation has been 
rejected. The cluster is inactive.");
 
             DiscoveryDataClusterState clusterState = 
cctx.kernalContext().state().clusterState();
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateFinishMessage.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateFinishMessage.java
index 3cf0e17..9f73c15 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateFinishMessage.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateFinishMessage.java
@@ -76,14 +76,14 @@ public class ChangeGlobalStateFinishMessage implements 
DiscoveryCustomMessage {
      */
     @Deprecated
     public boolean clusterActive() {
-        return ClusterState.active(state);
+        return state.active();
     }
 
     /**
      * @return Transition success status.
      */
     public boolean success() {
-        return transitionRes == null ? ClusterState.active(state) : 
transitionRes;
+        return transitionRes == null ? state.active() : transitionRes;
     }
 
     /**
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateMessage.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateMessage.java
index f49855e..1904969 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateMessage.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateMessage.java
@@ -181,7 +181,7 @@ public class ChangeGlobalStateMessage implements 
DiscoveryCustomMessage {
      */
     @Deprecated
     public boolean activate() {
-        return ClusterState.active(state);
+        return state.active();
     }
 
     /**
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClientGetClusterStateComputeRequest.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClientGetClusterStateComputeRequest.java
new file mode 100644
index 0000000..d564229
--- /dev/null
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClientGetClusterStateComputeRequest.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cluster;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.cluster.ClusterState;
+import org.apache.ignite.internal.processors.task.GridInternal;
+import org.apache.ignite.lang.IgniteCallable;
+import org.apache.ignite.resources.IgniteInstanceResource;
+
+/**
+ * Request for getting cluster state on client node.
+ */
+@GridInternal
+public class ClientGetClusterStateComputeRequest implements 
IgniteCallable<ClusterState> {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Ignite. */
+    @IgniteInstanceResource
+    private Ignite ig;
+
+    /** {@inheritDoc} */
+    @Override public ClusterState call() throws Exception {
+        return ig.cluster().state();
+    }
+}
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClientSetClusterStateComputeRequest.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClientSetClusterStateComputeRequest.java
new file mode 100644
index 0000000..b6eddab
--- /dev/null
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClientSetClusterStateComputeRequest.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cluster;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cluster.ClusterState;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.processors.task.GridInternal;
+import org.apache.ignite.lang.IgniteRunnable;
+import org.apache.ignite.resources.IgniteInstanceResource;
+
+/**
+ * Request for the change cluster state from client node.
+ */
+@GridInternal
+public class ClientSetClusterStateComputeRequest implements IgniteRunnable {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** */
+    private final ClusterState state;
+
+    /** If {@code true}, cluster deactivation will be forced. */
+    private final boolean forceDeactivation;
+
+    /** */
+    private final BaselineTopology baselineTopology;
+
+    /** */
+    private final boolean forceChangeBaselineTopology;
+
+    /** Ignite. */
+    @IgniteInstanceResource
+    private IgniteEx ig;
+
+    /**
+     * @param state New cluster state.
+     * @param forceDeactivation If {@code true}, cluster deactivation will be 
forced.
+     * @param blt New baseline topology.
+     * @param forceBlt Force change cluster state.
+     */
+    ClientSetClusterStateComputeRequest(
+        ClusterState state,
+        boolean forceDeactivation,
+        BaselineTopology blt,
+        boolean forceBlt
+    ) {
+        this.state = state;
+        this.baselineTopology = blt;
+        this.forceChangeBaselineTopology = forceBlt;
+        this.forceDeactivation = forceDeactivation;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void run() {
+        try {
+            ig.context().state().changeGlobalState(
+                state,
+                forceDeactivation,
+                baselineTopology != null ? baselineTopology.currentBaseline() 
: null,
+                forceChangeBaselineTopology
+            ).get();
+        }
+        catch (IgniteCheckedException ex) {
+            throw new IgniteException(ex);
+        }
+    }
+}
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/DiscoveryDataClusterState.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/DiscoveryDataClusterState.java
index cd30a54..8536dd2 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/DiscoveryDataClusterState.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/DiscoveryDataClusterState.java
@@ -223,7 +223,7 @@ public class DiscoveryDataClusterState implements 
Serializable {
      */
     @Deprecated
     public boolean active() {
-        return ClusterState.active(state);
+        return state.active();
     }
 
     /**
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridClusterStateProcessor.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridClusterStateProcessor.java
index 7353135..57b6790 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridClusterStateProcessor.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridClusterStateProcessor.java
@@ -31,7 +31,6 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.stream.Collectors;
-import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteCompute;
 import org.apache.ignite.IgniteException;
@@ -46,7 +45,6 @@ import org.apache.ignite.events.DiscoveryEvent;
 import org.apache.ignite.events.Event;
 import org.apache.ignite.events.EventType;
 import org.apache.ignite.internal.GridKernalContext;
-import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.internal.IgniteFeatures;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.NodeStoppingException;
@@ -71,7 +69,6 @@ import 
org.apache.ignite.internal.processors.cache.persistence.metastorage.ReadW
 import 
org.apache.ignite.internal.processors.cluster.baseline.autoadjust.BaselineAutoAdjustStatus;
 import 
org.apache.ignite.internal.processors.cluster.baseline.autoadjust.ChangeTopologyWatcher;
 import org.apache.ignite.internal.processors.service.GridServiceProcessor;
-import org.apache.ignite.internal.processors.task.GridInternal;
 import org.apache.ignite.internal.util.future.GridFinishedFuture;
 import org.apache.ignite.internal.util.future.GridFutureAdapter;
 import org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl;
@@ -85,14 +82,11 @@ import org.apache.ignite.internal.util.typedef.internal.A;
 import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteCallable;
 import org.apache.ignite.lang.IgniteFuture;
 import org.apache.ignite.lang.IgniteInClosure;
 import org.apache.ignite.lang.IgniteProductVersion;
-import org.apache.ignite.lang.IgniteRunnable;
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.marshaller.jdk.JdkMarshaller;
-import org.apache.ignite.resources.IgniteInstanceResource;
 import org.apache.ignite.spi.IgniteNodeValidationResult;
 import org.apache.ignite.spi.discovery.DiscoveryDataBag;
 import org.jetbrains.annotations.Nullable;
@@ -100,7 +94,6 @@ import org.jetbrains.annotations.Nullable;
 import static org.apache.ignite.cluster.ClusterState.ACTIVE;
 import static org.apache.ignite.cluster.ClusterState.ACTIVE_READ_ONLY;
 import static org.apache.ignite.cluster.ClusterState.INACTIVE;
-import static org.apache.ignite.cluster.ClusterState.lesserOf;
 import static 
org.apache.ignite.configuration.IgniteConfiguration.DFLT_STATE_ON_START;
 import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
 import static org.apache.ignite.events.EventType.EVT_NODE_JOINED;
@@ -238,7 +231,7 @@ public class GridClusterStateProcessor extends 
GridProcessorAdapter implements I
         return new IgniteNodeValidationResult(
             node.id(),
             "Joining persistence node to in-memory cluster couldn't be allowed 
" +
-            "due to baseline auto-adjust is enabled and timeout equal to 0"
+                "due to baseline auto-adjust is enabled and timeout equal to 0"
         );
     }
 
@@ -264,7 +257,7 @@ public class GridClusterStateProcessor extends 
GridProcessorAdapter implements I
 
         assert globalState != null;
 
-        if (globalState.transition() && active(globalState)) {
+        if (globalState.transition() && globalState.state().active()) {
             ClusterState transitionRes = globalState.transitionResult();
 
             if (transitionRes != null)
@@ -283,7 +276,7 @@ public class GridClusterStateProcessor extends 
GridProcessorAdapter implements I
                         }));
                     }
                     else
-                        return new 
IgniteFinishedFutureImpl<>(lesserOf(globalState.lastState(), 
globalState.state()));
+                        return new 
IgniteFinishedFutureImpl<>(stateWithMinimalFeatures(globalState.lastState(), 
globalState.state()));
                 }
 
                 transitionRes = globalState.transitionResult();
@@ -304,7 +297,7 @@ public class GridClusterStateProcessor extends 
GridProcessorAdapter implements I
 
     /** {@inheritDoc} */
     @Override public IgniteFuture<Boolean> publicApiActiveStateAsync(boolean 
asyncWaitForTransition) {
-        return publicApiStateAsync(asyncWaitForTransition).chain(f -> 
ClusterState.active(f.get()));
+        return publicApiStateAsync(asyncWaitForTransition).chain(f -> 
f.get().active());
     }
 
     /** {@inheritDoc} */
@@ -314,7 +307,7 @@ public class GridClusterStateProcessor extends 
GridProcessorAdapter implements I
 
     /** {@inheritDoc} */
     @Override public void onReadyForRead(ReadOnlyMetastorage metastorage) 
throws IgniteCheckedException {
-        BaselineTopology blt = (BaselineTopology) 
metastorage.read(METASTORE_CURR_BLT_KEY);
+        BaselineTopology blt = 
(BaselineTopology)metastorage.read(METASTORE_CURR_BLT_KEY);
 
         if (blt != null) {
             if (log.isInfoEnabled())
@@ -361,7 +354,8 @@ public class GridClusterStateProcessor extends 
GridProcessorAdapter implements I
     /**
      * @param blt Blt.
      */
-    private void writeBaselineTopology(BaselineTopology blt, 
BaselineTopologyHistoryItem prevBltHistItem) throws IgniteCheckedException {
+    private void writeBaselineTopology(BaselineTopology blt,
+        BaselineTopologyHistoryItem prevBltHistItem) throws 
IgniteCheckedException {
         assert metastorage != null;
 
         if (inMemoryMode)
@@ -453,7 +447,7 @@ public class GridClusterStateProcessor extends 
GridProcessorAdapter implements I
     @Override @Nullable public IgniteInternalFuture<Boolean> 
onLocalJoin(DiscoCache discoCache) {
         final DiscoveryDataClusterState state = globalState;
 
-        if (active(state))
+        if (state.state().active())
             checkLocalNodeInBaseline(state.baselineTopology());
 
         if (state.transition()) {
@@ -461,21 +455,19 @@ public class GridClusterStateProcessor extends 
GridProcessorAdapter implements I
 
             return joinFut;
         }
-        else
-        {
+        else {
             ClusterState targetState = ctx.config().getClusterStateOnStart();
 
             if (targetState == null)
                 targetState = ctx.config().isAutoActivationEnabled() ? ACTIVE 
: INACTIVE;
 
-            if (!ctx.clientNode()
-                && !ctx.isDaemon()
-                && !active(state)
-                && ClusterState.active(targetState)
-                && !inMemoryMode
-                && isBaselineSatisfied(state.baselineTopology(), 
discoCache.serverNodes())
-            )
-                changeGlobalState(targetState, true, 
state.baselineTopology().currentBaseline(), false);
+            boolean serverNode = !ctx.clientNode() && !ctx.isDaemon();
+            boolean activation = !state.state().active() && 
targetState.active();
+
+            if (serverNode && activation && !inMemoryMode) {
+                if (isBaselineSatisfied(state.baselineTopology(), 
discoCache.serverNodes()))
+                    changeGlobalState(targetState, true, 
state.baselineTopology().currentBaseline(), false);
+            }
         }
 
         return null;
@@ -551,12 +543,12 @@ public class GridClusterStateProcessor extends 
GridProcessorAdapter implements I
 
             ctx.durableBackgroundTasksProcessor().onStateChangeFinish(msg);
 
-            if (readOnly(discoClusterState.lastState()) || 
readOnly(globalState.state()))
-                
ctx.cache().context().readOnlyMode(readOnly(globalState.state()));
+            if (discoClusterState.lastState() == ACTIVE_READ_ONLY || 
globalState.state() == ACTIVE_READ_ONLY)
+                ctx.cache().context().readOnlyMode(globalState.state() == 
ACTIVE_READ_ONLY);
 
             log.info("Cluster state was changed from " + 
discoClusterState.lastState() + " to " + globalState.state());
 
-            if (!ClusterState.active(globalState.state()))
+            if (!globalState.state().active())
                 ctx.cache().context().readOnlyMode(false);
 
             TransitionOnJoinWaitFuture joinFut = this.joinFut;
@@ -734,21 +726,6 @@ public class GridClusterStateProcessor extends 
GridProcessorAdapter implements I
     }
 
     /**
-     * Same behaviour as {@link ClusterState#active(ClusterState)}
-     */
-    private static boolean active(DiscoveryDataClusterState 
discoDataClusterState) {
-        return ClusterState.active(discoDataClusterState.state());
-    }
-
-    /**
-     * @param state Cluster state
-     * @return {@code True} passed {@code state} is {@link 
ClusterState#ACTIVE_READ_ONLY}, and {@code False} otherwise.
-     */
-    private static boolean readOnly(ClusterState state) {
-        return state == ACTIVE_READ_ONLY;
-    }
-
-    /**
      * @param msg State change message.
      * @param state Current cluster state.
      * @return {@code True} if state change from message can be applied to the 
current state.
@@ -776,7 +753,7 @@ public class GridClusterStateProcessor extends 
GridProcessorAdapter implements I
     @Override public DiscoveryDataClusterState 
pendingState(ChangeGlobalStateMessage stateMsg) {
         ClusterState state;
 
-        if (ClusterState.active(stateMsg.state()))
+        if (stateMsg.state().active())
             state = stateMsg.state();
         else
             state = stateMsg.forceChangeBaselineTopology() ? ACTIVE : INACTIVE;
@@ -924,14 +901,11 @@ public class GridClusterStateProcessor extends 
GridProcessorAdapter implements I
                 throw new IgniteException("Node with BaselineTopology cannot 
join" +
                     " mixed cluster running in compatibility mode");
 
-            globalState = (DiscoveryDataClusterState) data.commonData();
+            globalState = (DiscoveryDataClusterState)data.commonData();
 
             compatibilityMode = true;
 
-            ctx.cache().context().readOnlyMode(readOnly(globalState.state()));
-
-            if (readOnly(globalState.state()))
-                ctx.cache().context().database().forceCheckpoint("Cluster 
read-only mode enabled");
+            ctx.cache().context().readOnlyMode(globalState.state() == 
ACTIVE_READ_ONLY);
 
             return;
         }
@@ -951,12 +925,7 @@ public class GridClusterStateProcessor extends 
GridProcessorAdapter implements I
                     bltHist.bufferHistoryItemForStore(item);
             }
 
-            final boolean readOnly = readOnly(globalState.state());
-
-            ctx.cache().context().readOnlyMode(readOnly);
-
-            if (readOnly)
-                ctx.cache().context().database().forceCheckpoint("Cluster 
read-only mode enabled");
+            ctx.cache().context().readOnlyMode(globalState.state() == 
ACTIVE_READ_ONLY);
         }
     }
 
@@ -983,14 +952,14 @@ public class GridClusterStateProcessor extends 
GridProcessorAdapter implements I
         int newBltId = 0;
 
         if (currBlt != null)
-            newBltId = ClusterState.active(state) ? currBlt.id() + 1 : 
currBlt.id();
+            newBltId = state.active() ? currBlt.id() + 1 : currBlt.id();
 
         if (baselineNodes != null && !baselineNodes.isEmpty()) {
             List<BaselineNode> baselineNodes0 = new ArrayList<>();
 
             for (BaselineNode node : baselineNodes) {
                 if (node instanceof ClusterNode) {
-                    ClusterNode clusterNode = (ClusterNode) node;
+                    ClusterNode clusterNode = (ClusterNode)node;
 
                     if (!clusterNode.isClient() && !clusterNode.isDaemon())
                         baselineNodes0.add(node);
@@ -1004,7 +973,7 @@ public class GridClusterStateProcessor extends 
GridProcessorAdapter implements I
 
         if (forceChangeBaselineTopology)
             newBlt = BaselineTopology.build(baselineNodes, newBltId);
-        else if (ClusterState.active(state)) {
+        else if (state.active()) {
             if (baselineNodes == null)
                 baselineNodes = baselineNodes();
 
@@ -1072,7 +1041,7 @@ public class GridClusterStateProcessor extends 
GridProcessorAdapter implements I
         DiscoveryDataClusterState curState = globalState;
 
         if (!curState.transition() && curState.state() == state) {
-            if (!ClusterState.active(state) || 
BaselineTopology.equals(curState.baselineTopology(), blt))
+            if (!state.active() || 
BaselineTopology.equals(curState.baselineTopology(), blt))
                 return new GridFinishedFuture<>();
         }
 
@@ -1097,7 +1066,7 @@ public class GridClusterStateProcessor extends 
GridProcessorAdapter implements I
                 return new GridFinishedFuture<>(
                     new IgniteCheckedException(
                         "Failed to " + prettyStr(state) +
-                        ", because another state change operation is currently 
in progress: " + prettyStr(fut.state)
+                            ", because another state change operation is 
currently in progress: " + prettyStr(fut.state)
                     )
                 );
             }
@@ -1114,7 +1083,7 @@ public class GridClusterStateProcessor extends 
GridProcessorAdapter implements I
                 if (!F.isEmpty(cfgs)) {
                     storedCfgs = new ArrayList<>(cfgs.values());
 
-                    IgniteDiscoverySpi spi = (IgniteDiscoverySpi) 
ctx.discovery().getInjectedDiscoverySpi();
+                    IgniteDiscoverySpi spi = 
(IgniteDiscoverySpi)ctx.discovery().getInjectedDiscoverySpi();
 
                     boolean splittedCacheCfgs = 
spi.allNodesSupport(IgniteFeatures.SPLITTED_CACHE_CONFIGURATIONS);
 
@@ -1197,8 +1166,9 @@ public class GridClusterStateProcessor extends 
GridProcessorAdapter implements I
         DiscoveryDataClusterState joiningNodeState;
 
         try {
-            joiningNodeState = marsh.unmarshal((byte[]) 
discoData.joiningNodeData(), Thread.currentThread().getContextClassLoader());
-        } catch (IgniteCheckedException e) {
+            joiningNodeState = 
marsh.unmarshal((byte[])discoData.joiningNodeData(), 
Thread.currentThread().getContextClassLoader());
+        }
+        catch (IgniteCheckedException e) {
             String msg = "Error on unmarshalling discovery data " +
                 "from node " + node.consistentId() + ": " + e.getMessage() +
                 "; node is not allowed to join";
@@ -1315,7 +1285,7 @@ public class GridClusterStateProcessor extends 
GridProcessorAdapter implements I
 
         IgniteCompute comp = 
((ClusterGroupAdapter)ctx.cluster().get().forServers()).compute();
 
-        IgniteFuture<Void> fut = comp.runAsync(new 
ClientSetGlobalStateComputeRequest(state, forceDeactivation, blt,
+        IgniteFuture<Void> fut = comp.runAsync(new 
ClientSetClusterStateComputeRequest(state, forceDeactivation, blt,
             forceBlt));
 
         return ((IgniteFutureImpl<Void>)fut).internalFuture();
@@ -1341,7 +1311,7 @@ public class GridClusterStateProcessor extends 
GridProcessorAdapter implements I
         if (F.isEmpty(clusterGroupAdapter.nodes()))
             return new IgniteFinishedFutureImpl<>(INACTIVE);
 
-        return clusterGroupAdapter.compute().callAsync(new 
GetClusterStateComputeRequest());
+        return clusterGroupAdapter.compute().callAsync(new 
ClientGetClusterStateComputeRequest());
     }
 
     /** {@inheritDoc} */
@@ -1428,7 +1398,7 @@ public class GridClusterStateProcessor extends 
GridProcessorAdapter implements I
     @Override public void onStateChangeExchangeDone(StateChangeRequest req) {
         try {
             if (req.activeChanged()) {
-                if (ClusterState.active(req.state()))
+                if (req.state().active())
                     onFinalActivate(req);
 
                 globalState.setTransitionResult(req.requestId(), req.state());
@@ -1532,7 +1502,7 @@ public class GridClusterStateProcessor extends 
GridProcessorAdapter implements I
     private void onStateRestored(BaselineTopology blt) {
         DiscoveryDataClusterState state = globalState;
 
-        if (!ClusterState.active(state.state()) && !state.transition() && 
state.baselineTopology() == null)
+        if (!state.state().active() && !state.transition() && 
state.baselineTopology() == null)
             globalState = DiscoveryDataClusterState.createState(INACTIVE, blt);
     }
 
@@ -1564,7 +1534,7 @@ public class GridClusterStateProcessor extends 
GridProcessorAdapter implements I
         );
 
         boolean autoAdjustBaseline = isInMemoryCluster
-            && ClusterState.active(oldState.state())
+            && oldState.state().active()
             && !oldState.transition()
             && cluster.isBaselineAutoAdjustEnabled()
             && cluster.baselineAutoAdjustTimeout() == 0L;
@@ -1626,7 +1596,7 @@ public class GridClusterStateProcessor extends 
GridProcessorAdapter implements I
                 UUID.randomUUID(),
                 ctx.localNodeId(),
                 null,
-                ClusterState.active(clusterState.state()) ? 
clusterState.state() : ACTIVE,
+                clusterState.state().active() ? clusterState.state() : ACTIVE,
                 true,
                 blt,
                 true,
@@ -1650,7 +1620,8 @@ public class GridClusterStateProcessor extends 
GridProcessorAdapter implements I
     }
 
     /** {@inheritDoc} */
-    @Override public void onExchangeFinishedOnCoordinator(IgniteInternalFuture 
exchangeFuture, boolean hasMovingPartitions) {
+    @Override public void onExchangeFinishedOnCoordinator(IgniteInternalFuture 
exchangeFuture,
+        boolean hasMovingPartitions) {
         // no-op
     }
 
@@ -1771,7 +1742,7 @@ public class GridClusterStateProcessor extends 
GridProcessorAdapter implements I
         assert state != null;
         assert newState != null;
 
-        return state == INACTIVE && ClusterState.active(newState);
+        return state == INACTIVE && newState.active();
     }
 
     /**
@@ -1821,6 +1792,36 @@ public class GridClusterStateProcessor extends 
GridProcessorAdapter implements I
                 && (!desc.cacheConfiguration().isWriteBehindEnabled() || 
!desc.cacheConfiguration().isReadThrough()));
     }
 
+    /**
+     * Gets state of given two with minimal number of features.
+     * <p/>
+     * The order: {@link ClusterState#ACTIVE} > {@link 
ClusterState#ACTIVE_READ_ONLY} > {@link ClusterState#INACTIVE}.
+     * <p/>
+     * Explain:
+     * <br/>
+     * {@link ClusterState#INACTIVE} has the smallast number of available 
features. You can't use caches in this state.
+     * <br/>
+     * In {@link ClusterState#ACTIVE_READ_ONLY} you have more available 
features than {@link ClusterState#INACTIVE} state,
+     * such as reading from caches, but can't write into them.
+     * <br/> In {@link ClusterState#ACTIVE} you can update caches. It's a 
state with the biggest number of features.
+     *
+     * @param state1 First given state.
+     * @param state2 Second given state.
+     * @return State with minimal number of available features.
+     */
+    public static ClusterState stateWithMinimalFeatures(ClusterState state1, 
ClusterState state2) {
+        if (state1 == state2)
+            return state1;
+
+        if (state1 == INACTIVE || state2 == INACTIVE)
+            return INACTIVE;
+
+        if (state1 == ACTIVE_READ_ONLY || state2 == ACTIVE_READ_ONLY)
+            return ACTIVE_READ_ONLY;
+
+        throw new IllegalArgumentException("Unknown cluster states. state1: " 
+ state1 + ", state2: " + state2);
+    }
+
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(GridClusterStateProcessor.class, this);
@@ -1979,82 +1980,6 @@ public class GridClusterStateProcessor extends 
GridProcessorAdapter implements I
     /**
      *
      */
-    @GridInternal
-    private static class ClientSetGlobalStateComputeRequest implements 
IgniteRunnable {
-        /** */
-        private static final long serialVersionUID = 0L;
-
-        /** */
-        private final ClusterState state;
-
-        /** If {@code true}, cluster deactivation will be forced. */
-        private final boolean forceDeactivation;
-
-        /** */
-        private final BaselineTopology baselineTopology;
-
-        /** */
-        private final boolean forceChangeBaselineTopology;
-
-        /** Ignite. */
-        @IgniteInstanceResource
-        private IgniteEx ig;
-
-        /**
-         * @param state New cluster state.
-         * @param forceDeactivation If {@code true}, cluster deactivation will 
be forced.
-         * @param blt New baseline topology.
-         * @param forceBlt Force change cluster state.
-         */
-        private ClientSetGlobalStateComputeRequest(
-            ClusterState state,
-            boolean forceDeactivation,
-            BaselineTopology blt,
-            boolean forceBlt
-        ) {
-            this.state = state;
-            this.baselineTopology = blt;
-            this.forceChangeBaselineTopology = forceBlt;
-            this.forceDeactivation = forceDeactivation;
-        }
-
-        /** {@inheritDoc} */
-        @Override public void run() {
-            try {
-                ig.context().state().changeGlobalState(
-                    state,
-                    forceDeactivation,
-                    baselineTopology != null ? 
baselineTopology.currentBaseline() : null,
-                    forceChangeBaselineTopology
-                ).get();
-            }
-            catch (IgniteCheckedException ex) {
-                throw new IgniteException(ex);
-            }
-        }
-    }
-
-    /**
-     *
-     */
-    @GridInternal
-    private static class GetClusterStateComputeRequest implements 
IgniteCallable<ClusterState> {
-        /** */
-        private static final long serialVersionUID = 0L;
-
-        /** Ignite. */
-        @IgniteInstanceResource
-        private Ignite ig;
-
-        /** {@inheritDoc} */
-        @Override public ClusterState call() throws Exception {
-            return ig.cluster().state();
-        }
-    }
-
-    /**
-     *
-     */
     class TransitionOnJoinWaitFuture extends GridFutureAdapter<Boolean> {
         /** */
         private DiscoveryDataClusterState transitionState;
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cluster/ClientClusterGetStateRequest.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cluster/ClientClusterGetStateRequest.java
index cd2270c..e3b96c6 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cluster/ClientClusterGetStateRequest.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cluster/ClientClusterGetStateRequest.java
@@ -45,6 +45,6 @@ public class ClientClusterGetStateRequest extends 
ClientRequest {
 
         return 
ctx.currentProtocolContext().isFeatureSupported(ClientBitmaskFeature.CLUSTER_STATES)
 ?
             new ClientByteResponse(requestId(), (byte)state.ordinal()) :
-            new ClientBooleanResponse(requestId(), ClusterState.active(state));
+            new ClientBooleanResponse(requestId(), state.active());
     }
 }
diff --git a/modules/core/src/main/resources/META-INF/classnames.properties 
b/modules/core/src/main/resources/META-INF/classnames.properties
index ccd6087..fc82e59 100644
--- a/modules/core/src/main/resources/META-INF/classnames.properties
+++ b/modules/core/src/main/resources/META-INF/classnames.properties
@@ -1310,6 +1310,8 @@ 
org.apache.ignite.internal.processors.cluster.BaselineTopologyHistoryItem
 org.apache.ignite.internal.processors.cluster.BranchingPointType
 org.apache.ignite.internal.processors.cluster.ChangeGlobalStateFinishMessage
 org.apache.ignite.internal.processors.cluster.ChangeGlobalStateMessage
+org.apache.ignite.internal.processors.cluster.ClientGetClusterStateComputeRequest
+org.apache.ignite.internal.processors.cluster.ClientSetClusterStateComputeRequest
 org.apache.ignite.internal.processors.cluster.ClusterMetricsUpdateMessage
 org.apache.ignite.internal.processors.cluster.ClusterNodeMetrics
 org.apache.ignite.internal.processors.cluster.ClusterProcessor$4
@@ -1322,9 +1324,6 @@ 
org.apache.ignite.internal.processors.cluster.GridClusterStateProcessor$4
 org.apache.ignite.internal.processors.cluster.GridClusterStateProcessor$5
 org.apache.ignite.internal.processors.cluster.GridClusterStateProcessor$7
 
org.apache.ignite.internal.processors.cluster.GridClusterStateProcessor$BaselineStateAndHistoryData
-org.apache.ignite.internal.processors.cluster.GridClusterStateProcessor$CheckGlobalStateComputeRequest
-org.apache.ignite.internal.processors.cluster.GridClusterStateProcessor$ClientChangeGlobalStateComputeRequest
-org.apache.ignite.internal.processors.cluster.GridClusterStateProcessor$ClientSetGlobalStateComputeRequest
 
org.apache.ignite.internal.processors.cluster.baseline.autoadjust.BaselineAutoAdjustStatus$TaskState
 
org.apache.ignite.internal.processors.configuration.distributed.DetachedPropertyException
 
org.apache.ignite.internal.processors.configuration.distributed.DistributedConfigurationProcessor$AllowableAction
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ClusterActiveStateChangeWithNodeOutOfBaselineTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ClusterActiveStateChangeWithNodeOutOfBaselineTest.java
index 0dfb418..f6d576a 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ClusterActiveStateChangeWithNodeOutOfBaselineTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ClusterActiveStateChangeWithNodeOutOfBaselineTest.java
@@ -29,7 +29,6 @@ import org.junit.Test;
 
 import static org.apache.ignite.cluster.ClusterState.ACTIVE;
 import static org.apache.ignite.cluster.ClusterState.ACTIVE_READ_ONLY;
-import static org.apache.ignite.cluster.ClusterState.active;
 import static org.apache.ignite.testframework.GridTestUtils.assertNotContains;
 
 /**
@@ -69,7 +68,6 @@ public class 
ClusterActiveStateChangeWithNodeOutOfBaselineTest extends GridCommo
         super.afterTestsStopped();
     }
 
-
     /** {@inheritDoc} */
     @Override protected IgniteConfiguration getConfiguration(String 
igniteInstanceName) throws Exception {
         return super.getConfiguration(igniteInstanceName)
@@ -106,8 +104,8 @@ public class 
ClusterActiveStateChangeWithNodeOutOfBaselineTest extends GridCommo
 
     /** */
     private void check(ClusterState initialState, ClusterState targetState) {
-        assertTrue(initialState + "", active(initialState));
-        assertTrue(targetState + "", active(targetState));
+        assertTrue(String.valueOf(initialState), initialState.active());
+        assertTrue(String.valueOf(targetState), targetState.active());
 
         if (grid(0).cluster().state() != initialState)
             grid(0).cluster().state(initialState);
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClusterActivateDeactivateTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClusterActivateDeactivateTest.java
index be0b976..6b3c15c 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClusterActivateDeactivateTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClusterActivateDeactivateTest.java
@@ -48,6 +48,7 @@ import 
org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCluster
 import 
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage;
 import 
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage;
 import org.apache.ignite.internal.processors.cluster.DiscoveryDataClusterState;
+import org.apache.ignite.internal.processors.cluster.GridClusterStateProcessor;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.G;
 import org.apache.ignite.internal.util.typedef.internal.CU;
@@ -65,7 +66,6 @@ import static 
org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
 import static org.apache.ignite.cluster.ClusterState.ACTIVE;
 import static org.apache.ignite.cluster.ClusterState.ACTIVE_READ_ONLY;
 import static org.apache.ignite.cluster.ClusterState.INACTIVE;
-import static org.apache.ignite.cluster.ClusterState.lesserOf;
 import static org.apache.ignite.testframework.GridTestUtils.assertActive;
 import static org.apache.ignite.testframework.GridTestUtils.assertInactive;
 import static 
org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause;
@@ -565,7 +565,7 @@ public class IgniteClusterActivateDeactivateTest extends 
GridCommonAbstractTest
 
         AffinityTopologyVersion affTopVer = new AffinityTopologyVersion(srvs + 
clients);
 
-        if (ClusterState.active(initialState)) {
+        if (initialState.active()) {
             ignite(0).cluster().state(initialState);
 
             awaitPartitionMapExchange();
@@ -717,7 +717,7 @@ public class IgniteClusterActivateDeactivateTest extends 
GridCommonAbstractTest
         activeFut.get();
         startFut.get();
 
-        if (ClusterState.active(targetState))
+        if (targetState.active())
             checkCachesOnNode(nodesCnt - 1, DEFAULT_CACHES_COUNT);
         else {
             checkNoCaches(nodesCnt);
@@ -913,12 +913,12 @@ public class IgniteClusterActivateDeactivateTest extends 
GridCommonAbstractTest
 
         startWithCaches1(srvs, clients);
 
-        if (persistenceEnabled() && ClusterState.active(initialState))
+        if (persistenceEnabled() && initialState.active())
             grid(0).cluster().state(initialState);
 
         checkClusterState(nodesCnt, initialState);
 
-        if (!ClusterState.active(initialState))
+        if (!initialState.active())
             checkNoCaches(nodesCnt);
 
         ignite(changeFrom).cluster().state(initialState); // Should be no-op.
@@ -929,7 +929,7 @@ public class IgniteClusterActivateDeactivateTest extends 
GridCommonAbstractTest
 
         checkClusterState(nodesCnt, targetState);
 
-        if (ClusterState.active(targetState)) {
+        if (targetState.active()) {
             for (int i = 0; i < nodesCnt; i++)
                 checkCachesOnNode(i, DEFAULT_CACHES_COUNT);
 
@@ -941,7 +941,7 @@ public class IgniteClusterActivateDeactivateTest extends 
GridCommonAbstractTest
         startNodeAndCheckCaches(nodesCnt++, false, DEFAULT_CACHES_COUNT);
         startNodeAndCheckCaches(nodesCnt++, true, DEFAULT_CACHES_COUNT);
 
-        if (!ClusterState.active(targetState)) {
+        if (!targetState.active()) {
             checkNoCaches(nodesCnt);
 
             checkClusterState(nodesCnt, targetState);
@@ -965,7 +965,7 @@ public class IgniteClusterActivateDeactivateTest extends 
GridCommonAbstractTest
 
         ClusterState state = grid(0).cluster().state();
 
-        if (ClusterState.active(state)) {
+        if (state.active()) {
             checkCachesOnNode(nodeIdx, cachesCount, !client);
 
             checkCaches(nodeIdx + 1, cachesCount);
@@ -1023,13 +1023,13 @@ public class IgniteClusterActivateDeactivateTest 
extends GridCommonAbstractTest
 
         startWithCaches1(SRVS, CLIENTS);
 
-        if (persistenceEnabled() && ClusterState.active(initialState))
+        if (persistenceEnabled() && initialState.active())
             ignite(0).cluster().state(initialState);
 
         Ignite srv = ignite(0);
         Ignite client = ignite(SRVS);
 
-        if (ClusterState.active(initialState)) {
+        if (initialState.active()) {
             checkCache(client, CU.UTILITY_CACHE_NAME, true);
 
             checkCaches(nodesCnt);
@@ -1039,7 +1039,7 @@ public class IgniteClusterActivateDeactivateTest extends 
GridCommonAbstractTest
 
         IgniteClientReconnectAbstractTest.reconnectClientNode(log, client, 
srv, null);
 
-        if (!ClusterState.active(initialState)) {
+        if (!initialState.active()) {
             checkNoCaches(nodesCnt);
 
             srv.cluster().state(ACTIVE);
@@ -1145,10 +1145,10 @@ public class IgniteClusterActivateDeactivateTest 
extends GridCommonAbstractTest
         final Ignite srv = ignite(0);
         IgniteEx client = grid(SRVS);
 
-        if (persistenceEnabled() && ClusterState.active(initialState))
+        if (persistenceEnabled() && initialState.active())
             ignite(0).cluster().state(initialState);
 
-        if (ClusterState.active(initialState)) {
+        if (initialState.active()) {
             checkCache(client, CU.UTILITY_CACHE_NAME, true);
 
             checkCaches(nodesCnt);
@@ -1188,7 +1188,10 @@ public class IgniteClusterActivateDeactivateTest extends 
GridCommonAbstractTest
             assertTrue(client.context().state().clusterState().transition());
 
             // Public API method would block forever because we blocked the 
exchange message.
-            assertEquals(lesserOf(initialState, targetState), 
client.context().state().publicApiState(false));
+            assertEquals(
+                
GridClusterStateProcessor.stateWithMinimalFeatures(initialState, targetState),
+                client.context().state().publicApiState(false)
+            );
 
             spi1.waitForBlocked();
 
@@ -1197,7 +1200,7 @@ public class IgniteClusterActivateDeactivateTest extends 
GridCommonAbstractTest
             stateFut.get().get();
         }
 
-        if (!ClusterState.active(targetState)) {
+        if (!targetState.active()) {
             checkNoCaches(nodesCnt);
 
             ignite(0).cluster().state(initialState);
@@ -1479,7 +1482,7 @@ public class IgniteClusterActivateDeactivateTest extends 
GridCommonAbstractTest
         for (int i = servers; i < nodesCnt; i++)
             assertEquals(ignite(i).name(), INACTIVE, 
ignite(i).cluster().state());
 
-        ignite(servers).cluster().state(ClusterState.active(initialState) ? 
initialState : targetState);
+        ignite(servers).cluster().state(initialState.active() ? initialState : 
targetState);
 
         doFinalChecks(servers, nodesCnt);
     }
@@ -1530,7 +1533,7 @@ public class IgniteClusterActivateDeactivateTest extends 
GridCommonAbstractTest
         for (int idx : restartNodes)
             startGrid(idx, idx >= servers & idx < (servers + clients));
 
-        if (!ClusterState.active(targetState)) {
+        if (!targetState.active()) {
             checkNoCaches(nodesCnt);
 
             ignite(0).cluster().state(initialState);
@@ -1594,7 +1597,7 @@ public class IgniteClusterActivateDeactivateTest extends 
GridCommonAbstractTest
             () -> {
                 DiscoveryDataClusterState clusterState = 
crd.context().state().clusterState();
 
-                return clusterState.transition() && 
!ClusterState.active(clusterState.state());
+                return clusterState.transition() && 
!clusterState.state().active();
             },
             getTestTimeout()
         ));
@@ -1734,7 +1737,7 @@ public class IgniteClusterActivateDeactivateTest extends 
GridCommonAbstractTest
 
     /** */
     private static void checkStatesAreDifferent(ClusterState state1, 
ClusterState state2) {
-        assertTrue(state1 + " " + state2, ClusterState.active(state1) != 
ClusterState.active(state2));
+        assertTrue(state1 + " " + state2, state1.active() != state2.active());
     }
 
     /** */
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/EvictionPolicyFailureHandlerTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/EvictionPolicyFailureHandlerTest.java
index c6ed0ef..87cca07 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/EvictionPolicyFailureHandlerTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/EvictionPolicyFailureHandlerTest.java
@@ -155,7 +155,7 @@ public class EvictionPolicyFailureHandlerTest extends 
GridCommonAbstractTest {
             .anyMatch(e -> new Double(2.1).equals(e.key().value(null, false)))
         );
 
-        assertTrue(node.cluster().state().active(ACTIVE));
+        assertEquals(ACTIVE, node.cluster().state());
     }
 
     /**
diff --git 
a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java 
b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
index 608c52a..58f0a11 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
@@ -2252,20 +2252,20 @@ public final class GridTestUtils {
      * Checks that {@code state} is active.
      *
      * @param state Passed cluster state.
-     * @see ClusterState#active(ClusterState)
+     * @see ClusterState#active()
      */
     public static void assertActive(ClusterState state) {
-        assertTrue(state + " isn't active state", ClusterState.active(state));
+        assertTrue(state + " isn't active state", state.active());
     }
 
     /**
      * Checks that {@code state} isn't active.
      *
      * @param state Passed cluster state.
-     * @see ClusterState#active(ClusterState)
+     * @see ClusterState#active()
      */
     public static void assertInactive(ClusterState state) {
-        assertFalse(state + " isn't inactive state", 
ClusterState.active(state));
+        assertFalse(state + " isn't inactive state", state.active());
     }
 
     /** Test parameters scale factor util. */

Reply via email to