ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject ignite git commit: IGNITE-6863 Visor CMD: Fixed check that cache available on node.
Date Tue, 14 Nov 2017 02:44:31 GMT
Repository: ignite
Updated Branches:
  refs/heads/master 02ccc9f38 -> e489e372e


IGNITE-6863 Visor CMD: Fixed check that cache available on node.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e489e372
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e489e372
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e489e372

Branch: refs/heads/master
Commit: e489e372ee15812f861a43313e9fa18fbec05a39
Parents: 02ccc9f
Author: vsisko <vsisko@gridgain.com>
Authored: Tue Nov 14 09:44:18 2017 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Tue Nov 14 09:44:18 2017 +0700

----------------------------------------------------------------------
 .../cache/VisorCacheMetricsCollectorTask.java   |  5 ++-
 .../visor/node/VisorGridConfiguration.java      |  6 ++-
 .../commands/cache/VisorCacheCommandSpec.scala  | 44 +++++++++++++++-----
 3 files changed, 42 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e489e372/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetricsCollectorTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetricsCollectorTask.java
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetricsCollectorTask.java
index 8ce3c8c..ab1fa8c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetricsCollectorTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetricsCollectorTask.java
@@ -22,6 +22,7 @@ import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import org.apache.ignite.compute.ComputeJobResult;
+import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.GridCacheProcessor;
 import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
 import org.apache.ignite.internal.processors.task.GridInternal;
@@ -109,7 +110,9 @@ public class VisorCacheMetricsCollectorTask extends VisorMultiNodeTask<VisorCach
             boolean allCaches = cacheNames.isEmpty();
 
             for (IgniteCacheProxy ca : caches) {
-                if (ca.context().started()) {
+                GridCacheContext ctx = ca.context();
+
+                if (ctx.started() && (ctx.affinityNode() || ctx.isNear())) {
                     String cacheName = ca.getName();
 
                     VisorCacheMetrics cm = new VisorCacheMetrics(ignite, cacheName);

http://git-wip-us.apache.org/repos/asf/ignite/blob/e489e372/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java
b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java
index 9e2370c..85849a5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java
@@ -27,6 +27,7 @@ import java.util.Properties;
 import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.configuration.BinaryConfiguration;
 import org.apache.ignite.configuration.ClientConnectorConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
 import org.apache.ignite.configuration.HadoopConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.IgniteEx;
@@ -187,7 +188,10 @@ public class VisorGridConfiguration extends VisorDataTransferObject {
 
         srvcCfgs = VisorServiceConfiguration.list(c.getServiceConfiguration());
 
-        dataStorage = new VisorDataStorageConfiguration(c.getDataStorageConfiguration());
+        DataStorageConfiguration dsCfg = c.getDataStorageConfiguration();
+
+        if (dsCfg != null)
+            dataStorage = new VisorDataStorageConfiguration(dsCfg);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/e489e372/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommandSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommandSpec.scala
b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommandSpec.scala
index 384aae0..d2c3711 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommandSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommandSpec.scala
@@ -17,25 +17,35 @@
 
 package org.apache.ignite.visor.commands.cache
 
+import java.lang.{Integer => JavaInt}
+import java.util.{Collections, List => JavaList}
+
 import org.apache.ignite.Ignition
 import org.apache.ignite.cache.CacheAtomicityMode._
 import org.apache.ignite.cache.CacheMode._
 import org.apache.ignite.cache.query.SqlQuery
 import org.apache.ignite.cache.query.annotations.QuerySqlField
 import org.apache.ignite.configuration._
+import org.apache.ignite.internal.visor.cache._
 import org.apache.ignite.spi.discovery.tcp._
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm._
-
-import java.lang.{Integer => JavaInt}
-import org.jetbrains.annotations._
-
+import org.apache.ignite.util.AttributeNodeFilter
 import org.apache.ignite.visor._
 import org.apache.ignite.visor.commands.cache.VisorCacheCommand._
+import org.apache.ignite.visor.visor.executeMulti
+import org.jetbrains.annotations._
+
+import scala.collection.JavaConversions._
 
 /**
  * Unit test for 'events' command.
  */
-class VisorCacheCommandSpec extends VisorRuntimeBaseSpec(1) {
+class VisorCacheCommandSpec extends VisorRuntimeBaseSpec(2) {
+    /** */
+    val CACHE_NAME = "replicated"
+
+    /** */
+    val FILTER_ATTRIBUTE_NAME = "NAME"
 
     /** IP finder. */
     val ipFinder = new TcpDiscoveryVmIpFinder(true)
@@ -47,9 +57,11 @@ class VisorCacheCommandSpec extends VisorRuntimeBaseSpec(1) {
     def cacheConfig(@NotNull name: String): CacheConfiguration[Object, Object] = {
         val cfg = new CacheConfiguration[Object, Object]
 
+        cfg.setName(name)
         cfg.setCacheMode(REPLICATED)
         cfg.setAtomicityMode(TRANSACTIONAL)
-        cfg.setName(name)
+
+        cfg.setNodeFilter(new AttributeNodeFilter(FILTER_ATTRIBUTE_NAME, "node-1"))
 
         val arr = Seq(classOf[JavaInt], classOf[Foo]).toArray
 
@@ -64,19 +76,18 @@ class VisorCacheCommandSpec extends VisorRuntimeBaseSpec(1) {
      * @param name Ignite instance name.
      * @return Grid configuration.
      */
-    override def config(name: String): IgniteConfiguration =
-    {
-        val cfg = new IgniteConfiguration
+    override def config(name: String): IgniteConfiguration = {
+        val cfg = super.config(name)
 
-        cfg.setIgniteInstanceName(name)
         cfg.setLocalHost("127.0.0.1")
-        cfg.setCacheConfiguration(cacheConfig("replicated"))
+        cfg.setCacheConfiguration(cacheConfig(CACHE_NAME))
 
         val discoSpi = new TcpDiscoverySpi()
 
         discoSpi.setIpFinder(ipFinder)
 
         cfg.setDiscoverySpi(discoSpi)
+        cfg.setUserAttributes(Collections.singletonMap(FILTER_ATTRIBUTE_NAME, name))
 
         cfg
     }
@@ -130,6 +141,17 @@ class VisorCacheCommandSpec extends VisorRuntimeBaseSpec(1) {
         it("should scan cache") {
             visor cache "-c=replicated -scan"
         }
+
+        it("should get metrics for nodes available by cache node filter") {
+            val caches: JavaList[String] = Collections.singletonList(CACHE_NAME)
+
+            val arg = new VisorCacheMetricsCollectorTaskArg(false, caches)
+
+            val metrics = executeMulti(classOf[VisorCacheMetricsCollectorTask], arg).toList
+
+            assert(metrics.size == 1)
+            assert(metrics.head.getNodes.size() == 1)
+        }
     }
 }
 


Mime
View raw message