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

namelchev 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 fe920299f0a IGNITE-18726 Fixed state-changed message on same cluster 
state. (#10522)
fe920299f0a is described below

commit fe920299f0a656e4b99557dde2a8d9664835a132
Author: Vladimir Steshin <[email protected]>
AuthorDate: Wed Feb 8 10:15:27 2023 +0300

    IGNITE-18726 Fixed state-changed message on same cluster state. (#10522)
---
 .../ignite/internal/commandline/ClusterStateChangeCommand.java | 10 ++++++++--
 .../java/org/apache/ignite/util/GridCommandHandlerTest.java    |  9 +++++++--
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git 
a/modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/ClusterStateChangeCommand.java
 
b/modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/ClusterStateChangeCommand.java
index fe8c398751b..fd540435bca 100644
--- 
a/modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/ClusterStateChangeCommand.java
+++ 
b/modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/ClusterStateChangeCommand.java
@@ -75,9 +75,15 @@ public class ClusterStateChangeCommand extends 
AbstractCommand<ClusterState> {
     /** {@inheritDoc} */
     @Override public Object execute(GridClientConfiguration clientCfg, 
IgniteLogger log) throws Exception {
         try (GridClient client = Command.startClient(clientCfg)) {
-            client.state().state(state, forceDeactivation);
+            ClusterState clusterState = client.state().state();
 
-            log.info("Cluster state changed to " + state);
+            if (clusterState == state)
+                log.info("Cluster state is already " + state + '.');
+            else {
+                client.state().state(state, forceDeactivation);
+
+                log.info("Cluster state changed to " + state + '.');
+            }
 
             return null;
         }
diff --git 
a/modules/control-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerTest.java
 
b/modules/control-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerTest.java
index 6e7ce81374e..cd9c76b2e62 100644
--- 
a/modules/control-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerTest.java
+++ 
b/modules/control-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerTest.java
@@ -977,7 +977,9 @@ public class GridCommandHandlerTest extends 
GridCommandHandlerClusterPerMethodAb
 
     /** */
     private void setState(Ignite ignite, ClusterState state, String strState, 
String... cacheNames) throws Exception {
-        log.info(ignite.cluster().state() + " -> " + state);
+        ClusterState curState = ignite.cluster().state();
+
+        log.info(curState + " -> " + state);
 
         CountDownLatch latch = getNewStateLatch(ignite.cluster().state(), 
state);
 
@@ -990,7 +992,10 @@ public class GridCommandHandlerTest extends 
GridCommandHandlerClusterPerMethodAb
 
         assertEquals(state, ignite.cluster().state());
 
-        assertContains(log, testOut.toString(), "Cluster state changed to " + 
strState);
+        if (state == curState)
+            assertContains(log, testOut.toString(), "Cluster state is already 
" + strState);
+        else
+            assertContains(log, testOut.toString(), "Cluster state changed to 
" + strState);
 
         List<IgniteEx> nodes = IntStream.range(0, 2)
             .mapToObj(this::grid)

Reply via email to