# IGNITE-298 Review.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/8469db79 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/8469db79 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/8469db79 Branch: refs/heads/ignite-187 Commit: 8469db791f1789ae83275a4394f7550359c343cf Parents: 42ba6a3 Author: AKuznetsov <akuznet...@gridgain.com> Authored: Tue Feb 24 16:08:25 2015 +0700 Committer: AKuznetsov <akuznet...@gridgain.com> Committed: Tue Feb 24 16:08:25 2015 +0700 ---------------------------------------------------------------------- .../commands/alert/VisorAlertCommand.scala | 8 +- .../commands/cache/VisorCacheCommand.scala | 88 ++++++------- .../config/VisorConfigurationCommand.scala | 123 +++++++++---------- .../commands/disco/VisorDiscoveryCommand.scala | 2 +- .../scala/org/apache/ignite/visor/visor.scala | 64 ++++++---- .../commands/tasks/VisorTasksCommandSpec.scala | 2 +- 6 files changed, 150 insertions(+), 137 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8469db79/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/alert/VisorAlertCommand.scala ---------------------------------------------------------------------- diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/alert/VisorAlertCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/alert/VisorAlertCommand.scala index bcdaeec..f94f481 100644 --- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/alert/VisorAlertCommand.scala +++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/alert/VisorAlertCommand.scala @@ -541,8 +541,8 @@ class VisorAlertCommand { sum += ("Total alerts", alerts.size) sum += ("Total sends", (0 /: stats.values)((b, a) => b + a.cnt)) - sum += ("First send", if (firstSnd == 0) "n/a" else formatDateTime(firstSnd)) - sum += ("Last send", if (lastSnd == 0) "n/a" else formatDateTime(lastSnd)) + sum += ("First send", if (firstSnd == 0) NA else formatDateTime(firstSnd)) + sum += ("Last send", if (lastSnd == 0) NA else formatDateTime(lastSnd)) sum.render() } @@ -582,8 +582,8 @@ class VisorAlertCommand { a.spec, stat.cnt, formatDateTime(a.createdOn), - if (stat.firstSnd == 0) "n/a" else formatDateTime(stat.firstSnd), - if (stat.lastSnd == 0) "n/a" else formatDateTime(stat.lastSnd) + if (stat.firstSnd == 0) NA else formatDateTime(stat.firstSnd), + if (stat.lastSnd == 0) NA else formatDateTime(stat.lastSnd) ) }) http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8469db79/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 fb9cf47..5dd19b1 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 @@ -17,19 +17,18 @@ package org.apache.ignite.visor.commands.cache -import org.apache.ignite.internal.visor.cache._ -import org.apache.ignite.internal.visor.node.{VisorGridConfiguration, VisorNodeConfigurationCollectorTask} -import org.apache.ignite.internal.util.typedef._ - import org.apache.ignite._ import org.apache.ignite.cluster.ClusterNode +import org.apache.ignite.internal.util.typedef._ +import org.apache.ignite.internal.visor.cache._ +import org.apache.ignite.internal.visor.node.{VisorGridConfiguration, VisorNodeConfigurationCollectorTask} import org.apache.ignite.lang.IgniteBiTuple -import org.apache.ignite.visor.VisorTag import org.jetbrains.annotations._ import java.lang.{Boolean => JavaBoolean} import java.util.UUID +import org.apache.ignite.visor.VisorTag import org.apache.ignite.visor.commands.cache.VisorCacheCommand._ import org.apache.ignite.visor.commands.{VisorConsoleCommand, VisorTextTable} import org.apache.ignite.visor.visor._ @@ -784,29 +783,30 @@ object VisorCacheCommand { cacheT #= ("Name", "Value") cacheT += ("Mode", cfg.mode) - cacheT += ("Atomicity Mode", cfg.atomicityMode) + cacheT += ("Atomicity Mode", safe(cfg.atomicityMode)) cacheT += ("Atomic Sequence Reserve Size", cfg.atomicSequenceReserveSize) - cacheT += ("Atomic Write Ordering Mode", cfg.atomicWriteOrderMode) - cacheT += ("Statistic Enabled", cfg.statisticsEnabled()) - cacheT += ("Management Enabled", cfg.managementEnabled()) + cacheT += ("Atomic Write Ordering Mode", safe(cfg.atomicWriteOrderMode)) + cacheT += ("Statistic Enabled", bool2Str(cfg.statisticsEnabled())) + cacheT += ("Management Enabled", bool2Str(cfg.managementEnabled())) cacheT += ("Time To Live", defaultCfg.timeToLive()) cacheT += ("Time To Live Eager Flag", cfg.eagerTtl) - cacheT += ("Write Synchronization Mode", cfg.writeSynchronizationMode) - cacheT += ("Swap Enabled", cfg.swapEnabled()) - cacheT += ("Invalidate", cfg.invalidate()) - cacheT += ("Read Through", cfg.readThrough()) + cacheT += ("Write Synchronization Mode", safe(cfg.writeSynchronizationMode)) + cacheT += ("Swap Enabled", bool2Str(cfg.swapEnabled())) + cacheT += ("Invalidate", bool2Str(cfg.invalidate())) + cacheT += ("Read Through", bool2Str(cfg.readThrough())) + cacheT += ("Write Through", bool2Str(cfg.writeThrough())) cacheT += ("Start Size", cfg.startSize()) - cacheT += ("Transaction Manager Lookup", cfg.transactionManagerLookupClassName()) + cacheT += ("Transaction Manager Lookup", safe(cfg.transactionManagerLookupClassName())) - cacheT += ("Affinity Function", affinityCfg.function()) + cacheT += ("Affinity Function", safe(affinityCfg.function())) cacheT += ("Affinity Backups", affinityCfg.partitionedBackups()) - cacheT += ("Affinity Partitions", affinityCfg.partitions()) - cacheT += ("Affinity Default Replicas", affinityCfg.defaultReplicas()) - cacheT += ("Affinity Exclude Neighbors", affinityCfg.excludeNeighbors()) - cacheT += ("Affinity Mapper", affinityCfg.mapper()) + cacheT += ("Affinity Partitions", safe(affinityCfg.partitions())) + cacheT += ("Affinity Default Replicas", safe(affinityCfg.defaultReplicas())) + cacheT += ("Affinity Exclude Neighbors", safe(affinityCfg.excludeNeighbors())) + cacheT += ("Affinity Mapper", safe(affinityCfg.mapper())) cacheT += ("Preload Mode", preloadCfg.mode()) cacheT += ("Preload Batch Size", preloadCfg.batchSize()) @@ -815,12 +815,12 @@ object VisorCacheCommand { cacheT += ("Preloading Delay", preloadCfg.partitionedDelay()) cacheT += ("Time Between Preload Messages", preloadCfg.throttle()) - cacheT += ("Eviction Policy Enabled", evictCfg.policy() != null) - cacheT += ("Eviction Policy", evictCfg.policy()) - cacheT += ("Eviction Policy Max Size", evictCfg.policyMaxSize()) - cacheT += ("Eviction Filter", evictCfg.filter()) + cacheT += ("Eviction Policy Enabled", bool2Str(evictCfg.policy() != null)) + cacheT += ("Eviction Policy", safe(evictCfg.policy())) + cacheT += ("Eviction Policy Max Size", safe(evictCfg.policyMaxSize())) + cacheT += ("Eviction Filter", safe(evictCfg.filter())) cacheT += ("Eviction Key Buffer Size", evictCfg.synchronizedKeyBufferSize()) - cacheT += ("Eviction Synchronized", evictCfg.evictSynchronized()) + cacheT += ("Eviction Synchronized", bool2Str(evictCfg.evictSynchronized())) cacheT += ("Eviction Overflow Ratio", evictCfg.maxOverflowRatio()) cacheT += ("Synchronous Eviction Timeout", evictCfg.synchronizedTimeout()) cacheT += ("Synchronous Eviction Concurrency Level", evictCfg.synchronizedConcurrencyLevel()) @@ -828,27 +828,27 @@ object VisorCacheCommand { cacheT += ("Distribution Mode", cfg.distributionMode()) cacheT += ("Near Start Size", nearCfg.nearStartSize()) - cacheT += ("Near Eviction Policy", nearCfg.nearEvictPolicy()) - cacheT += ("Near Eviction Enabled", nearCfg.nearEnabled()) - cacheT += ("Near Eviction Synchronized", evictCfg.nearSynchronized()) - cacheT += ("Near Eviction Policy Max Size", nearCfg.nearEvictMaxSize()) + cacheT += ("Near Eviction Policy", safe(nearCfg.nearEvictPolicy())) + cacheT += ("Near Eviction Enabled", bool2Str(nearCfg.nearEnabled())) + cacheT += ("Near Eviction Synchronized", bool2Str(evictCfg.nearSynchronized())) + cacheT += ("Near Eviction Policy Max Size", safe(nearCfg.nearEvictMaxSize())) cacheT += ("Default Lock Timeout", defaultCfg.txLockTimeout()) cacheT += ("Default Query Timeout", defaultCfg.queryTimeout()) - cacheT += ("Query Indexing Enabled", cfg.queryIndexEnabled()) + cacheT += ("Query Indexing Enabled", bool2Str(cfg.queryIndexEnabled())) cacheT += ("Query Iterators Number", cfg.maxQueryIteratorCount()) cacheT += ("Metadata type count", cfg.typeMeta().size()) - cacheT += ("Indexing SPI Name", cfg.indexingSpiName()) - cacheT += ("Cache Interceptor", cfg.interceptor()) + cacheT += ("Indexing SPI Name", safe(cfg.indexingSpiName())) + cacheT += ("Cache Interceptor", safe(cfg.interceptor())) - cacheT += ("Store Enabled", storeCfg.enabled()) - cacheT += ("Store", storeCfg.store()) + cacheT += ("Store Enabled", bool2Str(storeCfg.enabled())) + cacheT += ("Store", safe(storeCfg.store())) cacheT += ("Store Values In Bytes", storeCfg.valueBytes()) - cacheT += ("Configured JDBC Store", cfg.jdbcStore()) + cacheT += ("Configured JDBC Store", bool2Str(cfg.jdbcStore())) cacheT += ("Off-Heap Size", cfg.offsetHeapMaxMemory()) - cacheT += ("Write-Behind Enabled", writeBehind.enabled()) + cacheT += ("Write-Behind Enabled", bool2Str(writeBehind.enabled())) cacheT += ("Write-Behind Flush Size", writeBehind.flushSize()) cacheT += ("Write-Behind Frequency", writeBehind.flushFrequency()) cacheT += ("Write-Behind Flush Threads Count", writeBehind.flushThreadCount()) @@ -857,19 +857,19 @@ object VisorCacheCommand { cacheT += ("Concurrent Asynchronous Operations Number", cfg.maxConcurrentAsyncOperations()) cacheT += ("Memory Mode", cfg.memoryMode()) - cacheT += ("Loader Factory Class Name", cfg.loaderFactory()) - cacheT += ("Writer Factory Class Name", cfg.writerFactory()) - cacheT += ("Expiry Policy Factory Class Name", cfg.expiryPolicyFactory()) + cacheT += ("Loader Factory Class Name", safe(cfg.loaderFactory())) + cacheT += ("Writer Factory Class Name", safe(cfg.writerFactory())) + cacheT += ("Expiry Policy Factory Class Name", safe(cfg.expiryPolicyFactory())) if (queryCfg != null) { - cacheT +=("Query Type Resolver Class Name", queryCfg.typeResolver()) - cacheT +=("Indexing Primitive Key", queryCfg.indexPrimitiveKey()) - cacheT +=("Indexing Primitive Value", queryCfg.indexPrimitiveValue()) - cacheT +=("Fixed Typing", queryCfg.indexFixedTyping()) - cacheT +=("Escaped Names", queryCfg.escapeAll()) + cacheT +=("Query Type Resolver", safe(queryCfg.typeResolver())) + cacheT +=("Query Indexing Primitive Key", bool2Str(queryCfg.indexPrimitiveKey())) + cacheT +=("Query Indexing Primitive Value", bool2Str(queryCfg.indexPrimitiveValue())) + cacheT +=("Query Fixed Typing", bool2Str(queryCfg.indexFixedTyping())) + cacheT +=("Query Escaped Names", bool2Str(queryCfg.escapeAll())) } else - cacheT += ("Query configuration", queryCfg) + cacheT += ("Query Configuration", NA) println(title) http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8469db79/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/config/VisorConfigurationCommand.scala ---------------------------------------------------------------------- diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/config/VisorConfigurationCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/config/VisorConfigurationCommand.scala index 4ebfc8b..4934b99 100644 --- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/config/VisorConfigurationCommand.scala +++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/config/VisorConfigurationCommand.scala @@ -32,7 +32,6 @@ import org.apache.ignite.visor.visor._ import scala.collection.JavaConversions._ import scala.language.implicitConversions -import scala.reflect.ClassTag import scala.util.control.Breaks._ /** @@ -81,9 +80,6 @@ import scala.util.control.Breaks._ * }}} */ class VisorConfigurationCommand { - /** Default value */ - private val DFLT = "<n/a>" - /** * Prints error message and advise. * @@ -97,26 +93,6 @@ class VisorConfigurationCommand { } /** - * Joins array elements to string. - * - * @param arr Array. - * @return String. - */ - private def arr2Str[T: ClassTag](arr: Array[T]): String = { - if (arr != null && arr.length > 0) U.compact(arr.mkString(", ")) else DFLT - } - - /** - * Converts `Boolean` to 'Yes'/'No' string. - * - * @param bool Boolean value. - * @return String. - */ - private def bool2Str(bool: Boolean): String = { - if (bool) "on" else "off" - } - - /** * ===Command=== * Run command in interactive mode. * @@ -221,27 +197,44 @@ class VisorConfigurationCommand { val cmnT = VisorTextTable() - cmnT += ("Grid name", safe(cfg.basic().gridName(), "<default>")) - cmnT += ("Ignite home", safe(cfg.basic().ggHome(), DFLT)) - cmnT += ("Localhost", safe(cfg.basic().localHost(), DFLT)) - cmnT += ("Node ID", safe(cfg.basic().nodeId(), DFLT)) - cmnT += ("Marshaller", cfg.basic().marshaller()) - cmnT += ("Deployment mode", safe(cfg.basic().deploymentMode(), DFLT)) - cmnT += ("Daemon", bool2Str(cfg.basic().daemon())) - cmnT += ("Remote JMX", bool2Str(cfg.basic().jmxRemote())) - cmnT += ("Restart", bool2Str(cfg.basic().restart())) - cmnT += ("Network timeout", cfg.basic().networkTimeout() + "ms") - cmnT += ("Grid logger", safe(cfg.basic().logger(), DFLT)) - cmnT += ("Discovery startup delay", cfg.basic().discoStartupDelay() + "ms") - cmnT += ("MBean server", safe(cfg.basic().mBeanServer(), DFLT)) - cmnT += ("ASCII logo disabled", bool2Str(cfg.basic().noAscii())) - cmnT += ("Discovery order not required", bool2Str(cfg.basic().noDiscoOrder())) - cmnT += ("Shutdown hook disabled", bool2Str(cfg.basic().noShutdownHook())) - cmnT += ("Program name", safe(cfg.basic(). programName(), DFLT)) - cmnT += ("Quiet mode", bool2Str(cfg.basic().quiet())) - cmnT += ("Success filename", safe(cfg.basic().successFile(), DFLT)) - cmnT += ("Update notification", bool2Str(cfg.basic().updateNotifier())) - cmnT += ("Include properties", safe(cfg.includeProperties(), DFLT)) + val basic = cfg.basic() + + cmnT += ("Grid name", safe(basic.gridName(), "<default>")) + cmnT += ("Ignite home", safe(basic.ggHome())) + cmnT += ("Localhost", safe(basic.localHost())) + cmnT += ("Node ID", safe(basic.nodeId())) + cmnT += ("Marshaller", basic.marshaller()) + cmnT += ("Deployment mode", safe(basic.deploymentMode())) + cmnT += ("Daemon", bool2Str(basic.daemon())) + cmnT += ("Remote JMX", bool2Str(basic.jmxRemote())) + cmnT += ("Restart", bool2Str(basic.restart())) + cmnT += ("Network timeout", basic.networkTimeout() + "ms") + cmnT += ("Grid logger", safe(basic.logger())) + cmnT += ("Discovery startup delay", basic.discoStartupDelay() + "ms") + cmnT += ("MBean server", safe(basic.mBeanServer())) + cmnT += ("ASCII logo disabled", bool2Str(basic.noAscii())) + cmnT += ("Discovery order not required", bool2Str(basic.noDiscoOrder())) + cmnT += ("Shutdown hook disabled", bool2Str(basic.noShutdownHook())) + cmnT += ("Program name", safe(basic. programName())) + cmnT += ("Quiet mode", bool2Str(basic.quiet())) + cmnT += ("Success filename", safe(basic.successFile())) + cmnT += ("Update notification", bool2Str(basic.updateNotifier())) + cmnT += ("Include properties", safe(cfg.includeProperties())) + + val atomic = cfg.atomic() + + cmnT += ("Atomic Cache Mode", atomic.cacheMode()) + cmnT += ("Atomic Sequence Reservation Size", atomic.atomicSequenceReserveSize()) + cmnT += ("Atomic Number Of Backup Nodes", atomic.backups()) + + val trn = cfg.transaction() + + cmnT += ("Transaction Concurrency", trn.defaultTxConcurrency()) + cmnT += ("Transaction Isolation", trn.defaultTxIsolation()) + cmnT += ("Transaction Timeout", trn.defaultTxTimeout() + "ms") + cmnT += ("Transaction Log Cleanup Delay", trn.pessimisticTxLogLinger() + "ms") + cmnT += ("Transaction Log Size", trn.getPessimisticTxLogSize) + cmnT += ("Transaction Serializable Enabled", bool2Str(trn.txSerializableEnabled())) cmnT.render() @@ -262,7 +255,7 @@ class VisorConfigurationCommand { val spisT = VisorTextTable() def spiClass(spi: IgniteBiTuple[String, java.util.Map[String, AnyRef]]) = { - if (spi != null) spi.get2().getOrElse("Class Name", DFLT) else DFLT + if (spi != null) spi.get2().getOrElse("Class Name", NA) else NA } def spisClass(spis: Array[IgniteBiTuple[String, java.util.Map[String, AnyRef]]]) = { @@ -288,7 +281,7 @@ class VisorConfigurationCommand { p2pT += ("Peer class loading enabled", bool2Str(cfg.p2p().p2pEnabled())) p2pT += ("Missed resources cache size", cfg.p2p().p2pMissedResponseCacheSize()) - p2pT += ("Peer-to-Peer loaded packages", safe(cfg.p2p().p2pLocalClassPathExclude(), DFLT)) + p2pT += ("Peer-to-Peer loaded packages", safe(cfg.p2p().p2pLocalClassPathExclude())) p2pT.render() @@ -296,7 +289,7 @@ class VisorConfigurationCommand { val lifecycleT = VisorTextTable() - lifecycleT += ("Beans", safe(cfg.lifecycle().beans(), DFLT)) + lifecycleT += ("Beans", safe(cfg.lifecycle().beans())) lifecycleT.render() @@ -306,12 +299,12 @@ class VisorConfigurationCommand { val execCfg = cfg.executeService() - execSvcT += ("Public thread pool size", safe(execCfg.publicThreadPoolSize(), DFLT)) - execSvcT += ("System thread pool size", safe(execCfg.systemThreadPoolSize(), DFLT)) - execSvcT += ("Management thread pool size", safe(execCfg.managementThreadPoolSize(), DFLT)) - execSvcT += ("IGFS thread pool size", safe(execCfg.igfsThreadPoolSize(), DFLT)) - execSvcT += ("Peer-to-Peer thread pool size", safe(execCfg.peerClassLoadingThreadPoolSize(), DFLT)) - execSvcT += ("REST thread pool size", safe(execCfg.restThreadPoolSize(), DFLT)) + execSvcT += ("Public thread pool size", safe(execCfg.publicThreadPoolSize())) + execSvcT += ("System thread pool size", safe(execCfg.systemThreadPoolSize())) + execSvcT += ("Management thread pool size", safe(execCfg.managementThreadPoolSize())) + execSvcT += ("IGFS thread pool size", safe(execCfg.igfsThreadPoolSize())) + execSvcT += ("Peer-to-Peer thread pool size", safe(execCfg.peerClassLoadingThreadPoolSize())) + execSvcT += ("REST thread pool size", safe(execCfg.restThreadPoolSize())) execSvcT.render() @@ -319,8 +312,8 @@ class VisorConfigurationCommand { val segT = VisorTextTable() - segT += ("Segmentation policy", safe(cfg.segmentation().policy(), DFLT)) - segT += ("Segmentation resolvers", safe(cfg.segmentation().resolvers(), DFLT)) + segT += ("Segmentation policy", safe(cfg.segmentation().policy())) + segT += ("Segmentation resolvers", safe(cfg.segmentation().resolvers())) segT += ("Segmentation check frequency", cfg.segmentation().checkFrequency()) segT += ("Wait for segmentation on start", bool2Str(cfg.segmentation().waitOnStart())) segT += ("All resolvers pass required", bool2Str(cfg.segmentation().passRequired())) @@ -331,7 +324,7 @@ class VisorConfigurationCommand { val evtsT = VisorTextTable() - val inclEvtTypes = Option(cfg.includeEventTypes()).fold(DFLT)(et => arr2Str(et.map(U.gridEventName))) + val inclEvtTypes = Option(cfg.includeEventTypes()).fold(NA)(et => arr2Str(et.map(U.gridEventName))) evtsT += ("Included event types", inclEvtTypes) @@ -342,14 +335,14 @@ class VisorConfigurationCommand { val restT = VisorTextTable() restT += ("REST enabled", bool2Str(cfg.rest().restEnabled())) - restT += ("Rest accessible folders", safe(cfg.rest().accessibleFolders(), DFLT)) - restT += ("Jetty path", safe(cfg.rest().jettyPath(), DFLT)) - restT += ("Jetty host", safe(cfg.rest().jettyHost(), DFLT)) - restT += ("Jetty port", safe(cfg.rest().jettyPort(), DFLT)) + restT += ("Rest accessible folders", safe(cfg.rest().accessibleFolders())) + restT += ("Jetty path", safe(cfg.rest().jettyPath())) + restT += ("Jetty host", safe(cfg.rest().jettyHost())) + restT += ("Jetty port", safe(cfg.rest().jettyPort())) restT += ("Tcp ssl enabled", bool2Str(cfg.rest().tcpSslEnabled())) - restT += ("Tcp ssl context factory", safe(cfg.rest().tcpSslContextFactory(), DFLT)) - restT += ("Tcp host", safe(cfg.rest().tcpHost(), DFLT)) - restT += ("Tcp port", safe(cfg.rest().tcpPort(), DFLT)) + restT += ("Tcp ssl context factory", safe(cfg.rest().tcpSslContextFactory())) + restT += ("Tcp host", safe(cfg.rest().tcpHost())) + restT += ("Tcp port", safe(cfg.rest().tcpPort())) restT.render() @@ -399,7 +392,7 @@ class VisorConfigurationCommand { println("\nNo system properties defined.") cfg.caches().foreach(cacheCfg => { - VisorCacheCommand.showCacheConfiguration("\nCache '" + safe(cacheCfg.name(), DFLT) + "':", cacheCfg) + VisorCacheCommand.showCacheConfiguration("\nCache '" + safe(cacheCfg.name()) + "':", cacheCfg) }) } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8469db79/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/disco/VisorDiscoveryCommand.scala ---------------------------------------------------------------------- diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/disco/VisorDiscoveryCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/disco/VisorDiscoveryCommand.scala index f0b1610..11689f5 100644 --- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/disco/VisorDiscoveryCommand.scala +++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/disco/VisorDiscoveryCommand.scala @@ -194,7 +194,7 @@ class VisorDiscoveryCommand { case de: VisorGridDiscoveryEvent => t +=(formatDateTime(de.timestamp()), de.name(), nodeId8(de.evtNodeId()) + (if (de.isDaemon) "(daemon)" else ""), - if (F.isEmpty(de.address())) "<n/a>" else de.address()) + if (F.isEmpty(de.address())) NA else de.address()) case _ => } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8469db79/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 852c223..8e518aa 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 @@ -36,7 +36,7 @@ import org.apache.ignite.internal.{IgniteVersionUtils, IgniteEx} import IgniteVersionUtils._ import org.apache.ignite.internal.util.lang.{GridFunc => F} import org.apache.ignite.internal.util.typedef._ -import org.apache.ignite.internal.util.{GridConfigurationFinder, IgniteUtils} +import org.apache.ignite.internal.util.{IgniteUtils => U, GridConfigurationFinder} import org.apache.ignite.internal.visor.VisorTaskArgument import org.apache.ignite.internal.visor.node.VisorNodeEventsCollectorTask import org.apache.ignite.internal.visor.node.VisorNodeEventsCollectorTask.VisorNodeEventsCollectorTaskArg @@ -51,6 +51,7 @@ import scala.collection.JavaConversions._ import scala.collection.immutable import scala.io.StdIn import scala.language.{implicitConversions, reflectiveCalls} +import scala.reflect.ClassTag import scala.util.control.Breaks._ /** @@ -143,6 +144,9 @@ object visor extends VisorTag { /** System line separator. */ final val NL = System getProperty "line.separator" + /** Display value for `null`. */ + final val NA = "<n/a>" + /** */ private var cmdLst: Seq[VisorConsoleCommandHolder] = Nil @@ -989,13 +993,34 @@ object visor extends VisorTag { * @param a Parameter. * @param dflt Value to return if `a` is `null`. */ - def safe(@Nullable a: Any, dflt: Any = ""): String = { + def safe(@Nullable a: Any, dflt: Any = NA): String = { assert(dflt != null) if (a != null) a.toString else dflt.toString } /** + * Joins array elements to string. + * + * @param arr Array. + * @param dflt Value to return if `arr` is `null` or empty. + * @return String. + */ + def arr2Str[T: ClassTag](arr: Array[T], dflt: Any = ""): String = { + if (arr != null && arr.length > 0) U.compact(arr.mkString(", ")) else dflt.toString + } + + /** + * Converts `Boolean` to 'on'/'off' string. + * + * @param bool Boolean value. + * @return String. + */ + def bool2Str(bool: Boolean): String = { + if (bool) "on" else "off" + } + + /** * Reconstructs string presentation for given argument. * * @param arg Argument to reconstruct. @@ -1288,15 +1313,15 @@ object visor extends VisorTag { t += ("Status", if (isCon) "Connected" else "Disconnected") t += ("Grid name", if (ignite == null) - "<n/a>" + NA else { val n = ignite.name if (n == null) "<default>" else n } ) - t += ("Config path", safe(cfgPath, "<n/a>")) - t += ("Uptime", if (isCon) X.timeSpan2HMS(uptime) else "<n/a>") + t += ("Config path", safe(cfgPath)) + t += ("Uptime", if (isCon) X.timeSpan2HMS(uptime) else NA) t.render() } @@ -1472,7 +1497,7 @@ object visor extends VisorTag { new URL(path) catch { case e: Exception => - val url = IgniteUtils.resolveIgniteUrl(path) + val url = U.resolveIgniteUrl(path) if (url == null) throw new IgniteException("Ignite configuration path is invalid: " + path, e) @@ -1483,7 +1508,7 @@ object visor extends VisorTag { // Add no-op logger to remove no-appender warning. val log4jTup = if (classOf[Ignition].getClassLoader.getResource("org/apache/log4j/Appender.class") != null) - IgniteUtils.addLog4jNoOpLogger() + U.addLog4jNoOpLogger() else null @@ -1496,7 +1521,7 @@ object visor extends VisorTag { "drSenderHubConfiguration", "drReceiverHubConfiguration").get1() finally { if (log4jTup != null) - IgniteUtils.removeLog4jNoOpLogger(log4jTup) + U.removeLog4jNoOpLogger(log4jTup) } if (cfgs == null || cfgs.isEmpty) @@ -1774,7 +1799,7 @@ object visor extends VisorTag { id8 + (if (v.isDefined) "(@" + v.get._1 + ")" else "") + ", " + - (if (n == null) "<n/a>" else n.addresses().headOption.getOrElse("<n/a>")) + (if (n == null) NA else n.addresses().headOption.getOrElse(NA)) } } @@ -1798,14 +1823,9 @@ object visor extends VisorTag { * Guards against invalid percent readings. * * @param v Value in '%' to guard. Any value below `0` and greater than `100` - * will return `n/a` string. + * will return `<n/a>` string. */ - def safePercent(v: Double): String = { - if (v < 0 || v > 100) - "n/a" - else - formatDouble(v) + " %" - } + def safePercent(v: Double): String = if (v < 0 || v > 100) NA else formatDouble(v) + " %" /** Convert to task argument. */ def emptyTaskArgument[A](nid: UUID): VisorTaskArgument[Void] = new VisorTaskArgument(nid, false) @@ -1898,7 +1918,7 @@ object visor extends VisorTag { t #= ("#", "Int./Ext. IPs", "Node ID8(@)", "OS", "CPUs", "MACs", "CPU Load") - val neighborhood = IgniteUtils.neighborhood(ignite.cluster.nodes()).values().toIndexedSeq + val neighborhood = U.neighborhood(ignite.cluster.nodes()).values().toIndexedSeq if (neighborhood.isEmpty) { warn("Topology is empty.") @@ -2350,7 +2370,7 @@ object visor extends VisorTag { val folder = Option(f.getParent).getOrElse("") val fileName = f.getName - logFile = new File(IgniteUtils.resolveWorkDirectory(folder, false), fileName) + logFile = new File(U.resolveWorkDirectory(folder, false), fileName) logFile.createNewFile() @@ -2440,7 +2460,7 @@ object visor extends VisorTag { out, formatDateTime(e.timestamp), nodeId8Addr(e.nid()), - IgniteUtils.compact(e.shortDisplay()) + U.compact(e.shortDisplay()) ) if (EVTS_DISCOVERY.contains(e.typeId())) @@ -2448,7 +2468,7 @@ object visor extends VisorTag { }) } finally { - IgniteUtils.close(out, null) + U.close(out, null) } } } @@ -2513,7 +2533,7 @@ object visor extends VisorTag { } logText("H/N/C" + pipe + - IgniteUtils.neighborhood(ignite.cluster.nodes()).size.toString.padTo(4, ' ') + pipe + + U.neighborhood(ignite.cluster.nodes()).size.toString.padTo(4, ' ') + pipe + ignite.cluster.nodes().size().toString.padTo(4, ' ') + pipe + m.getTotalCpus.toString.padTo(4, ' ') + pipe + bar(m.getAverageCpuLoad, m.getHeapMemoryUsed / m.getHeapMemoryTotal) + pipe @@ -2545,7 +2565,7 @@ object visor extends VisorTag { case e: IOException => () } finally { - IgniteUtils.close(out, null) + U.close(out, null) } } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8469db79/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/tasks/VisorTasksCommandSpec.scala ---------------------------------------------------------------------- diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/tasks/VisorTasksCommandSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/tasks/VisorTasksCommandSpec.scala index b8997bc..2fd2843 100644 --- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/tasks/VisorTasksCommandSpec.scala +++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/tasks/VisorTasksCommandSpec.scala @@ -42,7 +42,7 @@ class VisorTasksCommandSpec extends FlatSpec with Matchers with BeforeAndAfterAl Ignition.start(config("grid-1")) Ignition.start(config("grid-2")) - visor.open(config("grid-visor"), "n/a") + visor.open(config("visor-demo-node"), "n/a") try { val compute = visor.ignite.compute().withAsync