ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anovi...@apache.org
Subject [2/2] ignite git commit: IGNITE-1943 Review.
Date Tue, 24 Jan 2017 08:25:12 GMT
IGNITE-1943 Review.


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

Branch: refs/heads/master
Commit: c42b50cfa0ff992debe773307a7cf25ecc141a31
Parents: 24e14b6
Author: Andrey Novikov <anovikov@gridgain.com>
Authored: Tue Jan 24 15:15:48 2017 +0700
Committer: Andrey Novikov <anovikov@gridgain.com>
Committed: Tue Jan 24 15:23:46 2017 +0700

----------------------------------------------------------------------
 .../scala/org/apache/ignite/visor/visor.scala   | 39 ++++++++------------
 .../commands/mem/VisorMemoryCommandSpec.scala   | 25 +++++++++++--
 .../commands/node/VisorNodeCommandSpec.scala    | 10 -----
 3 files changed, 38 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/c42b50cf/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
index 0aa8549..e4e7918 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
@@ -352,16 +352,16 @@ object visor extends VisorTag {
 
     addHelp(
         name = "mcompact",
-        shortInfo = "Fills gap in Visor console memory variable.",
+        shortInfo = "Fills gap in Visor console memory variables.",
         longInfo = Seq(
-            "Finds and fills gap in Visor console memory variable."
+            "Finds and fills gap in Visor console memory variables."
         ),
         spec = Seq(
             "mcompact"
         ),
         examples = Seq(
             "mcompact" ->
-                "Fills gap in Visor console memory variable."
+                "Fills gap in Visor console memory variables."
         ),
         emptyArgs = mcompact,
         withArgs = _ => wrongArgs("mcompact")
@@ -597,22 +597,22 @@ object visor extends VisorTag {
 
     /**
       * ==Command==
-      * Fills gap in Visor console memory variable.
+      * Fills gap in Visor console memory variables.
       *
       * ==Examples==
       * <ex>mcompact</ex>
-      * Fills gap in Visor console memory variable.
+      * Fills gap in Visor console memory variables.
       */
     def mcompact() {
-        var elements = Array("e", "a", "c", "n", "t", "s")
-        for (element <- elements){
-            val r = mem.filter { case (k, _) => (element.contains(k.charAt(0)) &&
k != "nl" && k != "nr") }
-
-            if (r.isEmpty)
-                NA
-            else {
-                clearNamespace(element)
-                r.toSeq.sortBy(_._1).foreach { case (k, v) => setVar(v, element) }
+        val namespaces = Array("a", "c", "e", "n", "s", "t")
+        
+        for (namespace <- namespaces) {
+            val vars = mem.filter { case (k, _) => k.matches(s"$namespace\\d+") }
+
+            if (vars.nonEmpty) {
+                clearNamespace(namespace)
+                
+                vars.toSeq.sortBy(_._1).foreach { case (_, v) => setVar(v, namespace)
}
             }
         }
     }
@@ -645,15 +645,8 @@ object visor extends VisorTag {
         assert(namespace != null)
 
         mem.keySet.foreach(k => {
-            if (k.startsWith(namespace))
-                try {
-                    k.substring(1).toInt
-
-                    mem.remove(k)
-                }
-                catch {
-                    case ignored: Throwable => // No-op.
-                }
+            if (k.matches(s"$namespace\\d+"))
+                mem.remove(k)
         })
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/c42b50cf/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/mem/VisorMemoryCommandSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/mem/VisorMemoryCommandSpec.scala
b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/mem/VisorMemoryCommandSpec.scala
index a360ea3..278bace 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/mem/VisorMemoryCommandSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/mem/VisorMemoryCommandSpec.scala
@@ -82,14 +82,33 @@ class VisorMemoryCommandSpec extends FunSpec with Matchers {
 
     describe("A 'mcompact' visor command") {
         it("should compact variable") {
-
             visor.mset("key1", "value1")
-            visor.mset("key2", "value2")
             visor.mset("key3", "value3")
 
-            visor mclear "key2"
+            visor.mset("n0", "value0")
+            visor.mset("n1", "value1")
+            visor.mset("n2", "value2")
+            visor.mset("n3", "value3")
+
+            visor.mset("c1", "value1")
+            visor.mset("c3", "value3")
 
             visor.mcompact()
+
+            assertResult(None)(visor.mgetOpt("key0"))
+            assertResult(Some("value1"))(visor.mgetOpt("key1"))
+            assertResult(None)(visor.mgetOpt("key2"))
+            assertResult(Some("value3"))(visor.mgetOpt("key3"))
+
+            assertResult(Some("value0"))(visor.mgetOpt("n0"))
+            assertResult(Some("value1"))(visor.mgetOpt("n1"))
+            assertResult(Some("value2"))(visor.mgetOpt("n2"))
+            assertResult(Some("value3"))(visor.mgetOpt("n3"))
+
+            assertResult(Some("value1"))(visor.mgetOpt("c0"))
+            assertResult(Some("value3"))(visor.mgetOpt("c1"))
+            assertResult(None)(visor.mgetOpt("c3"))
+
             visor.mlist()
         }
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/c42b50cf/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/node/VisorNodeCommandSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/node/VisorNodeCommandSpec.scala
b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/node/VisorNodeCommandSpec.scala
index 0ef4814..c0983c0 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/node/VisorNodeCommandSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/node/VisorNodeCommandSpec.scala
@@ -38,15 +38,5 @@ class VisorNodeCommandSpec extends VisorRuntimeBaseSpec(1) {
 
             visor.node("") // Arguments are ignored.
         }
-
-        visor.mclear()
-
-        it("should properly execute with valid node ID value post mclear") {
-            visor.node("-id8=@n1")
-        }
-
-        it("should list all variables") {
-            visor.mlist()
-        }
     }
 }


Mime
View raw message