Repository: nifi Updated Branches: refs/heads/master 1195d4c18 -> a794166d2
NIFI-3118 - Sorting the garbage collection stats and content repository entries client side. Opting to not sort server side as the property of the DTO does not allow deterministic sorting. Consequently, order would need to be implemented every time that DTO is (de)serializaed which may happen in a number of places with zero master clustering. This closes #1337. Project: http://git-wip-us.apache.org/repos/asf/nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/a794166d Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/a794166d Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/a794166d Branch: refs/heads/master Commit: a794166d2170f68f18cda5b34a7e8bd3f22e5583 Parents: 1195d4c Author: Matt Gilman <[email protected]> Authored: Wed Jan 4 13:25:11 2017 -0500 Committer: Pierre Villard <[email protected]> Committed: Mon Jan 9 18:09:25 2017 +0100 ---------------------------------------------------------------------- .../api/dto/SystemDiagnosticsSnapshotDTO.java | 18 +++++------ .../webapp/js/nf/cluster/nf-cluster-table.js | 15 ++++++--- .../webapp/js/nf/summary/nf-summary-table.js | 32 ++++++++++++++------ 3 files changed, 42 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi/blob/a794166d/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/SystemDiagnosticsSnapshotDTO.java ---------------------------------------------------------------------- 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 05826fc..1cced18 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 @@ -16,17 +16,15 @@ */ package org.apache.nifi.web.api.dto; -import java.util.Date; -import java.util.HashSet; -import java.util.Set; - -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - +import com.wordnik.swagger.annotations.ApiModelProperty; import org.apache.nifi.web.api.dto.util.DateTimeAdapter; import org.apache.nifi.web.api.dto.util.TimeAdapter; -import com.wordnik.swagger.annotations.ApiModelProperty; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import java.util.Date; +import java.util.LinkedHashSet; +import java.util.Set; /** * The diagnostics of the system this NiFi is running on. @@ -346,13 +344,13 @@ public class SystemDiagnosticsSnapshotDTO implements Cloneable { other.setFlowFileRepositoryStorageUsage(getFlowFileRepositoryStorageUsage().clone()); - final Set<StorageUsageDTO> contentRepoStorageUsage = new HashSet<>(); + final Set<StorageUsageDTO> contentRepoStorageUsage = new LinkedHashSet<>(); other.setContentRepositoryStorageUsage(contentRepoStorageUsage); for (final StorageUsageDTO usage : getContentRepositoryStorageUsage()) { contentRepoStorageUsage.add(usage.clone()); } - final Set<GarbageCollectionDTO> gcUsage = new HashSet<>(); + final Set<GarbageCollectionDTO> gcUsage = new LinkedHashSet<>(); other.setGarbageCollection(gcUsage); for (final GarbageCollectionDTO gcDto : getGarbageCollection()) { gcUsage.add(gcDto.clone()); http://git-wip-us.apache.org/repos/asf/nifi/blob/a794166d/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/cluster/nf-cluster-table.js ---------------------------------------------------------------------- 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 ff9768b..f91d735 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 @@ -678,6 +678,13 @@ nf.ClusterTable = (function () { var jvmTableRows = []; systemDiagnosticsResponse.systemDiagnostics.nodeSnapshots.forEach(function (nodeSnapshot) { var snapshot = nodeSnapshot.snapshot; + + // sort the garbage collection + var garbageCollection = snapshot.garbageCollection.sort(function (a, b) { + return a.name === b.name ? 0 : a.name > b.name ? 1 : -1; + }); + + // add the node jvm details jvmTableRows.push({ id: nodeSnapshot.nodeId, node: nodeSnapshot.address + ':' + nodeSnapshot.apiPort, @@ -689,10 +696,10 @@ nf.ClusterTable = (function () { maxNonHeap: snapshot.maxNonHeap, totalNonHeap: snapshot.totalNonHeap, usedNonHeap: snapshot.usedNonHeap, - gcOldGen: snapshot.garbageCollection[0].collectionCount + ' times (' + - snapshot.garbageCollection[0].collectionTime + ')', - gcNewGen: snapshot.garbageCollection[1].collectionCount + ' times (' + - snapshot.garbageCollection[1].collectionTime + ')' + gcOldGen: garbageCollection[0].collectionCount + ' times (' + + garbageCollection[0].collectionTime + ')', + gcNewGen: garbageCollection[1].collectionCount + ' times (' + + garbageCollection[1].collectionTime + ')' }); }); jvmTab.rowCount = jvmTableRows.length; http://git-wip-us.apache.org/repos/asf/nifi/blob/a794166d/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/summary/nf-summary-table.js ---------------------------------------------------------------------- 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 aeaa295..fba8b93 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 @@ -2260,9 +2260,16 @@ nf.SummaryTable = (function () { // garbage collection var garbageCollectionContainer = $('#garbage-collection-table tbody').empty(); - $.each(aggregateSnapshot.garbageCollection, function (_, garbageCollection) { - addGarbageCollection(garbageCollectionContainer, garbageCollection); - }); + if (nf.Common.isDefinedAndNotNull(aggregateSnapshot.garbageCollection)) { + // sort the garbage collections + var sortedGarbageCollection = aggregateSnapshot.garbageCollection.sort(function(a, b) { + return a.name === b.name ? 0 : a.name > b.name ? 1 : -1; + }); + // add each to the UI + $.each(sortedGarbageCollection, function (_, garbageCollection) { + addGarbageCollection(garbageCollectionContainer, garbageCollection); + }); + } // available processors $('#available-processors').text(aggregateSnapshot.availableProcessors); @@ -2274,15 +2281,22 @@ nf.SummaryTable = (function () { $('#processor-load-average').html(nf.Common.formatValue(aggregateSnapshot.processorLoadAverage)); } - // database storage usage + // flow file storage usage var flowFileRepositoryStorageUsageContainer = $('#flow-file-repository-storage-usage-container').empty(); addStorageUsage(flowFileRepositoryStorageUsageContainer, aggregateSnapshot.flowFileRepositoryStorageUsage); - // database storage usage + // content repo storage usage var contentRepositoryUsageContainer = $('#content-repository-storage-usage-container').empty(); - $.each(aggregateSnapshot.contentRepositoryStorageUsage, function (_, contentRepository) { - addStorageUsage(contentRepositoryUsageContainer, contentRepository); - }); + if (nf.Common.isDefinedAndNotNull(aggregateSnapshot.contentRepositoryStorageUsage)) { + // sort the content repos + var sortedContentRepositoryStorageUsage = aggregateSnapshot.contentRepositoryStorageUsage.sort(function(a, b) { + return a.identifier === b.identifier ? 0 : a.identifier > b.identifier ? 1 : -1; + }); + // add each to the UI + $.each(sortedContentRepositoryStorageUsage, function (_, contentRepository) { + addStorageUsage(contentRepositoryUsageContainer, contentRepository); + }); + } // Version var versionSpanSelectorToFieldMap = { @@ -2318,7 +2332,7 @@ nf.SummaryTable = (function () { */ var addGarbageCollection = function (container, garbageCollection) { var nameTr = $('<tr></tr>').appendTo(container); - $('<td class="setting-name"></td>').append(garbageCollection.name + ':').appendTo(nameTr); + $('<td class="setting-name"></td>').text(garbageCollection.name + ':').appendTo(nameTr); var valTr = $('<tr></tr>').appendTo(container); $('<td></td>').append($('<b></b>').text(garbageCollection.collectionCount + ' times (' + garbageCollection.collectionTime + ')')).appendTo(valTr); $('<tr></tr>').text(' ').appendTo(container);
