Repository: ignite Updated Branches: refs/heads/master d34107b8f -> a5a907b80
IGNITE-2093 Visor CMD: Added support to scan near cache. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a5a907b8 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a5a907b8 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a5a907b8 Branch: refs/heads/master Commit: a5a907b805a96d432da103b7984bc2c83cb7aa29 Parents: d34107b Author: Vasiliy Sisko <vsi...@gridgain.com> Authored: Mon Feb 12 10:13:06 2018 +0700 Committer: Alexey Kuznetsov <akuznet...@apache.org> Committed: Mon Feb 12 10:13:06 2018 +0700 ---------------------------------------------------------------------- .../commands/cache/VisorCacheCommand.scala | 29 ++++++++++++++++---- .../commands/cache/VisorCacheScanCommand.scala | 19 ++++++++----- .../scala/org/apache/ignite/visor/visor.scala | 2 +- 3 files changed, 37 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/a5a907b8/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 582feff..d55fed1 100755 --- 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 @@ -71,7 +71,7 @@ import scala.language.{implicitConversions, reflectiveCalls} * cache -i {-system} * cache {-c=<cache-name>} {-id=<node-id>|id8=<node-id8>} {-s=hi|mi|rd|wr|cn} {-a} {-r} {-system} * cache -clear {-c=<cache-name>} - * cache -scan -c=<cache-name> {-id=<node-id>|id8=<node-id8>} {-p=<page size>} {-system} + * cache -scan -c=<cache-name> {-near} {-id=<node-id>|id8=<node-id8>} {-p=<page size>} {-system} * cache -stop -c=<cache-name> * cache -reset -c=<cache-name> * cache -rebalance -c=<cache-name> @@ -112,9 +112,11 @@ import scala.language.{implicitConversions, reflectiveCalls} * -system * Enable showing of information about system caches. * -clear - * Clears cache. + * Clears cache. * -scan - * Prints list of all entries from cache. + * Prints list of all entries from cache. + * -near + * Prints list of all entries from near cache of cache. * -stop * Stop cache with specified name. * -reset @@ -153,6 +155,8 @@ import scala.language.{implicitConversions, reflectiveCalls} * with page of 50 items from all nodes with this cache. * cache -scan -c=cache -id8=12345678 * Prints list entries from cache with name 'cache' and node '12345678' ID8. + * cache -scan -c=cache -near -id8=12345678 + * Prints list entries from near cache of cache with name 'cache' and node '12345678' ID8. * cache -stop -c=cache * Stops cache with name 'cache'. * cache -reset -c=cache @@ -196,6 +200,9 @@ class VisorCacheCommand extends VisorConsoleCommand { * <ex>cache -scan -c=cache -id8=12345678</ex> * Prints list entries from cache with name 'cache' and node '12345678' ID8. * <br> + * <ex>cache -scan -c=cache -near -id8=12345678</ex> + * Prints list entries from near cache of cache with name 'cache' and node '12345678' ID8. + * <br> * <ex>cache -stop -c=@c0</ex> * Stop cache with name taken from 'c0' memory variable. * <br> @@ -227,7 +234,16 @@ class VisorCacheCommand extends VisorConsoleCommand { return - case Right(n) => n + case Right(n) => n match { + case None if hasArgName("scan", argLst) && hasArgName("near", argLst) => + askForNode("Select node from:") match { + case None => return + + case nidOpt => nidOpt.map(ignite.cluster.node(_)) + } + + case _ => n + } } val showSystem = hasArgFlag("system", argLst) @@ -707,7 +723,7 @@ object VisorCacheCommand { "cache -i", "cache {-c=<cache-name>} {-id=<node-id>|id8=<node-id8>} {-s=hi|mi|rd|wr} {-a} {-r}", "cache -clear {-c=<cache-name>} {-id=<node-id>|id8=<node-id8>}", - "cache -scan -c=<cache-name> {-id=<node-id>|id8=<node-id8>} {-p=<page size>}", + "cache -scan -c=<cache-name> {-near} {-id=<node-id>|id8=<node-id8>} {-p=<page size>}", "cache -stop -c=<cache-name>", "cache -reset -c=<cache-name>", "cache -rebalance -c=<cache-name>" @@ -733,6 +749,7 @@ object VisorCacheCommand { "-clear" -> "Clears cache.", "-system" -> "Enable showing of information about system caches.", "-scan" -> "Prints list of all entries from cache.", + "-near" -> "Prints list of all entries from near cache of cache.", "-stop" -> "Stop cache with specified name.", "-reset" -> "Reset metrics of cache with specified name.", "-rebalance" -> "Re-balance partitions for cache with specified name.", @@ -791,6 +808,8 @@ object VisorCacheCommand { "cache -scan -c=@c0 -p=50" -> ("Prints list entries from cache with name taken from 'c0' memory variable" + " with page of 50 items from all nodes with this cache."), "cache -scan -c=cache -id8=12345678" -> "Prints list entries from cache with name 'cache' and node '12345678' ID8.", + "cache -scan -near -c=cache -id8=12345678" -> + "Prints list entries from near cache of cache with name 'cache' and node '12345678' ID8.", "cache -stop -c=@c0" -> "Stop cache with name taken from 'c0' memory variable.", "cache -reset -c=@c0" -> "Reset metrics for cache with name taken from 'c0' memory variable.", "cache -rebalance -c=cache" -> "Re-balance partitions for cache with name 'cache'." http://git-wip-us.apache.org/repos/asf/ignite/blob/a5a907b8/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheScanCommand.scala ---------------------------------------------------------------------- diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheScanCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheScanCommand.scala index 8e46ffc..72d4cab 100644 --- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheScanCommand.scala +++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheScanCommand.scala @@ -32,19 +32,21 @@ import scala.collection.JavaConversions._ * * ====Specification==== * {{{ - * cache {-id=<node-id>|-id8=<node-id8>} {-p=<page size>} -c=<cache name> -scan + * cache -scan -c=<cache name> {-near} {-id=<node-id>|-id8=<node-id8>} {-p=<page size>} * }}} * * ====Arguments==== * {{{ + * <cache-name> + * Name of the cache. + * <near> + * Prints list of all entries from near cache of cache. * <node-id> * Full node ID. * <node-id8> * Node ID8. * <page size> * Number of object to fetch from cache at once. - * <cache-name> - * Name of the cache. * }}} * * ====Examples==== @@ -54,8 +56,10 @@ import scala.collection.JavaConversions._ * cache -c=@c0 -scan -p=50 * List entries from cache with name taken from 'c0' memory variable with page of 50 items * from all nodes with this cache. - * cache -c=cache -scan -id8=12345678 + * cache -scan -c=cache -id8=12345678 * List entries from cache with name 'cache' and node '12345678' ID8. + * cache -scan -near -c=cache -id8=12345678 + * List entries from near cache of cache with name 'cache' and node '12345678' ID8. * }}} */ class VisorCacheScanCommand { @@ -100,6 +104,7 @@ class VisorCacheScanCommand { def scan(argLst: ArgList, node: Option[ClusterNode]) { val pageArg = argValue("p", argLst) val cacheArg = argValue("c", argLst) + val near = hasArgName("near", argLst) var pageSize = 25 @@ -138,7 +143,7 @@ class VisorCacheScanCommand { val firstPage = try executeRandom(groupForDataNode(node, cacheName), - classOf[VisorScanQueryTask], new VisorScanQueryTaskArg(cacheName, null, false, false, false, false, pageSize)) match { + classOf[VisorScanQueryTask], new VisorScanQueryTaskArg(cacheName, null, false, false, near, false, pageSize)) match { case x if x.getError != null => error(x.getError) @@ -157,7 +162,7 @@ class VisorCacheScanCommand { } if (firstPage.getRows.isEmpty) { - println(s"Cache: ${escapeName(cacheName)} is empty") + println(s"${if (near) "Near cache" else "Cache"}: ${escapeName(cacheName)} is empty") return } @@ -165,7 +170,7 @@ class VisorCacheScanCommand { var nextPage: VisorQueryResult = firstPage def render() { - println("Entries in cache: " + escapeName(cacheName)) + println(s"Entries in ${if (near) "near" else ""} cache: " + escapeName(cacheName)) val t = VisorTextTable() http://git-wip-us.apache.org/repos/asf/ignite/blob/a5a907b8/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 c24bc25..795cc53 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 @@ -1309,7 +1309,7 @@ object visor extends VisorTag { * * @return `True` when cluster is active. */ - def isActive: Boolean = ignite.active + def isActive: Boolean = ignite.cluster().active() /** * Gets timestamp of Visor console connection. Returns `0` if Visor console is not connected.