Merge branches 'ignite-639' and 'ignite-sprint-3' of 
https://github.com/ggprivate/ggprivate into ignite-639

Conflicts:
        
modules/visor-tester/src/main/scala/org/gridgain/visor/tester/VisorCmptbTesterLauncherBase.scala


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

Branch: refs/heads/ignite-437-sqltests-p2
Commit: 349c200d11e2c961a503b368a566e6bd5345590a
Parents: b189877
Author: AKuznetsov <akuznet...@gridgain.com>
Authored: Tue Apr 7 09:17:16 2015 +0700
Committer: AKuznetsov <akuznet...@gridgain.com>
Committed: Tue Apr 7 09:17:16 2015 +0700

----------------------------------------------------------------------
 .../cache/VisorCacheAggregatedMetrics.java      | 21 +++++++++++-
 .../cache/VisorCacheMetricsCollectorTask.java   | 25 +++++++++-----
 .../commands/cache/VisorCacheCommand.scala      | 26 +++++++-------
 .../commands/cache/VisorCacheStopCommand.scala  | 36 +++++++++++++-------
 4 files changed, 72 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/349c200d/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAggregatedMetrics.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAggregatedMetrics.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAggregatedMetrics.java
index 076a19b..c8d3a8d 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAggregatedMetrics.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAggregatedMetrics.java
@@ -17,6 +17,7 @@
 
 package org.apache.ignite.internal.visor.cache;
 
+import org.apache.ignite.cache.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 
 import java.io.*;
