ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject [38/38] incubator-ignite git commit: # GG-9945 Review.
Date Thu, 02 Apr 2015 07:45:21 GMT
# GG-9945 Review.


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

Branch: refs/heads/ignite-639
Commit: bdea1a22571c12918cebbfe330da26a5e866b692
Parents: 5e0050c
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Thu Apr 2 14:44:46 2015 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Thu Apr 2 14:44:46 2015 +0700

----------------------------------------------------------------------
 .../cache/VisorCacheMetricsCollectorTask.java   | 75 ++++++--------------
 .../commands/cache/VisorCacheCommand.scala      | 10 ++-
 2 files changed, 29 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bdea1a22/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 f29d47a..e4495aa 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
@@ -20,27 +20,24 @@ package org.apache.ignite.internal.visor.cache;
 import org.apache.ignite.compute.*;
 import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.internal.processors.task.*;
-import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.internal.visor.*;
 import org.apache.ignite.lang.*;
 import org.jetbrains.annotations.*;
 
-import java.io.*;
 import java.util.*;
 
 /**
  * Task that collect cache metrics from all nodes.
  */
 @GridInternal
-public class VisorCacheMetricsCollectorTask extends VisorMultiNodeTask<
-    VisorCacheMetricsCollectorTask.VisorCacheMetricsCollectorArg, Iterable<VisorCacheAggregatedMetrics>,
-    Map<String, VisorCacheMetrics>> {
+public class VisorCacheMetricsCollectorTask extends VisorMultiNodeTask<IgniteBiTuple<Boolean,
Collection<String>>,
+    Iterable<VisorCacheAggregatedMetrics>, Map<String, VisorCacheMetrics>>
{
     /** */
     private static final long serialVersionUID = 0L;
 
     /** {@inheritDoc} */
-    @Override protected VisorCacheMetricsCollectorJob job(VisorCacheMetricsCollectorArg arg)
{
+    @Override protected VisorCacheMetricsCollectorJob job(IgniteBiTuple<Boolean, Collection<String>>
arg) {
         return new VisorCacheMetricsCollectorJob(arg, debug);
     }
 
@@ -74,7 +71,7 @@ public class VisorCacheMetricsCollectorTask extends VisorMultiNodeTask<
      * Job that collect cache metrics from node.
      */
     private static class VisorCacheMetricsCollectorJob
-        extends VisorJob<VisorCacheMetricsCollectorArg, Map<String, VisorCacheMetrics>>
{
+        extends VisorJob<IgniteBiTuple<Boolean, Collection<String>>, Map<String,
VisorCacheMetrics>> {
         /** */
         private static final long serialVersionUID = 0L;
 
@@ -84,15 +81,14 @@ public class VisorCacheMetricsCollectorTask extends VisorMultiNodeTask<
          * @param arg Whether to collect metrics for all caches or for specified cache name
only.
          * @param debug Debug flag.
          */
-        private VisorCacheMetricsCollectorJob(VisorCacheMetricsCollectorArg arg, boolean
debug) {
+        private VisorCacheMetricsCollectorJob(IgniteBiTuple<Boolean, Collection<String>>
arg, boolean debug) {
             super(arg, debug);
         }
 
         /** {@inheritDoc} */
-        @Override protected Map<String, VisorCacheMetrics> run(final VisorCacheMetricsCollectorArg
arg) {
-            Collection<? extends GridCache<?, ?>> caches = arg.allCaches
-                ? ignite.cachesx(new VisorSystemCachesPredicate(arg.systemCaches))
-                : F.asList(ignite.cachex(arg.cacheName));
+        @Override protected Map<String, VisorCacheMetrics> run(final IgniteBiTuple<Boolean,
Collection<String>> arg) {
+            Collection<? extends GridCache<?, ?>> caches =
+                ignite.cachesx(new VisorCachesFilterPredicate(arg.get1(), arg.get2()));
 
             if (caches != null) {
                 Map<String, VisorCacheMetrics> res = U.newHashMap(caches.size());
@@ -113,57 +109,30 @@ public class VisorCacheMetricsCollectorTask extends VisorMultiNodeTask<
     }
 
     /**
-     * Arguments for {@link VisorCacheMetricsCollectorTask}.
+     * Predicate to filter required caches.
      */
-    @SuppressWarnings("PublicInnerClass")
-    public static class VisorCacheMetricsCollectorArg implements Serializable {
-        /** Collect metrics for all caches. */
-        private final Boolean allCaches;
-
-        /** Include system cache metrics. */
-        private final Boolean systemCaches;
+    private static class VisorCachesFilterPredicate implements IgnitePredicate<GridCache<?,?>>
{
+        /** Select system caches. */
+        private final Boolean showSystem;
 
-        /** Collect metrics for cache with name only. */
-        private final String cacheName;
+        /** Name of caches for selection */
+        private final Collection<String> names;
 
         /**
-         * Create task arguments with given parameters.
+         * Create cache filtration predicate.
          *
-         * @param allCaches Collect metrics for all caches.
-         * @param systemCaches Include system cache metrics.
-         * @param cacheName Collect metrics for cache with name only.
+         * @param showSystem Select system caches.
+         * @param names Name of caches for selection.
          */
-        public VisorCacheMetricsCollectorArg(Boolean allCaches, Boolean systemCaches, String
cacheName) {
-            this.allCaches = allCaches;
-            this.systemCaches = systemCaches;
-            this.cacheName = cacheName;
-        }
-
-        /** @return Collect metrics for all caches. */
-        public Boolean allCaches() {
-            return allCaches;
-        }
-
-        /** @return Include system cache metrics. */
-        public Boolean systemCaches() {
-            return systemCaches;
-        }
-
-        /** @return Collect metrics for cache with name only. */
-        public String cacheName() {
-            return cacheName;
-        }
-    }
-
-    private static class VisorSystemCachesPredicate implements IgnitePredicate<GridCache<?,?>>
{
-        private final Boolean showSystem;
-
-        VisorSystemCachesPredicate(Boolean showSystem) {
+        VisorCachesFilterPredicate(Boolean showSystem, Collection<String> names) {
             this.showSystem = showSystem;
+            this.names = names;
         }
 
+        /** {@inheritDoc} */
         @Override public boolean apply(GridCache<?, ?> cache) {
-            return showSystem || !CU.isSystemCache(cache.name());
+            return (showSystem || !CU.isSystemCache(cache.name()))
+                && (names == null || names.isEmpty() || names.contains(cache.name()));
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bdea1a22/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala
b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala
index 53792f1..3ced9b8 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala
@@ -21,6 +21,7 @@ import org.apache.ignite._
 import org.apache.ignite.cluster.ClusterNode
 import org.apache.ignite.internal.processors.cache.{GridCacheUtils => CU}
 import org.apache.ignite.internal.util.typedef._
+import org.apache.ignite.lang.IgniteBiTuple
 import org.apache.ignite.visor.VisorTag
 import org.apache.ignite.visor.commands.cache.VisorCacheCommand._
 import org.apache.ignite.visor.commands.{VisorConsoleCommand, VisorTextTable}
@@ -29,9 +30,9 @@ import org.apache.ignite.visor.visor._
 import org.jetbrains.annotations._
 
 import java.lang.{Boolean => JavaBoolean}
+import java.util.{ArrayList => JavaList, Collection => JavaCollection}
 import java.util.UUID
 
-import org.apache.ignite.internal.visor.cache.VisorCacheMetricsCollectorTask.VisorCacheMetricsCollectorArg
 import org.apache.ignite.internal.visor.cache._
 import org.apache.ignite.internal.visor.node.{VisorGridConfiguration, VisorNodeConfigurationCollectorTask}
 import org.apache.ignite.internal.visor.util.VisorTaskUtils._
@@ -493,8 +494,11 @@ class VisorCacheCommand {
 
             val nids = prj.nodes().map(_.id())
 
+            val caches = new JavaList[String](1)
+            name.foreach(caches.add)
+
             ignite.compute(prj).execute(classOf[VisorCacheMetricsCollectorTask], toTaskArgument(nids,
-                new VisorCacheMetricsCollectorArg(JavaBoolean.valueOf(name.isEmpty), systemCaches,
name.orNull))).toList
+                new IgniteBiTuple(JavaBoolean.valueOf(systemCaches), caches.asInstanceOf[JavaCollection[String]]))).toList
         }
         catch {
             case e: IgniteException => Nil
@@ -502,7 +506,7 @@ class VisorCacheCommand {
     }
 
     /**
-     * Gets configuration of grid from specified node for callecting of node cache's configuration.
+     * Gets configuration of grid from specified node for collecting of node cache's configuration.
      *
      * @param node Specified node.
      * @return Grid configuration for specified node.


Mime
View raw message