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

ilyak 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 aa93762  IGNITE-6796 Use CheckGlobalStateComputeRequest in place of 
GridClusterStateProcessor$5.
aa93762 is described below

commit aa93762a8efc4d76795676cf106ccf6b880ea739
Author: akorensh <[email protected]>
AuthorDate: Mon Jul 29 16:53:41 2019 +0300

    IGNITE-6796 Use CheckGlobalStateComputeRequest in place of 
GridClusterStateProcessor$5.
    
    Add @GridInternal annotation to CheckGlobalStateComputeRequest.
    
    Fixes #6720.
    
    Signed-off-by: Ilya Kasnacheev <[email protected]>
---
 .../cluster/GridClusterStateProcessor.java         | 10 +---
 ...rocessorCheckGlobalStateComputeRequestTest.java | 69 ++++++++++++++++++++++
 .../ignite/testsuites/IgniteBasicTestSuite.java    |  2 +
 3 files changed, 73 insertions(+), 8 deletions(-)

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 8268711..7591103 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
@@ -1189,14 +1189,7 @@ public class GridClusterStateProcessor extends 
GridProcessorAdapter implements I
 
         IgniteCompute comp = clusterGroupAdapter.compute();
 
-        return comp.callAsync(new IgniteCallable<Boolean>() {
-            @IgniteInstanceResource
-            private Ignite ig;
-
-            @Override public Boolean call() throws Exception {
-                return ig.active();
-            }
-        });
+        return comp.callAsync(new CheckGlobalStateComputeRequest());
     }
 
     /** {@inheritDoc} */
@@ -1813,6 +1806,7 @@ public class GridClusterStateProcessor extends 
GridProcessorAdapter implements I
     /**
      *
      */
+    @GridInternal
     private static class CheckGlobalStateComputeRequest implements 
IgniteCallable<Boolean> {
         /** */
         private static final long serialVersionUID = 0L;
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/ClusterProcessorCheckGlobalStateComputeRequestTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/ClusterProcessorCheckGlobalStateComputeRequestTest.java
new file mode 100644
index 0000000..89d17b2
--- /dev/null
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/ClusterProcessorCheckGlobalStateComputeRequestTest.java
@@ -0,0 +1,69 @@
+/*
+ * 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;
+
+import javax.management.ObjectName;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+/**
+ * Tests that the GridInternal annotation for 
GridClusterStateProcessor.CheckGlobalStateComputeRequest works correctly.
+ */
+public class ClusterProcessorCheckGlobalStateComputeRequestTest extends 
GridCommonAbstractTest {
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String 
igniteInstanceName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+        if(igniteInstanceName.equalsIgnoreCase("daemon"))
+            cfg.setDaemon(true);
+
+        return cfg;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    @Test
+    public void testCheckGlobalStateComputeRequest() throws Exception {
+        startGrids(1);
+        IgniteEx daemon = startGrid("daemon");
+
+        // GridInternal annotation will cause the job and response message to 
execute on management pool.
+        for(int i = 0; i < 100; i++)
+            daemon.cluster().active();
+
+        checkBeanAttribute(daemon, "Thread Pools", "GridManagementExecutor", 
"TaskCount", 100L);
+
+        for(int i = 0; i < 100; i++)
+            grid(0).cluster().active();
+
+        checkBeanAttribute(grid(0), "Thread Pools", "GridManagementExecutor", 
"TaskCount", 100L);
+    }
+
+    /**
+     * Checks that a bean with the specified group and name is available and 
has the expected attribute
+     */
+    private void checkBeanAttribute(Ignite ignite, String grp, String name, 
String attributeName, Object expAttributeVal) throws Exception {
+        ObjectName mBeanName = IgniteUtils.makeMBeanName(ignite.name(), grp, 
name);
+        Object attributeVal = 
ignite.configuration().getMBeanServer().getAttribute(mBeanName, attributeName);
+
+        assertEquals(expAttributeVal, attributeVal);
+    }
+}
diff --git 
a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
 
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
index 50bfa02..3d5bfe2 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
@@ -26,6 +26,7 @@ import 
org.apache.ignite.failure.StopNodeOrHaltFailureHandlerTest;
 import org.apache.ignite.internal.ClassSetTest;
 import org.apache.ignite.internal.ClusterGroupHostsSelfTest;
 import org.apache.ignite.internal.ClusterGroupSelfTest;
+import 
org.apache.ignite.internal.ClusterProcessorCheckGlobalStateComputeRequestTest;
 import org.apache.ignite.internal.ConsistentIdImplicitlyExplicitlyTest;
 import org.apache.ignite.internal.GridFailFastNodeFailureDetectionSelfTest;
 import org.apache.ignite.internal.GridLifecycleAwareSelfTest;
@@ -134,6 +135,7 @@ import org.junit.runners.Suite;
     IgniteMessagingWithClientTest.class,
     IgniteMessagingSendAsyncTest.class,
 
+    ClusterProcessorCheckGlobalStateComputeRequestTest.class,
     ClusterGroupSelfTest.class,
     GridMessagingSelfTest.class,
     GridMessagingNoPeerClassLoadingSelfTest.class,

Reply via email to