@@ -32,6 +33,12 @@ public class VisorCacheAggregatedMetrics implements 
Serializable {
     /** Cache name. */
     private final String cacheName;
 
+    /** Cache mode. */
+    private final CacheMode cacheMode;
+
+    /** Cache system state. */
+    private final Boolean system;
+
     /** Node IDs with cache metrics. */
     private final Map<UUID, VisorCacheMetrics> metrics = new HashMap<>();
 
@@ -103,8 +110,10 @@ public class VisorCacheAggregatedMetrics implements 
Serializable {
      *
      * @param cacheName Cache name.
      */
-    public VisorCacheAggregatedMetrics(String cacheName) {
+    public VisorCacheAggregatedMetrics(String cacheName, CacheMode cacheMode, 
Boolean system) {
         this.cacheName = cacheName;
+        this.cacheMode = cacheMode;
+        this.system = system;
     }
 
     /**
@@ -114,6 +123,16 @@ public class VisorCacheAggregatedMetrics implements 
Serializable {
         return cacheName;
     }
 
+    /** @return Cache mode. */
+    public CacheMode cacheMode() {
+        return cacheMode;
+    }
+
+    /** @return Cache system state. */
+    public Boolean system() {
+        return system;
+    }
+
     /**
      * @return Nodes.
      */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/349c200d/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 615935a..99b29c0 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
@@ -32,7 +32,7 @@ import java.util.*;
  */
 @GridInternal
 public class VisorCacheMetricsCollectorTask extends 
VisorMultiNodeTask<IgniteBiTuple<Boolean, Collection<String>>,
-    Iterable<VisorCacheAggregatedMetrics>, Map<String, VisorCacheMetrics>> {
+    Iterable<VisorCacheAggregatedMetrics>, Map<String, IgniteBiTuple<Boolean, 
VisorCacheMetrics>>> {
     /** */
     private static final long serialVersionUID = 0L;
 
@@ -47,18 +47,23 @@ public class VisorCacheMetricsCollectorTask extends 
VisorMultiNodeTask<IgniteBiT
 
         for (ComputeJobResult res : results) {
             if (res.getException() == null && res.getData() instanceof Map<?, 
?>) {
-                Map<String, VisorCacheMetrics> cms = res.getData();
+                Map<String, IgniteBiTuple<Boolean, VisorCacheMetrics>> cms = 
res.getData();
 
-                for (Map.Entry<String, VisorCacheMetrics> entry : 
cms.entrySet()) {
+                for (Map.Entry<String, IgniteBiTuple<Boolean, 
VisorCacheMetrics>> entry : cms.entrySet()) {
                     VisorCacheAggregatedMetrics am = 
grpAggrMetrics.get(entry.getKey());
 
                     if (am == null) {
-                        am = new VisorCacheAggregatedMetrics(entry.getKey());
+                        String cacheName = entry.getKey();
+
+                        GridCacheProcessor proc = ignite.context().cache();
+
+                        am = new VisorCacheAggregatedMetrics(cacheName, 
proc.cacheMode(cacheName),
+                            entry.getValue().get1());
 
                         grpAggrMetrics.put(entry.getKey(), am);
                     }
 
-                    am.metrics().put(res.getNode().id(), entry.getValue());
+                    am.metrics().put(res.getNode().id(), 
entry.getValue().get2());
                 }
             }
         }
@@ -71,7 +76,7 @@ public class VisorCacheMetricsCollectorTask extends 
VisorMultiNodeTask<IgniteBiT
      * Job that collect cache metrics from node.
      */
     private static class VisorCacheMetricsCollectorJob
-        extends VisorJob<IgniteBiTuple<Boolean, Collection<String>>, 
Map<String, VisorCacheMetrics>> {
+        extends VisorJob<IgniteBiTuple<Boolean, Collection<String>>, 
Map<String, IgniteBiTuple<Boolean, VisorCacheMetrics>>> {
         /** */
         private static final long serialVersionUID = 0L;
 
@@ -86,7 +91,8 @@ public class VisorCacheMetricsCollectorTask extends 
VisorMultiNodeTask<IgniteBiT
         }
 
         /** {@inheritDoc} */
-        @Override protected Map<String, VisorCacheMetrics> run(final 
IgniteBiTuple<Boolean, Collection<String>> arg) {
+        @Override protected Map<String, IgniteBiTuple<Boolean, 
VisorCacheMetrics>> run(
+            final IgniteBiTuple<Boolean, Collection<String>> arg) {
             assert arg != null;
 
             Boolean showSysCaches = arg.get1();
@@ -101,7 +107,7 @@ public class VisorCacheMetricsCollectorTask extends 
VisorMultiNodeTask<IgniteBiT
 
             Collection<GridCacheAdapter<?, ?>> caches = 
cacheProcessor.internalCaches();
 
-            Map<String, VisorCacheMetrics> res = U.newHashMap(caches.size());
+            Map<String, IgniteBiTuple<Boolean, VisorCacheMetrics>> res = 
U.newHashMap(caches.size());
 
             boolean allCaches = cacheNames.isEmpty();
 
@@ -110,7 +116,8 @@ public class VisorCacheMetricsCollectorTask extends 
VisorMultiNodeTask<IgniteBiT
                     String name = ca.name();
 
                     if ((showSysCaches && cacheProcessor.systemCache(name)) || 
allCaches || cacheNames.contains(name))
-                        res.put(name, VisorCacheMetrics.from(ca));
+                        res.put(name, new IgniteBiTuple<Boolean, 
VisorCacheMetrics>(
+                            ignite.context().cache().systemCache(name), 
VisorCacheMetrics.from(ca)));
                 }
             }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/349c200d/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 bd0d251..33a2a16 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
@@ -30,8 +30,7 @@ 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 java.util.{ArrayList => JavaList, Collection => JavaCollection, UUID}
 
 import org.apache.ignite.internal.visor.cache._
 import org.apache.ignite.internal.visor.node.{VisorGridConfiguration, 
VisorNodeConfigurationCollectorTask}
@@ -259,9 +258,13 @@ class VisorCacheCommand {
                 flags.exists(hasArgFlag(_, argLst))
             }
 
+            // Get cache stats data from all nodes.
+            val aggrData = cacheData(node, cacheName, showSystem)
+
             if (hasArgFlagIn("clear", "swap", "scan", "stop")) {
                 if (cacheName.isEmpty)
-                    askForCache("Select cache from:", node, showSystem && 
!hasArgFlagIn("clear", "swap", "stop")) match {
+                    askForCache("Select cache from:", node, showSystem && 
!hasArgFlagIn("clear", "swap", "stop"),
+                        aggrData) match {
                         case Some(name) =>
                             argLst = argLst ++ Seq("c" -> name)
 
@@ -274,7 +277,7 @@ class VisorCacheCommand {
                     if (hasArgFlag("scan", argLst))
                         VisorCacheScanCommand().scan(argLst, node)
                     else {
-                        if (!CU.isSystemCache(name)) {
+                        if (!aggrData.exists(cache => cache.cacheName() == 
name && cache.system())) {
                             if (hasArgFlag("clear", argLst))
                                 VisorCacheClearCommand().clear(argLst, node)
                             else if (hasArgFlag("swap", argLst))
@@ -304,9 +307,6 @@ class VisorCacheCommand {
             if (sortType.isDefined && !isValidSortType(sortType.get))
                 scold("Invalid '-s' argument in: " + args).^^
 
-            // Get cache stats data from all nodes.
-            val aggrData = cacheData(node, cacheName, showSystem)
-
             if (aggrData.isEmpty)
                 scold("No caches found.").^^
 
@@ -314,7 +314,7 @@ class VisorCacheCommand {
 
             val sumT = VisorTextTable()
 
-            sumT #= ("Name(@)", "Nodes", "Entries", "Hits", "Misses", "Reads", 
"Writes")
+            sumT #= ("Name(@)", "Mode", "Nodes", "Entries", "Hits", "Misses", 
"Reads", "Writes")
 
             sortAggregatedData(aggrData, sortType.getOrElse("cn"), 
reversed).foreach(
                 ad => {
@@ -323,6 +323,7 @@ class VisorCacheCommand {
 
                     sumT += (
                         mkCacheName(ad.cacheName),
+                        ad.cacheMode(),
                         ad.nodes,
                         (
                             "min: " + ad.minimumSize,
@@ -598,13 +599,11 @@ class VisorCacheCommand {
      * @param showSystem Allow selection of system caches.
      * @return `Option` for ID of selected cache.
      */
-    def askForCache(title: String, node: Option[ClusterNode], showSystem: 
Boolean = false): Option[String] = {
+    def askForCache(title: String, node: Option[ClusterNode], showSystem: 
Boolean = false,
+        aggrData: Seq[VisorCacheAggregatedMetrics]): Option[String] = {
         assert(title != null)
         assert(visor.visor.isConnected)
 
-        // Get cache stats data from all nodes.
-        val aggrData = cacheData(node, None, showSystem)
-
         if (aggrData.isEmpty)
             scold("No caches found.").^^
 
@@ -614,7 +613,7 @@ class VisorCacheCommand {
 
         val sumT = VisorTextTable()
 
-        sumT #= ("#", "Name(@)", "Nodes", "Size")
+        sumT #= ("#", "Name(@)", "Mode", "Nodes", "Size")
 
         (0 until sortedAggrData.size) foreach (i => {
             val ad = sortedAggrData(i)
@@ -625,6 +624,7 @@ class VisorCacheCommand {
             sumT += (
                 i,
                 mkCacheName(ad.cacheName),
+                ad.cacheMode(),
                 ad.nodes,
                 (
                     "min: " + ad.minimumSize,

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/349c200d/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheStopCommand.scala
----------------------------------------------------------------------
diff --git 
a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheStopCommand.scala
 
b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheStopCommand.scala
index 4c1aa10..cf344e6 100644
--- 
a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheStopCommand.scala
+++ 
b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheStopCommand.scala
@@ -19,9 +19,9 @@ package org.apache.ignite.visor.commands.cache
 
 import org.apache.ignite.cluster.ClusterNode
 import org.apache.ignite.visor.visor._
-import org.apache.ignite.internal.visor.util.VisorTaskUtils._
 
 import org.apache.ignite.internal.visor.cache.VisorCacheStopTask
+import org.apache.ignite.internal.visor.util.VisorTaskUtils._
 
 /**
  * ==Overview==
@@ -105,21 +105,31 @@ class VisorCacheStopCommand {
             return
         }
 
-        val stopPrj = cachePrj.forRandom()
+        ask(s"Are you sure you want to stop cache: ${escapeName(cacheName)}? 
(y/n) [n]: ", "n") match {
+            case "y" | "Y" =>
+                val stopPrj = cachePrj.forRandom()
 
-        val nid = stopPrj.node().id()
+                val nid = stopPrj.node().id()
 
-        try {
-            ignite.compute(stopPrj)
-                .withName("visor-cstop-task")
-                .withNoFailover()
-                .execute(classOf[VisorCacheStopTask], toTaskArgument(nid, 
cacheName))
+                try {
+                    ignite.compute(stopPrj)
+                        .withName("visor-cstop-task")
+                        .withNoFailover()
+                        .execute(classOf[VisorCacheStopTask], 
toTaskArgument(nid, cacheName))
 
-            println("Visor successfully stop cache: " + escapeName(cacheName))
-        }
-        catch {
-            case e: Exception =>
-                error(e)
+                    println("Visor successfully stop cache: " + 
escapeName(cacheName))
+                }
+                catch {
+                    case e: Exception =>
+                        error(e)
+                }
+
+            case "n" | "N" =>
+
+            case x =>
+                nl()
+
+                warn("Invalid answer: " + x)
         }
     }
 }

Reply via email to