From 86fb67d55cae49c085bed87287c70d365ce71766 Mon Sep 17 00:00:00 2001 From: Pierre Villard Date: Thu, 9 Feb 2017 18:59:53 +0100 Subject: [PATCH] NIFI-3405 - Add uptime to JVM section in System Diagnostics renamed column for node connection date in cluster This closes #1492. Signed-off-by: Koji Kawamura --- .../api/dto/SystemDiagnosticsSnapshotDTO.java | 13 +++++++++++++ .../nifi/diagnostics/SystemDiagnostics.java | 11 +++++++++++ .../diagnostics/SystemDiagnosticsFactory.java | 4 ++++ .../apache/nifi/web/api/dto/DtoFactory.java | 3 +++ .../summary/system-diagnostics-dialog.jsp | 18 ++++++++++++++++++ .../webapp/js/nf/cluster/nf-cluster-table.js | 14 ++++++++++++-- .../webapp/js/nf/summary/nf-summary-table.js | 3 +++ 7 files changed, 64 insertions(+), 2 deletions(-) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/SystemDiagnosticsSnapshotDTO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/SystemDiagnosticsSnapshotDTO.java index 1cced18156..eabbcdb93d 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/SystemDiagnosticsSnapshotDTO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/SystemDiagnosticsSnapshotDTO.java @@ -58,6 +58,8 @@ public class SystemDiagnosticsSnapshotDTO implements Cloneable { private Integer totalThreads; private Integer daemonThreads; + private String uptime; + private StorageUsageDTO flowFileRepositoryStorageUsage; private Set contentRepositoryStorageUsage; private Set garbageCollection; @@ -315,6 +317,15 @@ public class SystemDiagnosticsSnapshotDTO implements Cloneable { this.versionInfo = versionInfo; } + @ApiModelProperty("The uptime of the Java virtual machine") + public String getUptime() { + return uptime; + } + + public void setUptime(String uptime) { + this.uptime = uptime; + } + @Override public SystemDiagnosticsSnapshotDTO clone() { final SystemDiagnosticsSnapshotDTO other = new SystemDiagnosticsSnapshotDTO(); @@ -358,6 +369,8 @@ public class SystemDiagnosticsSnapshotDTO implements Cloneable { other.setVersionInfo(getVersionInfo().clone()); + other.setUptime(getUptime()); + return other; } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/diagnostics/SystemDiagnostics.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/diagnostics/SystemDiagnostics.java index 7b50ebcd77..e599e1f572 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/diagnostics/SystemDiagnostics.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/diagnostics/SystemDiagnostics.java @@ -39,6 +39,8 @@ public class SystemDiagnostics implements Cloneable { private int totalThreads; private int daemonThreads; + private long uptime; + private StorageUsage flowFileRepositoryStorageUsage; private Map contentRepositoryStorageUsage; private Map garbageCollection; @@ -181,6 +183,14 @@ public class SystemDiagnostics implements Cloneable { this.creationTimestamp = creationTimestamp; } + public long getUptime() { + return uptime; + } + + public void setUptime(long uptime) { + this.uptime = uptime; + } + @Override public SystemDiagnostics clone() { final SystemDiagnostics clonedObj = new SystemDiagnostics(); @@ -212,6 +222,7 @@ public class SystemDiagnostics implements Cloneable { clonedObj.usedHeap = usedHeap; clonedObj.usedNonHeap = usedNonHeap; clonedObj.creationTimestamp = creationTimestamp; + clonedObj.uptime = uptime; return clonedObj; } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/diagnostics/SystemDiagnosticsFactory.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/diagnostics/SystemDiagnosticsFactory.java index 24685e9ebe..86a772ab04 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/diagnostics/SystemDiagnosticsFactory.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/diagnostics/SystemDiagnosticsFactory.java @@ -22,6 +22,7 @@ import java.lang.management.ManagementFactory; import java.lang.management.MemoryMXBean; import java.lang.management.MemoryUsage; import java.lang.management.OperatingSystemMXBean; +import java.lang.management.RuntimeMXBean; import java.lang.management.ThreadMXBean; import java.util.Date; import java.util.LinkedHashMap; @@ -52,6 +53,7 @@ public class SystemDiagnosticsFactory { final OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean(); final ThreadMXBean threads = ManagementFactory.getThreadMXBean(); final List garbageCollectors = ManagementFactory.getGarbageCollectorMXBeans(); + final RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean(); systemDiagnostics.setDaemonThreads(threads.getDaemonThreadCount()); systemDiagnostics.setTotalThreads(threads.getThreadCount()); @@ -64,6 +66,8 @@ public class SystemDiagnosticsFactory { systemDiagnostics.setUsedNonHeap(nonHeap.getUsed()); systemDiagnostics.setMaxNonHeap(nonHeap.getMax()); + systemDiagnostics.setUptime(runtime.getUptime()); + systemDiagnostics.setAvailableProcessors(os.getAvailableProcessors()); final double systemLoad = os.getSystemLoadAverage(); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java index ec0392d806..8049c12520 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java @@ -2409,6 +2409,9 @@ public final class DtoFactory { final SystemDiagnosticsSnapshotDTO.VersionInfoDTO versionInfoDto = createVersionInfoDTO(); snapshot.setVersionInfo(versionInfoDto); + // uptime + snapshot.setUptime(FormatUtils.formatHoursMinutesSeconds(sysDiagnostics.getUptime(), TimeUnit.MILLISECONDS)); + return dto; } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/summary/system-diagnostics-dialog.jsp b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/summary/system-diagnostics-dialog.jsp index 11fda4632d..15d5310746 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/summary/system-diagnostics-dialog.jsp +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/summary/system-diagnostics-dialog.jsp @@ -127,6 +127,24 @@ +
+
Runtime
+
+ + + + + + + + + + + + +
Uptime:
+
+
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/cluster/nf-cluster-table.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/cluster/nf-cluster-table.js index b9b24db53a..6bb0d4a74a 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/cluster/nf-cluster-table.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/cluster/nf-cluster-table.js @@ -181,6 +181,15 @@ resizable: true, cssClass: 'cell-right', headerCssClass: 'header-right' + }, + { + id: 'uptime', + field: 'uptime', + name: 'Uptime', + sortable: true, + resizable: true, + cssClass: 'cell-right', + headerCssClass: 'header-right' } ], tableIdColumn: 'id', @@ -496,7 +505,7 @@ { id: 'uptime', field: 'nodeStartTime', - name: 'Uptime', + name: 'Started At', formatter: valueFormatter, resizable: true, sortable: true, @@ -944,7 +953,8 @@ gcOldGen: garbageCollection[0].collectionCount + ' times (' + garbageCollection[0].collectionTime + ')', gcNewGen: garbageCollection[1].collectionCount + ' times (' + - garbageCollection[1].collectionTime + ')' + garbageCollection[1].collectionTime + ')', + uptime: snapshot.uptime }); }); jvmTab.rowCount = jvmTableRows.length; diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/summary/nf-summary-table.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/summary/nf-summary-table.js index 4a5ae2205c..700e666f0a 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/summary/nf-summary-table.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/summary/nf-summary-table.js @@ -2299,6 +2299,9 @@ addGarbageCollection(garbageCollectionContainer, garbageCollection); }); } + + // uptime + $('#uptime').text(aggregateSnapshot.uptime); // available processors $('#available-processors').text(aggregateSnapshot.availableProcessors);