You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by yz...@apache.org on 2017/01/26 14:53:01 UTC
[02/15] ignite git commit: IGNITE-1943 Visor CMD: Fixed wrong
behavior of "mclear" command". - Fixes #1179.
IGNITE-1943 Visor CMD: Fixed wrong behavior of "mclear" command". - Fixes #1179.
Signed-off-by: Andrey Novikov <an...@gridgain.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/24e14b66
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/24e14b66
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/24e14b66
Branch: refs/heads/ignite-comm-balance-master
Commit: 24e14b6618564873ca9509ce3272cd315df93728
Parents: d5b2748
Author: samaitra <sa...@gmail.com>
Authored: Tue Jan 24 14:31:24 2017 +0700
Committer: Andrey Novikov <an...@gridgain.com>
Committed: Tue Jan 24 14:31:24 2017 +0700
----------------------------------------------------------------------
.../scala/org/apache/ignite/visor/visor.scala | 104 ++++++++++++-------
.../commands/mem/VisorMemoryCommandSpec.scala | 14 +++
.../commands/node/VisorNodeCommandSpec.scala | 10 ++
3 files changed, 89 insertions(+), 39 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/24e14b66/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 8673b9c..0aa8549 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
@@ -330,43 +330,6 @@ object visor extends VisorTag {
)
addHelp(
- name = "mclear",
- shortInfo = "Clears Visor console memory variables.",
- spec = Seq(
- "mclear",
- "mclear <name>|-ev|-al|-ca|-no|-tn|-ex"
- ),
- args = Seq(
- "<name>" -> Seq(
- "Variable name to clear.",
- "Note that name doesn't include '@' symbol used to reference variable."
- ),
- "-ev" ->
- "Clears all 'event' variables.",
- "-al" ->
- "Clears all 'alert' variables.",
- "-ca" ->
- "Clears all 'cache' variables.",
- "-no" ->
- "Clears all 'node' variables.",
- "-tn" ->
- "Clears all 'task name' variables.",
- "-ex" ->
- "Clears all 'task execution' variables."
- ),
- examples = Seq(
- "mclear" ->
- "Clears all Visor console variables.",
- "mclear -ca" ->
- "Clears all Visor console cache variables.",
- "mclear n2" ->
- "Clears 'n2' Visor console variable."
- ),
- emptyArgs = mclear,
- withArgs = mclear
- )
-
- addHelp(
name = "mget",
shortInfo = "Gets Visor console memory variable.",
longInfo = Seq(
@@ -388,6 +351,23 @@ object visor extends VisorTag {
)
addHelp(
+ name = "mcompact",
+ shortInfo = "Fills gap in Visor console memory variable.",
+ longInfo = Seq(
+ "Finds and fills gap in Visor console memory variable."
+ ),
+ spec = Seq(
+ "mcompact"
+ ),
+ examples = Seq(
+ "mcompact" ->
+ "Fills gap in Visor console memory variable."
+ ),
+ emptyArgs = mcompact,
+ withArgs = _ => wrongArgs("mcompact")
+ )
+
+ addHelp(
name = "help",
shortInfo = "Prints Visor console help.",
aliases = Seq("?"),
@@ -616,6 +596,28 @@ object visor extends VisorTag {
}
/**
+ * ==Command==
+ * Fills gap in Visor console memory variable.
+ *
+ * ==Examples==
+ * <ex>mcompact</ex>
+ * Fills gap in Visor console memory variable.
+ */
+ 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) }
+ }
+ }
+ }
+
+ /**
* Clears given Visor console variable or the whole namespace.
*
* @param arg Variable host or namespace mnemonic.
@@ -1677,15 +1679,39 @@ object visor extends VisorTag {
val n = ignite.cluster.node(id)
val id8 = nid8(id)
- val v = mfindHead(id8)
+ var v = mfindHead(id8)
+
+ if(!v.isDefined){
+ v = assignNodeValue(n)
+ }
id8 +
- (if (v.isDefined) "(@" + v.get._1 + ")" else "") +
+ (if (v.isDefined) "(@" + v.get._1 + ")" else "" )+
", " +
(if (n == null) NA else sortAddresses(n.addresses).headOption.getOrElse(NA))
}
}
+ def assignNodeValue(node: ClusterNode): Option[(String, String)] = {
+ assert(node != null)
+
+ val id8 = nid8(node.id())
+
+ setVarIfAbsent(id8, "n")
+
+ val alias = if (U.sameMacs(ignite.localNode(), node)) "nl" else "nr"
+
+ if (mgetOpt(alias).isEmpty)
+ msetOpt(alias, nid8(node.id()))
+
+ val ip = sortAddresses(node.addresses).headOption
+
+ if (ip.isDefined)
+ setVarIfAbsent(ip.get, "h")
+
+ mfindHead(id8)
+ }
+
/**
* Returns string with node id8 and its memory variable, if available.
*
http://git-wip-us.apache.org/repos/asf/ignite/blob/24e14b66/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 27eaa94..a360ea3 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
@@ -79,4 +79,18 @@ class VisorMemoryCommandSpec extends FunSpec with Matchers {
visor.mlist()
}
}
+
+ 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.mcompact()
+ visor.mlist()
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/24e14b66/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 c0983c0..0ef4814 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,5 +38,15 @@ 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()
+ }
}
}