You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/04/09 10:12:06 UTC
[02/50] [abbrv] incubator-ignite git commit: # IGNITE-639 WIP.
# IGNITE-639 WIP.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/6011305b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/6011305b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/6011305b
Branch: refs/heads/ignite-452
Commit: 6011305b72610eb42290d090ccbf674324df5ddd
Parents: 8e21725
Author: AKuznetsov <ak...@gridgain.com>
Authored: Wed Apr 1 15:32:10 2015 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Wed Apr 1 15:32:10 2015 +0700
----------------------------------------------------------------------
.../org/apache/ignite/internal/IgniteEx.java | 8 +
.../apache/ignite/internal/IgniteKernal.java | 5 +
.../visor/cache/VisorCacheConfiguration.java | 17 +-
.../cache/VisorCacheMetricsCollectorTask.java | 75 +++-
.../HadoopDefaultMapReducePlannerSelfTest.java | 5 +
.../commands/cache/VisorCacheCommand.scala | 374 ++++++++++---------
6 files changed, 296 insertions(+), 188 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6011305b/modules/core/src/main/java/org/apache/ignite/internal/IgniteEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteEx.java
index b8c1e11..6604050 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteEx.java
@@ -69,6 +69,14 @@ public interface IgniteEx extends Ignite {
public Collection<GridCache<?, ?>> cachesx(@Nullable IgnitePredicate<? super GridCache<?, ?>>... p);
/**
+ * Gets system state of cache with specified name.
+ *
+ * @param name Cache name.
+ * @return {@code true} if cache with specified name is system.
+ */
+ public boolean systemCache(@Nullable String name);
+
+ /**
* Checks if the event type is user-recordable.
*
* @param type Event type to check.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6011305b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 5f35d16..c8cd372 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -2448,6 +2448,11 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
}
/** {@inheritDoc} */
+ @Override public boolean systemCache(@Nullable String name) {
+ return ctx.cache().systemCache(name);
+ }
+
+ /** {@inheritDoc} */
@Override public <K, V> GridCache<K, V> cachex() {
guard();
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6011305b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
index 98a8bc2..7afdb0d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
@@ -17,9 +17,9 @@
package org.apache.ignite.internal.visor.cache;
-import org.apache.ignite.*;
import org.apache.ignite.cache.*;
import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.*;
import org.apache.ignite.internal.util.typedef.internal.*;
import org.jetbrains.annotations.*;
@@ -116,12 +116,15 @@ public class VisorCacheConfiguration implements Serializable {
/** Query configuration. */
private VisorCacheQueryConfiguration qryCfg;
+ /** System cache state. */
+ private boolean system;
+
/**
* @param ignite Grid.
* @param ccfg Cache configuration.
* @return Data transfer object for cache configuration properties.
*/
- public static VisorCacheConfiguration from(Ignite ignite, CacheConfiguration ccfg) {
+ public static VisorCacheConfiguration from(IgniteEx ignite, CacheConfiguration ccfg) {
VisorCacheConfiguration cfg = new VisorCacheConfiguration();
cfg.name = ccfg.getName();
@@ -144,6 +147,7 @@ public class VisorCacheConfiguration implements Serializable {
cfg.ldrFactory = compactClass(ccfg.getCacheLoaderFactory());
cfg.writerFactory = compactClass(ccfg.getCacheWriterFactory());
cfg.expiryPlcFactory = compactClass(ccfg.getExpiryPolicyFactory());
+ cfg.system = ignite.systemCache(ccfg.getName());
cfg.affinityCfg = VisorCacheAffinityConfiguration.from(ccfg);
cfg.rebalanceCfg = VisorCacheRebalanceConfiguration.from(ccfg);
@@ -161,7 +165,7 @@ public class VisorCacheConfiguration implements Serializable {
* @param caches Cache configurations.
* @return Data transfer object for cache configurations properties.
*/
- public static Iterable<VisorCacheConfiguration> list(Ignite ignite, CacheConfiguration[] caches) {
+ public static Iterable<VisorCacheConfiguration> list(IgniteEx ignite, CacheConfiguration[] caches) {
if (caches == null)
return Collections.emptyList();
@@ -369,6 +373,13 @@ public class VisorCacheConfiguration implements Serializable {
return qryCfg;
}
+ /**
+ * @return System cache state.
+ */
+ public boolean system() {
+ return system;
+ }
+
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(VisorCacheConfiguration.class, this);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6011305b/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 de232f7..f29d47a 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
@@ -26,19 +26,21 @@ 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<IgniteBiTuple<Boolean, String>,
- Iterable<VisorCacheAggregatedMetrics>, Map<String, VisorCacheMetrics>> {
+public class VisorCacheMetricsCollectorTask extends VisorMultiNodeTask<
+ VisorCacheMetricsCollectorTask.VisorCacheMetricsCollectorArg, Iterable<VisorCacheAggregatedMetrics>,
+ Map<String, VisorCacheMetrics>> {
/** */
private static final long serialVersionUID = 0L;
/** {@inheritDoc} */
- @Override protected VisorCacheMetricsCollectorJob job(IgniteBiTuple<Boolean, String> arg) {
+ @Override protected VisorCacheMetricsCollectorJob job(VisorCacheMetricsCollectorArg arg) {
return new VisorCacheMetricsCollectorJob(arg, debug);
}
@@ -72,7 +74,7 @@ public class VisorCacheMetricsCollectorTask extends VisorMultiNodeTask<IgniteBiT
* Job that collect cache metrics from node.
*/
private static class VisorCacheMetricsCollectorJob
- extends VisorJob<IgniteBiTuple<Boolean, String>, Map<String, VisorCacheMetrics>> {
+ extends VisorJob<VisorCacheMetricsCollectorArg, Map<String, VisorCacheMetrics>> {
/** */
private static final long serialVersionUID = 0L;
@@ -82,15 +84,15 @@ public class VisorCacheMetricsCollectorTask extends VisorMultiNodeTask<IgniteBiT
* @param arg Whether to collect metrics for all caches or for specified cache name only.
* @param debug Debug flag.
*/
- private VisorCacheMetricsCollectorJob(IgniteBiTuple<Boolean, String> arg, boolean debug) {
+ private VisorCacheMetricsCollectorJob(VisorCacheMetricsCollectorArg arg, boolean debug) {
super(arg, debug);
}
/** {@inheritDoc} */
- @Override protected Map<String, VisorCacheMetrics> run(IgniteBiTuple<Boolean, String> arg) {
- Collection<? extends GridCache<?, ?>> caches = arg.get1()
- ? ignite.cachesx()
- : F.asList(ignite.cachex(arg.get2()));
+ @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));
if (caches != null) {
Map<String, VisorCacheMetrics> res = U.newHashMap(caches.size());
@@ -109,4 +111,59 @@ public class VisorCacheMetricsCollectorTask extends VisorMultiNodeTask<IgniteBiT
return S.toString(VisorCacheMetricsCollectorJob.class, this);
}
}
+
+ /**
+ * Arguments for {@link VisorCacheMetricsCollectorTask}.
+ */
+ @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;
+
+ /** Collect metrics for cache with name only. */
+ private final String cacheName;
+
+ /**
+ * Create task arguments with given parameters.
+ *
+ * @param allCaches Collect metrics for all caches.
+ * @param systemCaches Include system cache metrics.
+ * @param cacheName Collect metrics for cache with name only.
+ */
+ 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) {
+ this.showSystem = showSystem;
+ }
+
+ @Override public boolean apply(GridCache<?, ?> cache) {
+ return showSystem || !CU.isSystemCache(cache.name());
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6011305b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopDefaultMapReducePlannerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopDefaultMapReducePlannerSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopDefaultMapReducePlannerSelfTest.java
index 7075f2e..bd84be2 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopDefaultMapReducePlannerSelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopDefaultMapReducePlannerSelfTest.java
@@ -961,6 +961,11 @@ public class HadoopDefaultMapReducePlannerSelfTest extends HadoopAbstractSelfTes
}
/** {@inheritDoc} */
+ @Override public boolean systemCache(@Nullable String name) {
+ return false;
+ }
+
+ /** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override public Collection<GridCache<?, ?>> cachesx(@Nullable IgnitePredicate<? super GridCache<?, ?>>... p) {
return null;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6011305b/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 e11c197..53792f1 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,7 +21,6 @@ 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}
@@ -32,13 +31,13 @@ import org.jetbrains.annotations._
import java.lang.{Boolean => JavaBoolean}
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._
import scala.collection.JavaConversions._
import scala.language.{implicitConversions, reflectiveCalls}
-import scala.util.control.Breaks._
/**
* ==Overview==
@@ -67,11 +66,11 @@ import scala.util.control.Breaks._
*
* ====Specification====
* {{{
- * cache
- * cache -i
- * cache {-c=<cache-name>} {-id=<node-id>|id8=<node-id8>} {-s=hi|mi|rd|wr|cn} {-a} {-r}
+ * cache {-system}
+ * 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>}
+ * cache -scan -c=<cache-name> {-id=<node-id>|id8=<node-id8>} {-p=<page size>} {-system}
* cache -swap {-c=<cache-name>} {-id=<node-id>|id8=<node-id8>}
* cache -stop -c=<cache-name>
* }}}
@@ -105,6 +104,8 @@ import scala.util.control.Breaks._
* -a
* Prints details statistics about each cache.
* By default only aggregated summary is printed.
+ * -system
+ * Enable showing of information about system caches.
* -clear
* Clears cache.
* -scan
@@ -122,6 +123,8 @@ import scala.util.control.Breaks._
* ====Examples====
* {{{
* cache
+ * Prints summary statistics about all no system caches.
+ * cache -system
* Prints summary statistics about all caches.
* cache -id8=12345678 -s=hi -r
* Prints summary statistics about caches from node with specified id8
@@ -212,213 +215,227 @@ class VisorCacheCommand {
* @param args Command arguments.
*/
def cache(args: String) {
- breakable {
- if (!isConnected)
- adviseToConnect()
- else {
- var argLst = parseArgs(args)
-
- if (hasArgFlag("i", argLst)) {
- askForNode("Select node from:") match {
- case Some(nid) => ask("Detailed statistics (y/n) [n]: ", "n") match {
- case "n" | "N" => nl(); cache("-id=" + nid).^^
- case "y" | "Y" => nl(); cache("-a -id=" + nid).^^
- case x => nl(); warn("Invalid answer: " + x).^^
- }
- case None => break()
+ if (!isConnected)
+ adviseToConnect()
+ else {
+ var argLst = parseArgs(args)
+
+ if (hasArgFlag("i", argLst)) {
+ askForNode("Select node from:") match {
+ case Some(nid) => ask("Detailed statistics (y/n) [n]: ", "n") match {
+ case "n" | "N" => nl(); cache("-id=" + nid).^^
+ case "y" | "Y" => nl(); cache("-a -id=" + nid).^^
+ case x => nl(); warn("Invalid answer: " + x).^^
}
-
- break()
- }
-
- val node = parseNode(argLst) match {
- case Left(msg) =>
- scold(msg)
-
- break()
-
- case Right(n) => n
+ case None => return
}
- var cacheName = argValue("c", argLst) match {
- case Some(dfltName) if dfltName == DFLT_CACHE_KEY || dfltName == DFLT_CACHE_NAME =>
- argLst = argLst.filter(_._1 != "c") ++ Seq("c" -> null)
-
- Some(null)
-
- case cn => cn
- }
+ return
+ }
- if (Seq("clear", "swap", "scan", "stop").exists(hasArgFlag(_, argLst))) {
- if (cacheName.isEmpty)
- askForCache("Select cache from:", node) match {
- case Some(name) =>
- argLst = argLst ++ Seq("c" -> name)
+ val node = parseNode(argLst) match {
+ case Left(msg) =>
+ scold(msg)
- cacheName = Some(name)
- case None => break()
- }
+ return
- if (hasArgFlag("clear", argLst))
- VisorCacheClearCommand().clear(argLst, node)
- else if (hasArgFlag("swap", argLst))
- VisorCacheSwapCommand().swap(argLst, node)
- else if (hasArgFlag("scan", argLst))
- VisorCacheScanCommand().scan(argLst, node)
- else if (hasArgFlag("stop", argLst)) {
- cacheName.foreach(name => {
- if (!CU.isSystemCache(name))
- VisorCacheStopCommand().scan(argLst, node)
- else
- warn("Stopping of system cache is not allowed: " + name)
- })
- }
+ case Right(n) => n
+ }
- break()
- }
+ val showSystem = hasArgFlag("system", argLst)
- val all = hasArgFlag("a", argLst)
+ var cacheName = argValue("c", argLst) match {
+ case Some(dfltName) if dfltName == DFLT_CACHE_KEY || dfltName == DFLT_CACHE_NAME =>
+ argLst = argLst.filter(_._1 != "c") ++ Seq("c" -> null)
- val sortType = argValue("s", argLst)
- val reversed = hasArgName("r", argLst)
+ Some(null)
- if (sortType.isDefined && !isValidSortType(sortType.get))
- scold("Invalid '-s' argument in: " + args).^^
+ case cn => cn
+ }
- // Get cache stats data from all nodes.
- val aggrData = cacheData(node, cacheName)
+ /** Check that argument list has flag from list. */
+ def hasArgFlagIn(flags: String *) = {
+ flags.exists(hasArgFlag(_, argLst))
+ }
- if (aggrData.isEmpty)
- scold("No caches found.").^^
+ if (hasArgFlagIn("clear", "swap", "scan", "stop")) {
+ if (cacheName.isEmpty)
+ askForCache("Select cache from:", node, showSystem && !hasArgFlagIn("clear", "swap", "stop")) match {
+ case Some(name) =>
+ argLst = argLst ++ Seq("c" -> name)
- println("Time of the snapshot: " + formatDateTime(System.currentTimeMillis))
+ cacheName = Some(name)
- val sumT = VisorTextTable()
+ case None => return
+ }
- sumT #= ("Name(@)", "Nodes", "Entries", "Hits", "Misses", "Reads", "Writes")
+ cacheName.foreach(name => {
+ if (hasArgFlag("scan", argLst))
+ VisorCacheScanCommand().scan(argLst, node)
+ else {
+ if (!CU.isSystemCache(name)) {
+ if (hasArgFlag("clear", argLst))
+ VisorCacheClearCommand().clear(argLst, node)
+ else if (hasArgFlag("swap", argLst))
+ VisorCacheSwapCommand().swap(argLst, node)
+ else if (hasArgFlag("stop", argLst))
+ VisorCacheStopCommand().scan(argLst, node)
+ }
+ else {
+ if (hasArgFlag("clear", argLst))
+ warn("Clearing of system cache is not allowed: " + name)
+ else if (hasArgFlag("swap", argLst))
+ warn("Backup swapping of system cache is not allowed: " + name)
+ else if (hasArgFlag("stop", argLst))
+ warn("Stopping of system cache is not allowed: " + name)
+ }
+ }
+ })
- sortAggregatedData(aggrData, sortType.getOrElse("cn"), reversed).foreach(
- ad => {
- // Add cache host as visor variable.
- registerCacheName(ad.cacheName)
+ return
+ }
- sumT += (
- mkCacheName(ad.cacheName),
- ad.nodes,
- (
- "min: " + ad.minimumSize,
- "avg: " + formatDouble(ad.averageSize),
- "max: " + ad.maximumSize
- ),
- (
- "min: " + ad.minimumHits,
- "avg: " + formatDouble(ad.averageHits),
- "max: " + ad.maximumHits
- ),
- (
- "min: " + ad.minimumMisses,
- "avg: " + formatDouble(ad.averageMisses),
- "max: " + ad.maximumMisses
- ),
- (
- "min: " + ad.minimumReads,
- "avg: " + formatDouble(ad.averageReads),
- "max: " + ad.maximumReads
- ),
- (
- "min: " + ad.minimumWrites,
- "avg: " + formatDouble(ad.averageWrites),
- "max: " + ad.maximumWrites
- )
+ val all = hasArgFlag("a", argLst)
+
+ val sortType = argValue("s", argLst)
+ val reversed = hasArgName("r", argLst)
+
+ 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.").^^
+
+ println("Time of the snapshot: " + formatDateTime(System.currentTimeMillis))
+
+ val sumT = VisorTextTable()
+
+ sumT #= ("Name(@)", "Nodes", "Entries", "Hits", "Misses", "Reads", "Writes")
+
+ sortAggregatedData(aggrData, sortType.getOrElse("cn"), reversed).foreach(
+ ad => {
+ // Add cache host as visor variable.
+ registerCacheName(ad.cacheName)
+
+ sumT += (
+ mkCacheName(ad.cacheName),
+ ad.nodes,
+ (
+ "min: " + ad.minimumSize,
+ "avg: " + formatDouble(ad.averageSize),
+ "max: " + ad.maximumSize
+ ),
+ (
+ "min: " + ad.minimumHits,
+ "avg: " + formatDouble(ad.averageHits),
+ "max: " + ad.maximumHits
+ ),
+ (
+ "min: " + ad.minimumMisses,
+ "avg: " + formatDouble(ad.averageMisses),
+ "max: " + ad.maximumMisses
+ ),
+ (
+ "min: " + ad.minimumReads,
+ "avg: " + formatDouble(ad.averageReads),
+ "max: " + ad.maximumReads
+ ),
+ (
+ "min: " + ad.minimumWrites,
+ "avg: " + formatDouble(ad.averageWrites),
+ "max: " + ad.maximumWrites
)
- }
- )
+ )
+ }
+ )
- sumT.render()
+ sumT.render()
- if (all) {
- val sorted = aggrData.sortWith((k1, k2) => {
- if (k1.cacheName == null)
- true
- else if (k2.cacheName == null)
- false
- else k1.cacheName.compareTo(k2.cacheName) < 0
- })
+ if (all) {
+ val sorted = aggrData.sortWith((k1, k2) => {
+ if (k1.cacheName == null)
+ true
+ else if (k2.cacheName == null)
+ false
+ else k1.cacheName.compareTo(k2.cacheName) < 0
+ })
- val gCfg = node.map(config).collect {
- case cfg if cfg != null => cfg
- }
+ val gCfg = node.map(config).collect {
+ case cfg if cfg != null => cfg
+ }
- sorted.foreach(ad => {
- val cacheNameVar = mkCacheName(ad.cacheName)
+ sorted.foreach(ad => {
+ val cacheNameVar = mkCacheName(ad.cacheName)
- println("\nCache '" + cacheNameVar + "':")
+ println("\nCache '" + cacheNameVar + "':")
- val m = ad.metrics()
+ val m = ad.metrics()
- val csT = VisorTextTable()
+ val csT = VisorTextTable()
- csT += ("Name(@)", cacheNameVar)
- csT += ("Nodes", m.size())
- csT += ("Size Min/Avg/Max", ad.minimumSize + " / " + formatDouble(ad.averageSize) + " / " + ad.maximumSize)
+ csT += ("Name(@)", cacheNameVar)
+ csT += ("Nodes", m.size())
+ csT += ("Size Min/Avg/Max", ad.minimumSize + " / " + formatDouble(ad.averageSize) + " / " + ad.maximumSize)
- val ciT = VisorTextTable()
+ val ciT = VisorTextTable()
- ciT #= ("Node ID8(@), IP", "CPUs", "Heap Used", "CPU Load", "Up Time", "Size", "Hi/Mi/Rd/Wr")
+ ciT #= ("Node ID8(@), IP", "CPUs", "Heap Used", "CPU Load", "Up Time", "Size", "Hi/Mi/Rd/Wr")
- sortData(m.toMap, sortType.getOrElse("hi"), reversed).foreach { case (nid, cm) =>
- val nm = ignite.cluster.node(nid).metrics()
+ sortData(m.toMap, sortType.getOrElse("hi"), reversed).foreach { case (nid, cm) =>
+ val nm = ignite.cluster.node(nid).metrics()
- ciT += (
- nodeId8Addr(nid),
- nm.getTotalCpus,
- formatDouble(100d * nm.getHeapMemoryUsed / nm.getHeapMemoryMaximum) + " %",
+ ciT += (
+ nodeId8Addr(nid),
+ nm.getTotalCpus,
+ formatDouble(100d * nm.getHeapMemoryUsed / nm.getHeapMemoryMaximum) + " %",
- formatDouble(nm.getCurrentCpuLoad * 100d) + " %",
- X.timeSpan2HMSM(nm.getUpTime),
- cm.keySize(),
- (
- "Hi: " + cm.hits(),
- "Mi: " + cm.misses(),
- "Rd: " + cm.reads(),
- "Wr: " + cm.writes()
- )
+ formatDouble(nm.getCurrentCpuLoad * 100d) + " %",
+ X.timeSpan2HMSM(nm.getUpTime),
+ cm.keySize(),
+ (
+ "Hi: " + cm.hits(),
+ "Mi: " + cm.misses(),
+ "Rd: " + cm.reads(),
+ "Wr: " + cm.writes()
)
- }
+ )
+ }
- csT.render()
+ csT.render()
- nl()
- println("Nodes for: " + cacheNameVar)
+ nl()
+ println("Nodes for: " + cacheNameVar)
- ciT.render()
+ ciT.render()
- // Print footnote.
- println("'Hi' - Number of cache hits.")
- println("'Mi' - Number of cache misses.")
- println("'Rd' - number of cache reads.")
- println("'Wr' - Number of cache writes.")
+ // Print footnote.
+ println("'Hi' - Number of cache hits.")
+ println("'Mi' - Number of cache misses.")
+ println("'Rd' - number of cache reads.")
+ println("'Wr' - Number of cache writes.")
- // Print metrics.
- nl()
- println("Aggregated queries metrics:")
- println(" Minimum execution time: " + X.timeSpan2HMSM(ad.minimumQueryTime()))
- println(" Maximum execution time: " + X.timeSpan2HMSM(ad.maximumQueryTime))
- println(" Average execution time: " + X.timeSpan2HMSM(ad.averageQueryTime.toLong))
- println(" Total number of executions: " + ad.execsQuery)
- println(" Total number of failures: " + ad.failsQuery)
+ // Print metrics.
+ nl()
+ println("Aggregated queries metrics:")
+ println(" Minimum execution time: " + X.timeSpan2HMSM(ad.minimumQueryTime()))
+ println(" Maximum execution time: " + X.timeSpan2HMSM(ad.maximumQueryTime))
+ println(" Average execution time: " + X.timeSpan2HMSM(ad.averageQueryTime.toLong))
+ println(" Total number of executions: " + ad.execsQuery)
+ println(" Total number of failures: " + ad.failsQuery)
- gCfg.foreach(_.caches().find(_.name() == ad.cacheName()).foreach(cfg => {
- nl()
+ gCfg.foreach(_.caches().find(_.name() == ad.cacheName()).foreach(cfg => {
+ nl()
- showCacheConfiguration("Cache configuration:", cfg)
- }))
- })
+ showCacheConfiguration("Cache configuration:", cfg)
+ }))
+ })
- }
- else
- println("\nUse \"-a\" flag to see detailed statistics.")
}
+ else
+ println("\nUse \"-a\" flag to see detailed statistics.")
}
}
@@ -463,9 +480,12 @@ class VisorCacheCommand {
/**
* Get metrics data for all caches from all node or from specified node.
*
+ * @param node Option of node for cache names extracting. All nodes if `None`.
+ * @param systemCaches Allow selection of system caches.
* @return Caches metrics data.
*/
- private def cacheData(node: Option[ClusterNode], name: Option[String]): List[VisorCacheAggregatedMetrics] = {
+ private def cacheData(node: Option[ClusterNode], name: Option[String], systemCaches: Boolean = false):
+ List[VisorCacheAggregatedMetrics] = {
assert(node != null)
try {
@@ -474,7 +494,7 @@ class VisorCacheCommand {
val nids = prj.nodes().map(_.id())
ignite.compute(prj).execute(classOf[VisorCacheMetricsCollectorTask], toTaskArgument(nids,
- new IgniteBiTuple(JavaBoolean.valueOf(name.isEmpty), name.orNull))).toList
+ new VisorCacheMetricsCollectorArg(JavaBoolean.valueOf(name.isEmpty), systemCaches, name.orNull))).toList
}
catch {
case e: IgniteException => Nil
@@ -570,14 +590,16 @@ class VisorCacheCommand {
* Asks user to select a cache from the list.
*
* @param title Title displayed before the list of caches.
+ * @param node Option of node for cache names extracting. All nodes if `None`.
+ * @param showSystem Allow selection of system caches.
* @return `Option` for ID of selected cache.
*/
- def askForCache(title: String, node: Option[ClusterNode]): Option[String] = {
+ def askForCache(title: String, node: Option[ClusterNode], showSystem: Boolean = false): Option[String] = {
assert(title != null)
assert(visor.visor.isConnected)
// Get cache stats data from all nodes.
- val aggrData = cacheData(node, None)
+ val aggrData = cacheData(node, None, showSystem)
if (aggrData.isEmpty)
scold("No caches found.").^^