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 <ijokarumawak@apache.org>
This commit is contained in:
Pierre Villard 2017-02-09 18:59:53 +01:00 committed by Koji Kawamura
parent 6fc30900b9
commit 86fb67d55c
7 changed files with 64 additions and 2 deletions

View File

@ -58,6 +58,8 @@ public class SystemDiagnosticsSnapshotDTO implements Cloneable {
private Integer totalThreads; private Integer totalThreads;
private Integer daemonThreads; private Integer daemonThreads;
private String uptime;
private StorageUsageDTO flowFileRepositoryStorageUsage; private StorageUsageDTO flowFileRepositoryStorageUsage;
private Set<StorageUsageDTO> contentRepositoryStorageUsage; private Set<StorageUsageDTO> contentRepositoryStorageUsage;
private Set<GarbageCollectionDTO> garbageCollection; private Set<GarbageCollectionDTO> garbageCollection;
@ -315,6 +317,15 @@ public class SystemDiagnosticsSnapshotDTO implements Cloneable {
this.versionInfo = versionInfo; 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 @Override
public SystemDiagnosticsSnapshotDTO clone() { public SystemDiagnosticsSnapshotDTO clone() {
final SystemDiagnosticsSnapshotDTO other = new SystemDiagnosticsSnapshotDTO(); final SystemDiagnosticsSnapshotDTO other = new SystemDiagnosticsSnapshotDTO();
@ -358,6 +369,8 @@ public class SystemDiagnosticsSnapshotDTO implements Cloneable {
other.setVersionInfo(getVersionInfo().clone()); other.setVersionInfo(getVersionInfo().clone());
other.setUptime(getUptime());
return other; return other;
} }

View File

@ -39,6 +39,8 @@ public class SystemDiagnostics implements Cloneable {
private int totalThreads; private int totalThreads;
private int daemonThreads; private int daemonThreads;
private long uptime;
private StorageUsage flowFileRepositoryStorageUsage; private StorageUsage flowFileRepositoryStorageUsage;
private Map<String, StorageUsage> contentRepositoryStorageUsage; private Map<String, StorageUsage> contentRepositoryStorageUsage;
private Map<String, GarbageCollection> garbageCollection; private Map<String, GarbageCollection> garbageCollection;
@ -181,6 +183,14 @@ public class SystemDiagnostics implements Cloneable {
this.creationTimestamp = creationTimestamp; this.creationTimestamp = creationTimestamp;
} }
public long getUptime() {
return uptime;
}
public void setUptime(long uptime) {
this.uptime = uptime;
}
@Override @Override
public SystemDiagnostics clone() { public SystemDiagnostics clone() {
final SystemDiagnostics clonedObj = new SystemDiagnostics(); final SystemDiagnostics clonedObj = new SystemDiagnostics();
@ -212,6 +222,7 @@ public class SystemDiagnostics implements Cloneable {
clonedObj.usedHeap = usedHeap; clonedObj.usedHeap = usedHeap;
clonedObj.usedNonHeap = usedNonHeap; clonedObj.usedNonHeap = usedNonHeap;
clonedObj.creationTimestamp = creationTimestamp; clonedObj.creationTimestamp = creationTimestamp;
clonedObj.uptime = uptime;
return clonedObj; return clonedObj;
} }

View File

@ -22,6 +22,7 @@ import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean; import java.lang.management.MemoryMXBean;
import java.lang.management.MemoryUsage; import java.lang.management.MemoryUsage;
import java.lang.management.OperatingSystemMXBean; import java.lang.management.OperatingSystemMXBean;
import java.lang.management.RuntimeMXBean;
import java.lang.management.ThreadMXBean; import java.lang.management.ThreadMXBean;
import java.util.Date; import java.util.Date;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@ -52,6 +53,7 @@ public class SystemDiagnosticsFactory {
final OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean(); final OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
final ThreadMXBean threads = ManagementFactory.getThreadMXBean(); final ThreadMXBean threads = ManagementFactory.getThreadMXBean();
final List<GarbageCollectorMXBean> garbageCollectors = ManagementFactory.getGarbageCollectorMXBeans(); final List<GarbageCollectorMXBean> garbageCollectors = ManagementFactory.getGarbageCollectorMXBeans();
final RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
systemDiagnostics.setDaemonThreads(threads.getDaemonThreadCount()); systemDiagnostics.setDaemonThreads(threads.getDaemonThreadCount());
systemDiagnostics.setTotalThreads(threads.getThreadCount()); systemDiagnostics.setTotalThreads(threads.getThreadCount());
@ -64,6 +66,8 @@ public class SystemDiagnosticsFactory {
systemDiagnostics.setUsedNonHeap(nonHeap.getUsed()); systemDiagnostics.setUsedNonHeap(nonHeap.getUsed());
systemDiagnostics.setMaxNonHeap(nonHeap.getMax()); systemDiagnostics.setMaxNonHeap(nonHeap.getMax());
systemDiagnostics.setUptime(runtime.getUptime());
systemDiagnostics.setAvailableProcessors(os.getAvailableProcessors()); systemDiagnostics.setAvailableProcessors(os.getAvailableProcessors());
final double systemLoad = os.getSystemLoadAverage(); final double systemLoad = os.getSystemLoadAverage();

View File

@ -2409,6 +2409,9 @@ public final class DtoFactory {
final SystemDiagnosticsSnapshotDTO.VersionInfoDTO versionInfoDto = createVersionInfoDTO(); final SystemDiagnosticsSnapshotDTO.VersionInfoDTO versionInfoDto = createVersionInfoDTO();
snapshot.setVersionInfo(versionInfoDto); snapshot.setVersionInfo(versionInfoDto);
// uptime
snapshot.setUptime(FormatUtils.formatHoursMinutesSeconds(sysDiagnostics.getUptime(), TimeUnit.MILLISECONDS));
return dto; return dto;
} }

View File

@ -127,6 +127,24 @@
</table> </table>
</div> </div>
</div> </div>
<div class="setting">
<div class="setting-header">Runtime</div>
<div id="jvm-runtime-container" class="setting-field">
<table id="jvm-runtime-table">
<tbody>
<tr>
<td class="setting-name">Uptime:</td>
</tr>
<tr>
<td><span id="uptime"></span></td>
</tr>
<tr>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
</div> </div>
<div id="system-tab-content"class="configuration-tab"> <div id="system-tab-content"class="configuration-tab">
<div class="settings-left"> <div class="settings-left">

View File

@ -181,6 +181,15 @@
resizable: true, resizable: true,
cssClass: 'cell-right', cssClass: 'cell-right',
headerCssClass: 'header-right' headerCssClass: 'header-right'
},
{
id: 'uptime',
field: 'uptime',
name: 'Uptime',
sortable: true,
resizable: true,
cssClass: 'cell-right',
headerCssClass: 'header-right'
} }
], ],
tableIdColumn: 'id', tableIdColumn: 'id',
@ -496,7 +505,7 @@
{ {
id: 'uptime', id: 'uptime',
field: 'nodeStartTime', field: 'nodeStartTime',
name: 'Uptime', name: 'Started At',
formatter: valueFormatter, formatter: valueFormatter,
resizable: true, resizable: true,
sortable: true, sortable: true,
@ -944,7 +953,8 @@
gcOldGen: garbageCollection[0].collectionCount + ' times (' + gcOldGen: garbageCollection[0].collectionCount + ' times (' +
garbageCollection[0].collectionTime + ')', garbageCollection[0].collectionTime + ')',
gcNewGen: garbageCollection[1].collectionCount + ' times (' + gcNewGen: garbageCollection[1].collectionCount + ' times (' +
garbageCollection[1].collectionTime + ')' garbageCollection[1].collectionTime + ')',
uptime: snapshot.uptime
}); });
}); });
jvmTab.rowCount = jvmTableRows.length; jvmTab.rowCount = jvmTableRows.length;

View File

@ -2300,6 +2300,9 @@
}); });
} }
// uptime
$('#uptime').text(aggregateSnapshot.uptime);
// available processors // available processors
$('#available-processors').text(aggregateSnapshot.availableProcessors); $('#available-processors').text(aggregateSnapshot.availableProcessors);