IGNITE-7492 Visor CMD: Added output of data region metrics to "node" command.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d6585fa2 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d6585fa2 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d6585fa2 Branch: refs/heads/ignite-6643 Commit: d6585fa2725f59b85640c5cb22da7a80a9d04f00 Parents: 09a94e8 Author: Alexey Kuznetsov <[email protected]> Authored: Wed Jan 24 18:55:44 2018 +0700 Committer: Alexey Kuznetsov <[email protected]> Committed: Wed Jan 24 18:55:44 2018 +0700 ---------------------------------------------------------------------- .../org/apache/ignite/DataRegionMetrics.java | 2 +- .../visor/cache/VisorMemoryMetrics.java | 74 +++++++++++ .../ignite/visor/commands/VisorConsole.scala | 20 ++- .../visor/commands/common/VisorTextTable.scala | 22 ++-- .../visor/commands/node/VisorNodeCommand.scala | 123 ++++++++++++------- 5 files changed, 181 insertions(+), 60 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/d6585fa2/modules/core/src/main/java/org/apache/ignite/DataRegionMetrics.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/DataRegionMetrics.java b/modules/core/src/main/java/org/apache/ignite/DataRegionMetrics.java index f5ae96b..dc48f11 100644 --- a/modules/core/src/main/java/org/apache/ignite/DataRegionMetrics.java +++ b/modules/core/src/main/java/org/apache/ignite/DataRegionMetrics.java @@ -162,7 +162,7 @@ public interface DataRegionMetrics { /** * Gets memory page size. * - * @return page size in bytes. + * @return Page size in bytes. */ public int getPageSize(); } http://git-wip-us.apache.org/repos/asf/ignite/blob/d6585fa2/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorMemoryMetrics.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorMemoryMetrics.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorMemoryMetrics.java index 37fed5a..c19fd36 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorMemoryMetrics.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorMemoryMetrics.java @@ -59,6 +59,21 @@ public class VisorMemoryMetrics extends VisorDataTransferObject { /** */ private long physicalMemoryPages; + /** */ + private long totalAllocatedSz; + + /** */ + private long physicalMemSz; + + /** */ + private long cpBufPages; + + /** */ + private long cpBufSz; + + /** */ + private int pageSize; + /** * Default constructor. */ @@ -79,6 +94,11 @@ public class VisorMemoryMetrics extends VisorDataTransferObject { dirtyPages = m.getDirtyPages(); pagesReplaceRate = m.getPagesReplaceRate(); physicalMemoryPages = m.getPhysicalMemoryPages(); + totalAllocatedSz = m.getTotalAllocatedSize(); + physicalMemSz = m.getPhysicalMemorySize(); + cpBufPages = m.getCheckpointBufferPages(); + cpBufSz = m.getCheckpointBufferSize(); + pageSize = m.getPageSize(); } /** @@ -144,6 +164,47 @@ public class VisorMemoryMetrics extends VisorDataTransferObject { return physicalMemoryPages; } + + /** + * @return Total size of memory allocated, in bytes. + */ + public long getTotalAllocatedSize() { + return totalAllocatedSz; + } + + /** + * @return Total size of pages loaded to RAM in bytes. + */ + public long getPhysicalMemorySize() { + return physicalMemSz; + } + + /** + * @return Checkpoint buffer size in pages. + */ + public long getCheckpointBufferPages() { + return cpBufPages; + } + + /** + * @return @return Checkpoint buffer size in bytes. + */ + public long getCheckpointBufferSize() { + return cpBufSz; + } + + /** + * @return Page size in bytes. + */ + public int getPageSize() { + return pageSize; + } + + /** {@inheritDoc} */ + @Override public byte getProtocolVersion() { + return V2; + } + /** {@inheritDoc} */ @Override protected void writeExternalData(ObjectOutput out) throws IOException { U.writeString(out, name); @@ -155,6 +216,11 @@ public class VisorMemoryMetrics extends VisorDataTransferObject { out.writeLong(dirtyPages); out.writeFloat(pagesReplaceRate); out.writeLong(physicalMemoryPages); + out.writeLong(totalAllocatedSz); + out.writeLong(physicalMemSz); + out.writeLong(cpBufPages); + out.writeLong(cpBufSz); + out.writeInt(pageSize); } /** {@inheritDoc} */ @@ -168,6 +234,14 @@ public class VisorMemoryMetrics extends VisorDataTransferObject { dirtyPages = in.readLong(); pagesReplaceRate = in.readFloat(); physicalMemoryPages = in.readLong(); + + if (protoVer > V1) { + totalAllocatedSz = in.readLong(); + physicalMemSz = in.readLong(); + cpBufPages = in.readLong(); + cpBufSz = in.readLong(); + pageSize = in.readInt(); + } } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/ignite/blob/d6585fa2/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/VisorConsole.scala ---------------------------------------------------------------------- diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/VisorConsole.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/VisorConsole.scala index 8bf64b7..43e11db 100644 --- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/VisorConsole.scala +++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/VisorConsole.scala @@ -170,13 +170,21 @@ class VisorConsole { } // Workaround for IDEA terminal. - val term = try { - Class.forName("com.intellij.rt.execution.application.AppMain") + val idea = Seq( + "com.intellij.rt.execution.application.AppMain", + "com.intellij.rt.execution.application.AppMainV2" + ).exists(cls => + try { + Class.forName(cls) + + true + } + catch { + case _: ClassNotFoundException => false + } + ) - new TerminalSupport(false) {} - } catch { - case _: ClassNotFoundException => null - } + val term = if (idea) new TerminalSupport(false) {} else null val reader = new ConsoleReader(inputStream, System.out, term) http://git-wip-us.apache.org/repos/asf/ignite/blob/d6585fa2/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/common/VisorTextTable.scala ---------------------------------------------------------------------- diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/common/VisorTextTable.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/common/VisorTextTable.scala index 58e3f21..6612ba4 100644 --- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/common/VisorTextTable.scala +++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/common/VisorTextTable.scala @@ -127,7 +127,7 @@ class VisorTextTable { private val rows = collection.mutable.ArrayBuffer.empty[Seq[Cell]] /** Current row, if any. */ - private var curRow: collection.mutable.ArrayBuffer[Cell] = null + private var curRow: collection.mutable.ArrayBuffer[Cell] = _ /** Table's margin, if any. */ private var margin: Margin = Margin() @@ -146,7 +146,7 @@ class VisorTextTable { /** * Flag indicating whether of not to automatically draw horizontal lines - * for multiline rows. + * for multi line rows. */ var autoBorder = true @@ -276,7 +276,7 @@ class VisorTextTable { */ def addHeaderCell(lines: Any*): VisorTextTable = { assert(lines != null) - assert(lines.length > 0) + assert(lines.nonEmpty) // Break up long line into multiple ones - if necessary. val lst = lines flatten(_.toString.grouped(maxCellWidth)) @@ -400,7 +400,7 @@ class VisorTextTable { var hdrH = 0 // Initialize column widths with header row (if any). - for (i <- 0 until hdr.size) { + for (i <- hdr.indices) { val c = hdr(i) colWs(i) = c.width @@ -409,7 +409,7 @@ class VisorTextTable { } // Calc row heights and column widths. - for (i <- 0 until rows.length; j <- 0 until colsNum) { + for (i <- rows.indices; j <- 0 until colsNum) { val c = rows(i)(j) rowHs(i) = math.max(rowHs(i), c.height) @@ -422,7 +422,7 @@ class VisorTextTable { val tbl = new GridStringBuilder() // Top margin. - for (i <- 0 until margin.top) + for (_ <- 0 until margin.top) tbl.a(" ").a(NL) // Print header, if any. @@ -433,7 +433,7 @@ class VisorTextTable { // Left margin and '|'. tbl.a(blank(margin.left)).a(HDR_VER) - for (j <- 0 until hdr.size) { + for (j <- hdr.indices) { val c = hdr(j) if (i >= 0 && i < c.height) @@ -459,14 +459,14 @@ class VisorTextTable { // Left margin and '+' tbl.a(blank(margin.left)).a(ROW_CRS) - for (k <- 0 until rows(i).size) + for (k <- rows(i).indices) tbl.a(dash(ROW_HOR, colWs(k))).a(ROW_CRS) // Right margin. tbl.a(blank(margin.right)).a(NL) } - for (i <- 0 until rows.size) { + for (i <- rows.indices) { val r = rows(i) val rowH = rowHs(i) @@ -478,7 +478,7 @@ class VisorTextTable { // Left margin and '|' tbl.a(blank(margin.left)).a(ROW_VER) - for (k <- 0 until r.size) { + for (k <- r.indices) { val c = r(k) val w = colWs(k) @@ -502,7 +502,7 @@ class VisorTextTable { } // Bottom margin. - for (i <- 1 to margin.bottom) + for (_ <- 1 to margin.bottom) tbl.a(" ").a(NL) print(tbl.toString) http://git-wip-us.apache.org/repos/asf/ignite/blob/d6585fa2/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/node/VisorNodeCommand.scala ---------------------------------------------------------------------- diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/node/VisorNodeCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/node/VisorNodeCommand.scala index b240aa5..6e1a339 100644 --- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/node/VisorNodeCommand.scala +++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/node/VisorNodeCommand.scala @@ -17,22 +17,22 @@ package org.apache.ignite.visor.commands.node +import java.util.UUID + import org.apache.ignite.cluster.ClusterNode import org.apache.ignite.internal.IgniteNodeAttributes._ import org.apache.ignite.internal.util.lang.{GridFunc => F} import org.apache.ignite.internal.util.scala.impl import org.apache.ignite.internal.util.typedef.X import org.apache.ignite.internal.util.{IgniteUtils => U} +import org.apache.ignite.internal.visor.node.{VisorNodeDataCollectorTask, VisorNodeDataCollectorTaskArg} +import org.apache.ignite.internal.visor.util.VisorTaskUtils._ import org.apache.ignite.visor.VisorTag import org.apache.ignite.visor.commands.common.{VisorConsoleCommand, VisorTextTable} import org.apache.ignite.visor.visor._ import org.jetbrains.annotations._ -import java.util.UUID - -import org.apache.ignite.internal.visor.util.VisorTaskUtils._ - import scala.collection.JavaConversions._ import scala.language.{implicitConversions, reflectiveCalls} import scala.util.control.Breaks._ @@ -105,6 +105,54 @@ class VisorNodeCommand extends VisorConsoleCommand { } } + private def printDataRegions(node: ClusterNode) { + val arg = new VisorNodeDataCollectorTaskArg(false, EVT_LAST_ORDER_KEY, EVT_THROTTLE_CNTR_KEY, false, false) + + val res = executeMulti(Seq(node.id()), classOf[VisorNodeDataCollectorTask], arg) + + val t = VisorTextTable() + + t #= ("Name", "Page size", "Pages", "Memory", "Rates", "Checkpoint buffer", "Large entries") + + val mm = res.getMemoryMetrics + + mm.values().flatten.toSeq.sortBy(_.getName.toLowerCase).foreach(m => { + // Add row. + t += ( + m.getName, + formatMemory(m.getPageSize), + ( + "Total: " + formatNumber(m.getTotalAllocatedPages), + "Dirty: " + formatNumber(m.getDirtyPages), + "Memory: " + formatNumber(m.getPhysicalMemoryPages), + "Fill factor: " + formatDouble(m.getPagesFillFactor * 100) + "%" + ), + ( + "Total: " + formatMemory(m.getTotalAllocatedSize), + "In RAM: " + formatMemory(m.getPhysicalMemorySize) + ), + ( + "Allocation: " + formatDouble(m.getAllocationRate), + "Eviction: " + formatDouble(m.getEvictionRate), + "Replace: " + formatDouble(m.getPagesReplaceRate) + ), + ( + "Pages: " + formatNumber(m.getCheckpointBufferPages), + "Size: " + formatMemory(m.getCheckpointBufferSize) + ), + formatDouble(m.getLargeEntriesPagesPercentage * 100) + "%" + ) + }) + + nl() + + println("Data region metrics:") + + t.render() + + nl() + } + /** * ===Command=== * Prints full node information. @@ -144,7 +192,7 @@ class VisorNodeCommand extends VisorConsoleCommand { try node = ignite.cluster.node(UUID.fromString(id.get)) catch { - case e: IllegalArgumentException => warn("Invalid node ID: " + id.get).^^ + case _: IllegalArgumentException => warn("Invalid node ID: " + id.get).^^ } else warn("Invalid arguments: " + args).^^ @@ -163,33 +211,38 @@ class VisorNodeCommand extends VisorConsoleCommand { (0 /: sortAddresses(node.addresses))((b, a) => { t += ("Address (" + b + ")", a); b + 1 }) - val m = node.metrics + t += ("OS info", "" + + node.attribute("os.name") + " " + + node.attribute("os.arch") + " " + + node.attribute("os.version")) - val igniteInstanceName: String = node.attribute(ATTR_IGNITE_INSTANCE_NAME) + t += ("OS user", node.attribute(ATTR_USER_NAME)) + t += ("Deployment mode", node.attribute(ATTR_DEPLOYMENT_MODE)) + t += ("Language runtime", node.attribute(ATTR_LANG_RUNTIME)) val ver = U.productVersion(node) val verStr = ver.major() + "." + ver.minor() + "." + ver.maintenance() + (if (F.isEmpty(ver.stage())) "" else "-" + ver.stage()) + t += ("Ignite version", verStr) + + val igniteInstanceName: String = node.attribute(ATTR_IGNITE_INSTANCE_NAME) + + t += ("Ignite instance name", escapeName(igniteInstanceName)) + + t += ("JRE information", node.attribute(ATTR_JIT_NAME)) + + val m = node.metrics + + t += ("JVM start time", formatDateTime(m.getStartTime)) + t += ("Node start time", formatDateTime(m.getNodeStartTime)) + t += ("Up time", X.timeSpan2HMSM(m.getUpTime)) + t += ("CPUs", formatNumber(m.getTotalCpus)) + t += ("Last metric update", formatDateTime(m.getLastUpdateTime)) + if (all) { - t += ("OS info", "" + - node.attribute("os.name") + " " + - node.attribute("os.arch") + " " + - node.attribute("os.version") - ) - t += ("OS user", node.attribute(ATTR_USER_NAME)) - t += ("Deployment mode", node.attribute(ATTR_DEPLOYMENT_MODE)) - t += ("Language runtime", node.attribute(ATTR_LANG_RUNTIME)) - t += ("Ignite version", verStr) - t += ("JRE information", node.attribute(ATTR_JIT_NAME)) t += ("Non-loopback IPs", node.attribute(ATTR_IPS)) t += ("Enabled MACs", node.attribute(ATTR_MACS)) - t += ("Ignite instance name", escapeName(igniteInstanceName)) - t += ("JVM start time", formatDateTime(m.getStartTime)) - t += ("Node start time", formatDateTime(m.getNodeStartTime)) - t += ("Up time", X.timeSpan2HMSM(m.getUpTime)) - t += ("CPUs", formatNumber(m.getTotalCpus)) - t += ("Last metric update", formatDateTime(m.getLastUpdateTime)) t += ("Maximum active jobs", formatNumber(m.getMaximumActiveJobs)) t += ("Current active jobs", formatNumber(m.getCurrentActiveJobs)) t += ("Average active jobs", formatDouble(m.getAverageActiveJobs)) @@ -209,7 +262,7 @@ class VisorNodeCommand extends VisorConsoleCommand { t += ("Current job wait time", formatNumber(m.getCurrentJobWaitTime) + "ms") t += ("Average job wait time", formatDouble(m.getAverageJobWaitTime) + "ms") t += ("Maximum job execute time", formatNumber(m.getMaximumJobExecuteTime) + "ms") - t += ("Curent job execute time", formatNumber(m.getCurrentJobExecuteTime) + "ms") + t += ("Current job execute time", formatNumber(m.getCurrentJobExecuteTime) + "ms") t += ("Average job execute time", formatDouble(m.getAverageJobExecuteTime) + "ms") t += ("Total busy time", formatNumber(m.getTotalBusyTime) + "ms") t += ("Busy time %", formatDouble(m.getBusyTimePercentage * 100) + "%") @@ -229,23 +282,7 @@ class VisorNodeCommand extends VisorConsoleCommand { t += ("Current daemon thread count", formatNumber(m.getCurrentDaemonThreadCount)) } else { - t += ("OS info", "" + - node.attribute("os.name") + " " + - node.attribute("os.arch") + " " + - node.attribute("os.version") - ) - t += ("OS user", node.attribute(ATTR_USER_NAME)) - t += ("Deployment mode", node.attribute(ATTR_DEPLOYMENT_MODE)) - t += ("Language runtime", node.attribute(ATTR_LANG_RUNTIME)) - t += ("Ignite version", verStr) - t += ("JRE information", node.attribute(ATTR_JIT_NAME)) - t += ("Ignite instance name", escapeName(igniteInstanceName)) - t += ("JVM start time", formatDateTime(m.getStartTime)) - t += ("Node start time", formatDateTime(m.getNodeStartTime)) - t += ("Up time", X.timeSpan2HMSM(m.getUpTime)) - t += ("Last metric update", formatDateTime(m.getLastUpdateTime)) - t += ("CPUs", formatNumber(m.getTotalCpus)) - t += ("Thread count", formatNumber(m.getCurrentThreadCount)) + t += ("Threads count", formatNumber(m.getCurrentThreadCount)) t += ("Cur/avg active jobs", formatNumber(m.getCurrentActiveJobs) + "/" + formatDouble(m.getAverageActiveJobs)) t += ("Cur/avg waiting jobs", formatNumber(m.getCurrentWaitingJobs) + @@ -268,7 +305,9 @@ class VisorNodeCommand extends VisorConsoleCommand { t.render() - if (!all) + if (all) + printDataRegions(node) + else println("\nUse \"-a\" flag to see detailed statistics.") } }
