Repository: nifi Updated Branches: refs/heads/NIFI-1563 ad32cb824 -> 8f187274a
NIFI-1563: - Updating UI to support restructured status history DTO. Project: http://git-wip-us.apache.org/repos/asf/nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/8f187274 Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/8f187274 Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/8f187274 Branch: refs/heads/NIFI-1563 Commit: 8f187274afdbfa08538c3b867aad664716bc8a44 Parents: ad32cb8 Author: Matt Gilman <[email protected]> Authored: Fri Mar 4 16:42:29 2016 -0500 Committer: Matt Gilman <[email protected]> Committed: Fri Mar 4 16:42:29 2016 -0500 ---------------------------------------------------------------------- .../api/dto/status/NodeStatusSnapshotsDTO.java | 85 ++++ .../web/api/dto/status/StatusHistoryDTO.java | 22 +- .../cluster/manager/impl/WebClusterManager.java | 21 +- .../src/main/webapp/js/nf/canvas/nf-actions.js | 28 +- .../src/main/webapp/js/nf/nf-status-history.js | 409 ++++++------------- .../webapp/js/nf/summary/nf-summary-table.js | 40 +- 6 files changed, 239 insertions(+), 366 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi/blob/8f187274/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/NodeStatusSnapshotsDTO.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/NodeStatusSnapshotsDTO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/NodeStatusSnapshotsDTO.java new file mode 100644 index 0000000..f70da4a --- /dev/null +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/NodeStatusSnapshotsDTO.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.web.api.dto.status; + +import com.wordnik.swagger.annotations.ApiModelProperty; + +import javax.xml.bind.annotation.XmlType; +import java.util.List; + +/** + * DTO for serializing the status history of a single component across the cluster. + */ +@XmlType(name = "nodeStatusSnapshots") +public class NodeStatusSnapshotsDTO { + + private String nodeId; + private String address; + private Integer apiPort; + private List<StatusSnapshotDTO> statusSnapshots; + + /** + * @return node's host/IP address + */ + @ApiModelProperty( + value = "The node's host/ip address." + ) + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + /** + * @return node ID + */ + @ApiModelProperty( + value = "The id of the node." + ) + public String getNodeId() { + return nodeId; + } + + public void setNodeId(String nodeId) { + this.nodeId = nodeId; + } + + /** + * @return port the node is listening for API requests + */ + @ApiModelProperty( + value = "The port the node is listening for API requests." + ) + public Integer getApiPort() { + return apiPort; + } + + public void setApiPort(Integer port) { + this.apiPort = port; + } + + @ApiModelProperty("A list of StatusSnapshotDTO objects that provide the actual metric values for the component for this node.") + public List<StatusSnapshotDTO> getStatusSnapshots() { + return statusSnapshots; + } + + public void setStatusSnapshots(List<StatusSnapshotDTO> statusSnapshots) { + this.statusSnapshots = statusSnapshots; + } +} http://git-wip-us.apache.org/repos/asf/nifi/blob/8f187274/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/StatusHistoryDTO.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/StatusHistoryDTO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/StatusHistoryDTO.java index 4a9e1e3..31d3cc3 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/StatusHistoryDTO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/StatusHistoryDTO.java @@ -16,17 +16,14 @@ */ package org.apache.nifi.web.api.dto.status; -import java.util.Date; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import com.wordnik.swagger.annotations.ApiModelProperty; +import org.apache.nifi.web.api.dto.util.TimeAdapter; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import org.apache.nifi.web.api.dto.util.TimeAdapter; - -import com.wordnik.swagger.annotations.ApiModelProperty; +import java.util.Date; +import java.util.LinkedHashMap; +import java.util.List; /** * DTO for serializing the status history of a single component across the cluster. @@ -39,8 +36,7 @@ public class StatusHistoryDTO { private LinkedHashMap<String, String> componentDetails; private List<StatusDescriptorDTO> fieldDescriptors; private List<StatusSnapshotDTO> aggregateStatusSnapshots; - private Map<String, List<StatusSnapshotDTO>> nodeStatusSnapshots; - + private List<NodeStatusSnapshotsDTO> nodeStatusSnapshots; /** * @return when this status history was generated @@ -87,13 +83,13 @@ public class StatusHistoryDTO { this.aggregateStatusSnapshots = aggregateStatusSnapshots; } - @ApiModelProperty("A Map of Node Address to a list of StatusSnapshotDTO objects that provide the actual metric values for the component, for that node. " + @ApiModelProperty("The NodeStatusSnapshotsDTO objects that provide the actual metric values for the component, for each node. " + "If the NiFi instance is not clustered, this value will be null.") - public Map<String, List<StatusSnapshotDTO>> getNodeStatusSnapshots() { + public List<NodeStatusSnapshotsDTO> getNodeStatusSnapshots() { return nodeStatusSnapshots; } - public void setNodeStatusSnapshots(Map<String, List<StatusSnapshotDTO>> nodeStatusSnapshots) { + public void setNodeStatusSnapshots(List<NodeStatusSnapshotsDTO> nodeStatusSnapshots) { this.nodeStatusSnapshots = nodeStatusSnapshots; } } http://git-wip-us.apache.org/repos/asf/nifi/blob/8f187274/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java index 3d21b55..af62111 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java @@ -224,6 +224,7 @@ import org.apache.nifi.web.api.dto.provenance.ProvenanceEventDTO; import org.apache.nifi.web.api.dto.provenance.ProvenanceRequestDTO; import org.apache.nifi.web.api.dto.provenance.ProvenanceResultsDTO; import org.apache.nifi.web.api.dto.status.ControllerStatusDTO; +import org.apache.nifi.web.api.dto.status.NodeStatusSnapshotsDTO; import org.apache.nifi.web.api.dto.status.ProcessGroupStatusDTO; import org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusDTO; import org.apache.nifi.web.api.dto.status.StatusDTO; @@ -3848,7 +3849,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C final StatusHistoryEntity responseEntity = clientResponse.getClientResponse().getEntity(StatusHistoryEntity.class); StatusHistoryDTO lastStatusHistory = null; - final Map<String, List<StatusSnapshotDTO>> nodeStatusHistories = new HashMap<>(updatedNodesMap.size()); + final List<NodeStatusSnapshotsDTO> nodeStatusSnapshots = new ArrayList<>(updatedNodesMap.size()); for (final NodeResponse nodeResponse : updatedNodesMap.values()) { if (problematicNodeResponses.contains(nodeResponse)) { continue; @@ -3859,14 +3860,18 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C lastStatusHistory = nodeStatus; final NodeIdentifier nodeId = nodeResponse.getNodeId(); - final String nodeName = nodeId.getApiAddress() + ":" + nodeId.getApiPort(); - nodeStatusHistories.put(nodeName, nodeStatus.getAggregateStatusSnapshots()); + final NodeStatusSnapshotsDTO nodeStatuSnapshot = new NodeStatusSnapshotsDTO(); + nodeStatuSnapshot.setNodeId(nodeId.getId()); + nodeStatuSnapshot.setAddress(nodeId.getApiAddress()); + nodeStatuSnapshot.setApiPort(nodeId.getApiPort()); + nodeStatuSnapshot.setStatusSnapshots(nodeStatus.getAggregateStatusSnapshots()); + nodeStatusSnapshots.add(nodeStatuSnapshot); } final StatusHistoryDTO clusterStatusHistory = new StatusHistoryDTO(); - clusterStatusHistory.setAggregateStatusSnapshots(mergeStatusHistories(nodeStatusHistories, metricDescriptors)); + clusterStatusHistory.setAggregateStatusSnapshots(mergeStatusHistories(nodeStatusSnapshots, metricDescriptors)); clusterStatusHistory.setGenerated(new Date()); - clusterStatusHistory.setNodeStatusSnapshots(nodeStatusHistories); + clusterStatusHistory.setNodeStatusSnapshots(nodeStatusSnapshots); if (lastStatusHistory != null) { clusterStatusHistory.setComponentDetails(lastStatusHistory.getComponentDetails()); clusterStatusHistory.setFieldDescriptors(lastStatusHistory.getFieldDescriptors()); @@ -4456,14 +4461,14 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C return snapshot; } - private List<StatusSnapshotDTO> mergeStatusHistories(final Map<String, List<StatusSnapshotDTO>> nodeStatusHistories, final Map<String, MetricDescriptor<?>> metricDescriptors) { + private List<StatusSnapshotDTO> mergeStatusHistories(final List<NodeStatusSnapshotsDTO> nodeStatusSnapshots, final Map<String, MetricDescriptor<?>> metricDescriptors) { // Map of "normalized Date" (i.e., a time range, essentially) to all Snapshots for that time. The list // will contain one snapshot for each node. final Map<Date, List<StatusSnapshot>> snapshotsToAggregate = new TreeMap<>(); // group status snapshot's for each node by date - for (final List<StatusSnapshotDTO> snapshotDtos : nodeStatusHistories.values()) { - for (final StatusSnapshotDTO snapshotDto : snapshotDtos) { + for (final NodeStatusSnapshotsDTO nodeStatusSnapshot : nodeStatusSnapshots) { + for (final StatusSnapshotDTO snapshotDto : nodeStatusSnapshot.getStatusSnapshots()) { final StatusSnapshot snapshot = createSnapshot(snapshotDto, metricDescriptors); final Date normalizedDate = normalizeStatusSnapshotDate(snapshot.getTimestamp(), componentStatusSnapshotMillis); List<StatusSnapshot> snapshots = snapshotsToAggregate.get(normalizedDate); http://git-wip-us.apache.org/repos/asf/nifi/blob/8f187274/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js index c0e4e61..d92ebc2 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js @@ -722,26 +722,14 @@ nf.Actions = (function () { showStats: function (selection) { if (selection.size() === 1) { var selectionData = selection.datum(); - if (nf.Canvas.isClustered()) { - if (nf.CanvasUtils.isProcessor(selection)) { - nf.StatusHistory.showClusterProcessorChart(nf.Canvas.getGroupId(), selectionData.component.id); - } else if (nf.CanvasUtils.isProcessGroup(selection)) { - nf.StatusHistory.showClusterProcessGroupChart(nf.Canvas.getGroupId(), selectionData.component.id); - } else if (nf.CanvasUtils.isRemoteProcessGroup(selection)) { - nf.StatusHistory.showClusterRemoteProcessGroupChart(nf.Canvas.getGroupId(), selectionData.component.id); - } else if (nf.CanvasUtils.isConnection(selection)) { - nf.StatusHistory.showClusterConnectionChart(nf.Canvas.getGroupId(), selectionData.component.id); - } - } else { - if (nf.CanvasUtils.isProcessor(selection)) { - nf.StatusHistory.showStandaloneProcessorChart(nf.Canvas.getGroupId(), selectionData.component.id); - } else if (nf.CanvasUtils.isProcessGroup(selection)) { - nf.StatusHistory.showStandaloneProcessGroupChart(nf.Canvas.getGroupId(), selectionData.component.id); - } else if (nf.CanvasUtils.isRemoteProcessGroup(selection)) { - nf.StatusHistory.showStandaloneRemoteProcessGroupChart(nf.Canvas.getGroupId(), selectionData.component.id); - } else if (nf.CanvasUtils.isConnection(selection)) { - nf.StatusHistory.showStandaloneConnectionChart(nf.Canvas.getGroupId(), selectionData.component.id); - } + if (nf.CanvasUtils.isProcessor(selection)) { + nf.StatusHistory.showProcessorChart(nf.Canvas.getGroupId(), selectionData.component.id); + } else if (nf.CanvasUtils.isProcessGroup(selection)) { + nf.StatusHistory.showProcessGroupChart(nf.Canvas.getGroupId(), selectionData.component.id); + } else if (nf.CanvasUtils.isRemoteProcessGroup(selection)) { + nf.StatusHistory.showRemoteProcessGroupChart(nf.Canvas.getGroupId(), selectionData.component.id); + } else if (nf.CanvasUtils.isConnection(selection)) { + nf.StatusHistory.showConnectionChart(nf.Canvas.getGroupId(), selectionData.component.id); } } }, http://git-wip-us.apache.org/repos/asf/nifi/blob/8f187274/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-status-history.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-status-history.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-status-history.js index ac97726..74a3878 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-status-history.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-status-history.js @@ -19,8 +19,8 @@ nf.StatusHistory = (function () { var config = { - clusterInstanceId: 'cluster-instance-id', - clusterInstanceLabel: 'Cluster', + nifiInstanceId: 'nifi-instance-id', + nifiInstanceLabel: 'NiFi', type: { processor: 'Processor', inputPort: 'Input Port', @@ -33,11 +33,7 @@ nf.StatusHistory = (function () { label: 'Label' }, urls: { - processGroups: '../nifi-api/controller/process-groups/', - clusterProcessor: '../nifi-api/cluster/processors/', - clusterProcessGroup: '../nifi-api/cluster/process-groups/', - clusterRemoteProcessGroup: '../nifi-api/cluster/remote-process-groups/', - clusterConnection: '../nifi-api/cluster/connections/' + processGroups: '../nifi-api/controller/process-groups/' } }; @@ -83,73 +79,48 @@ nf.StatusHistory = (function () { var instances = null; /** - * Handles the status history response from a clustered NiFi. + * Handles the status history response. * - * @param {type} groupId - * @param {type} id - * @param {type} clusterStatusHistory - * @param {type} componentType - * @param {type} selectedDescriptor + * @param {string} groupId + * @param {string} id + * @param {object} componentStatusHistory + * @param {string} componentType + * @param {object} selectedDescriptor */ - var handleClusteredStatusHistoryResponse = function (groupId, id, clusterStatusHistory, componentType, selectedDescriptor) { + var handleStatusHistoryResponse = function (groupId, id, componentStatusHistory, componentType, selectedDescriptor) { // update the last refreshed - $('#status-history-last-refreshed').text(clusterStatusHistory.generated); + $('#status-history-last-refreshed').text(componentStatusHistory.generated); // initialize the status history var statusHistory = { groupId: groupId, id: id, type: componentType, - clustered: true, instances: [] }; - var descriptors = null; - - // get the status history for the entire cluster - var aggregateStatusHistory = clusterStatusHistory.clusterStatusHistory; + // get the descriptors + var descriptors = componentStatusHistory.fieldDescriptors; + statusHistory.details = componentStatusHistory.componentDetails; + statusHistory.selectedDescriptor = nf.Common.isUndefined(selectedDescriptor) ? descriptors[0] : selectedDescriptor; // ensure enough status snapshots - if (aggregateStatusHistory.statusSnapshots.length > 1) { - // only do these once - if (descriptors === null) { - // get the descriptors - descriptors = aggregateStatusHistory.fieldDescriptors; - - statusHistory.details = aggregateStatusHistory.details; - statusHistory.selectedDescriptor = nf.Common.isUndefined(selectedDescriptor) ? descriptors[0] : selectedDescriptor; - } - - // but ensure each instance is added + if (nf.Common.isDefinedAndNotNull(componentStatusHistory.aggregateStatusSnapshots) && componentStatusHistory.aggregateStatusSnapshots.length > 1) { statusHistory.instances.push({ - id: config.clusterInstanceId, - label: config.clusterInstanceLabel, - snapshots: aggregateStatusHistory.statusSnapshots + id: config.nifiInstanceId, + label: config.nifiInstanceLabel, + snapshots: componentStatusHistory.aggregateStatusSnapshots }); } - // get the status for each node in the cluster - $.each(clusterStatusHistory.nodeStatusHistory, function (_, nodeStatusHistory) { - var node = nodeStatusHistory.node; - var statusHistoryForNode = nodeStatusHistory.statusHistory; - + // get the status for each node in the cluster if applicable + $.each(componentStatusHistory.nodeStatusSnapshots, function (_, nodeStatusSnapshots) { // ensure enough status snapshots - if (statusHistoryForNode.statusSnapshots.length > 1) { - - // only do these once - if (descriptors === null) { - // get the descriptors - descriptors = statusHistoryForNode.fieldDescriptors; - - statusHistory.details = statusHistoryForNode.details; - statusHistory.selectedDescriptor = nf.Common.isUndefined(selectedDescriptor) ? descriptors[0] : selectedDescriptor; - } - - // but ensure each instance is added + if (nf.Common.isDefinedAndNotNull(nodeStatusSnapshots.statusSnapshots) && nodeStatusSnapshots.statusSnapshots.length > 1) { statusHistory.instances.push({ - id: node.nodeId, - label: node.address + ':' + node.apiPort, - snapshots: statusHistoryForNode.statusSnapshots + id: nodeStatusSnapshots.nodeId, + label: nodeStatusSnapshots.address + ':' + nodeStatusSnapshots.apiPort, + snapshots: nodeStatusSnapshots.statusSnapshots }); } }); @@ -167,50 +138,6 @@ nf.StatusHistory = (function () { }; /** - * Handles the status history response for a standalone NiFi. - * - * @param {type} groupId - * @param {type} id - * @param {type} statusHistory - * @param {type} componentType - * @param {type} selectedDescriptor - */ - var handleStandaloneStatusHistoryResponse = function (groupId, id, statusHistory, componentType, selectedDescriptor) { - // ensure there are sufficent snapshots - if (statusHistory.statusSnapshots.length > 1) { - // update the last refreshed - $('#status-history-last-refreshed').text(statusHistory.generated); - - // detect the available fields - var descriptors = statusHistory.fieldDescriptors; - - // build the status history - var statusHistory = { - groupId: groupId, - id: id, - details: statusHistory.details, - type: componentType, - clustered: false, - selectedDescriptor: nf.Common.isUndefined(selectedDescriptor) ? descriptors[0] : selectedDescriptor, - instances: [{ - id: '', - label: '', - snapshots: statusHistory.statusSnapshots - }] - }; - - // store the status history - $('#status-history-dialog').data('status-history', statusHistory); - - // chart the status history - chart(statusHistory, descriptors); - return; - } - - insufficientHistory(); - }; - - /** * Shows an error message stating there is insufficient history available. */ var insufficientHistory = function () { @@ -785,127 +712,107 @@ nf.StatusHistory = (function () { }); }); - if (statusHistory.clustered) { - // consider visible nodes with data in the brush - var nodes = $.grep(withinBrush, function (d) { - return d.id !== config.clusterInstanceId && d.visible && d.values.length > 0; - }); - - var nodeMinValue = nodes.length === 0 ? 'NA' : formatters[selectedDescriptor.formatter](getMinValue(nodes)); - var nodeMeanValue = nodes.length === 0 ? 'NA' : formatters[selectedDescriptor.formatter](getMeanValue(nodes)); - var nodeMaxValue = nodes.length === 0 ? 'NA' : formatters[selectedDescriptor.formatter](getMaxValue(nodes)); - - // update the currently displayed min/max/mean - $('#node-aggregate-statistics').text(nodeMinValue + ' / ' + nodeMaxValue + ' / ' + nodeMeanValue); + // consider visible nodes with data in the brush + var nodes = $.grep(withinBrush, function (d) { + return d.id !== config.nifiInstanceId && d.visible && d.values.length > 0; + }); - // only consider the cluster with data in the brush - var cluster = $.grep(withinBrush, function (d) { - return d.id === config.clusterInstanceId && d.visible && d.values.length > 0; - }); + var nodeMinValue = nodes.length === 0 ? 'NA' : formatters[selectedDescriptor.formatter](getMinValue(nodes)); + var nodeMeanValue = nodes.length === 0 ? 'NA' : formatters[selectedDescriptor.formatter](getMeanValue(nodes)); + var nodeMaxValue = nodes.length === 0 ? 'NA' : formatters[selectedDescriptor.formatter](getMaxValue(nodes)); - // determine the cluster values - var clusterMinValue = cluster.length === 0 ? 'NA' : formatters[selectedDescriptor.formatter](getMinValue(cluster)); - var clusterMeanValue = cluster.length === 0 ? 'NA' : formatters[selectedDescriptor.formatter](getMeanValue(cluster)); - var clusterMaxValue = cluster.length === 0 ? 'NA' : formatters[selectedDescriptor.formatter](getMaxValue(cluster)); + // update the currently displayed min/max/mean + $('#node-aggregate-statistics').text(nodeMinValue + ' / ' + nodeMaxValue + ' / ' + nodeMeanValue); - // update the cluster min/max/mean - $('#cluster-aggregate-statistics').text(clusterMinValue + ' / ' + clusterMaxValue + ' / ' + clusterMeanValue); - } else { - // only consider data in the brush - var instance = $.grep(withinBrush, function (d) { - return d.values.length > 0; - }); + // only consider the cluster with data in the brush + var cluster = $.grep(withinBrush, function (d) { + return d.id === config.nifiInstanceId && d.visible && d.values.length > 0; + }); - // determine the min, max, mean - var instanceMinValue = instance.length === 0 ? 0 : formatters[selectedDescriptor.formatter](getMinValue(instance)); - var instanceMeanValue = instance.length === 0 ? 0 : formatters[selectedDescriptor.formatter](getMeanValue(instance)); - var instanceMaxValue = instance.length === 0 ? 0 : formatters[selectedDescriptor.formatter](getMaxValue(instance)); + // determine the cluster values + var clusterMinValue = cluster.length === 0 ? 'NA' : formatters[selectedDescriptor.formatter](getMinValue(cluster)); + var clusterMeanValue = cluster.length === 0 ? 'NA' : formatters[selectedDescriptor.formatter](getMeanValue(cluster)); + var clusterMaxValue = cluster.length === 0 ? 'NA' : formatters[selectedDescriptor.formatter](getMaxValue(cluster)); - // update the instance min/max/mean - $('#instance-aggregate-statistics').text(instanceMinValue + ' / ' + instanceMaxValue + ' / ' + instanceMeanValue); - } + // update the cluster min/max/mean + $('#cluster-aggregate-statistics').text(clusterMinValue + ' / ' + clusterMaxValue + ' / ' + clusterMeanValue); }; // ---------------- // build the legend // ---------------- - if (statusHistory.clustered) { - // identify all nodes and sort - var nodes = $.grep(statusData, function (status) { - return status.id !== config.clusterInstanceId; - }).sort(function (a, b) { - return a.label < b.label ? -1 : a.label > b.label ? 1 : 0; - }); - - // adds a legend entry for the specified instance - var addLegendEntry = function (legend, instance) { - // create the label and the checkbox - var instanceLabelElement = $('<div></div>').addClass('legend-label').css('color', color(instance.label)).text(instance.label).ellipsis(); - var instanceCheckboxElement = $('<div class="nf-checkbox"></div>').on('click', function () { - // get the line and the control points for this instance (select all for the line to update control and main charts) - var chartLine = d3.selectAll('path.chart-line-' + instance.id); - var markGroup = d3.select('g.mark-group-' + instance.id); - - // determine if it was hidden - var isHidden = markGroup.classed('hidden'); - - // toggle the visibility - chartLine.classed('hidden', function () { - return !isHidden; - }); - markGroup.classed('hidden', function () { - return !isHidden; - }); - - // update whether its visible - instance.visible = isHidden; + // identify all nodes and sort + var nodes = $.grep(statusData, function (status) { + return status.id !== config.nifiInstanceId; + }).sort(function (a, b) { + return a.label < b.label ? -1 : a.label > b.label ? 1 : 0; + }); - // record the current status so it persists across refreshes - instances[instance.id] = instance.visible; + // adds a legend entry for the specified instance + var addLegendEntry = function (legend, instance) { + // create the label and the checkbox + var instanceLabelElement = $('<div></div>').addClass('legend-label').css('color', color(instance.label)).text(instance.label).ellipsis(); + var instanceCheckboxElement = $('<div class="nf-checkbox"></div>').on('click', function () { + // get the line and the control points for this instance (select all for the line to update control and main charts) + var chartLine = d3.selectAll('path.chart-line-' + instance.id); + var markGroup = d3.select('g.mark-group-' + instance.id); + + // determine if it was hidden + var isHidden = markGroup.classed('hidden'); + + // toggle the visibility + chartLine.classed('hidden', function () { + return !isHidden; + }); + markGroup.classed('hidden', function () { + return !isHidden; + }); - // update the brush - brushed(); - }).addClass(instance.visible ? 'checkbox-checked' : 'checkbox-unchecked'); + // update whether its visible + instance.visible = isHidden; - // add the legend entry - $('<div class="legend-entry"></div>').append(instanceCheckboxElement).append(instanceLabelElement).on('mouseenter', function () { - d3.selectAll('path.chart-line-' + instance.id).classed('over', true); - }).on('mouseleave', function () { - d3.selectAll('path.chart-line-' + instance.id).classed('over', false); - }).appendTo(legend); - }; + // record the current status so it persists across refreshes + instances[instance.id] = instance.visible; - // get the cluster instance - var cluster = $.grep(statusData, function (status) { - return status.id === config.clusterInstanceId; - }); + // update the brush + brushed(); + }).addClass(instance.visible ? 'checkbox-checked' : 'checkbox-unchecked'); + + // add the legend entry + $('<div class="legend-entry"></div>').append(instanceCheckboxElement).append(instanceLabelElement).on('mouseenter', function () { + d3.selectAll('path.chart-line-' + instance.id).classed('over', true); + }).on('mouseleave', function () { + d3.selectAll('path.chart-line-' + instance.id).classed('over', false); + }).appendTo(legend); + }; - // build the cluster container - var clusterDetailsContainer = buildDetailsContainer('Cluster'); + // get the cluster instance + var cluster = $.grep(statusData, function (status) { + return status.id === config.nifiInstanceId; + }); - // add the total cluster values - addDetailItem(clusterDetailsContainer, 'Min / Max / Mean', '', 'cluster-aggregate-statistics'); + // build the cluster container + var clusterDetailsContainer = buildDetailsContainer('NiFi'); - // build the cluster legend - addLegendEntry(clusterDetailsContainer, cluster[0]); + // add the total cluster values + addDetailItem(clusterDetailsContainer, 'Min / Max / Mean', '', 'cluster-aggregate-statistics'); - // if there are entries to render - if (nodes.length > 0) { - // build the cluster container - var nodeDetailsContainer = buildDetailsContainer('Nodes'); + // build the cluster legend + addLegendEntry(clusterDetailsContainer, cluster[0]); - // add the total cluster values - addDetailItem(nodeDetailsContainer, 'Min / Max / Mean', '', 'node-aggregate-statistics'); + // if there are entries to render + if (nodes.length > 0) { + // build the cluster container + var nodeDetailsContainer = buildDetailsContainer('Nodes'); - // add each legend entry - $.each(nodes, function (_, instance) { - addLegendEntry(nodeDetailsContainer, instance); - }); - } - } else { // add the total cluster values - addDetailItem(detailsContainer, 'Min / Max / Mean', '', 'instance-aggregate-statistics'); + addDetailItem(nodeDetailsContainer, 'Min / Max / Mean', '', 'node-aggregate-statistics'); + + // add each legend entry + $.each(nodes, function (_, instance) { + addLegendEntry(nodeDetailsContainer, instance); + }); } // update the brush @@ -1135,29 +1042,13 @@ nf.StatusHistory = (function () { var statusHistory = $('#status-history-dialog').data('status-history'); if (statusHistory !== null) { if (statusHistory.type === config.type.processor) { - if (statusHistory.clustered === true) { - nf.StatusHistory.showClusterProcessorChart(statusHistory.groupId, statusHistory.id, statusHistory.selectedDescriptor); - } else { - nf.StatusHistory.showStandaloneProcessorChart(statusHistory.groupId, statusHistory.id, statusHistory.selectedDescriptor); - } + nf.StatusHistory.showProcessorChart(statusHistory.groupId, statusHistory.id, statusHistory.selectedDescriptor); } else if (statusHistory.type === config.type.processGroup) { - if (statusHistory.clustered === true) { - nf.StatusHistory.showClusterProcessGroupChart(statusHistory.groupId, statusHistory.id, statusHistory.selectedDescriptor); - } else { - nf.StatusHistory.showStandaloneProcessGroupChart(statusHistory.groupId, statusHistory.id, statusHistory.selectedDescriptor); - } + nf.StatusHistory.showProcessGroupChart(statusHistory.groupId, statusHistory.id, statusHistory.selectedDescriptor); } else if (statusHistory.type === config.type.remoteProcessGroup) { - if (statusHistory.clustered === true) { - nf.StatusHistory.showClusterRemoteProcessGroupChart(statusHistory.groupId, statusHistory.id, statusHistory.selectedDescriptor); - } else { - nf.StatusHistory.showStandaloneRemoteProcessGroupChart(statusHistory.groupId, statusHistory.id, statusHistory.selectedDescriptor); - } + nf.StatusHistory.showRemoteProcessGroupChart(statusHistory.groupId, statusHistory.id, statusHistory.selectedDescriptor); } else { - if (statusHistory.clustered === true) { - nf.StatusHistory.showClusterConnectionChart(statusHistory.groupId, statusHistory.id, statusHistory.selectedDescriptor); - } else { - nf.StatusHistory.showStandaloneConnectionChart(statusHistory.groupId, statusHistory.id, statusHistory.selectedDescriptor); - } + nf.StatusHistory.showConnectionChart(statusHistory.groupId, statusHistory.id, statusHistory.selectedDescriptor); } } }); @@ -1196,87 +1087,19 @@ nf.StatusHistory = (function () { }, /** - * Shows the status history for the specified connection across the cluster. - * - * @param {type} groupId - * @param {type} connectionId - * @param {type} selectedDescriptor - */ - showClusterConnectionChart: function (groupId, connectionId, selectedDescriptor) { - $.ajax({ - type: 'GET', - url: config.urls.clusterConnection + encodeURIComponent(connectionId) + '/status/history', - dataType: 'json' - }).done(function (response) { - handleClusteredStatusHistoryResponse(groupId, connectionId, response.clusterStatusHistory, config.type.connection, selectedDescriptor); - }).fail(nf.Common.handleAjaxError); - }, - - /** - * Shows the status history for the specified processor across the cluster. - * - * @param {type} groupId - * @param {type} processorId - * @param {type} selectedDescriptor - */ - showClusterProcessorChart: function (groupId, processorId, selectedDescriptor) { - $.ajax({ - type: 'GET', - url: config.urls.clusterProcessor + encodeURIComponent(processorId) + '/status/history', - dataType: 'json' - }).done(function (response) { - handleClusteredStatusHistoryResponse(groupId, processorId, response.clusterStatusHistory, config.type.processor, selectedDescriptor); - }).fail(nf.Common.handleAjaxError); - }, - - /** - * Shows the status history for the specified process group across the cluster. - * - * @param {type} groupId - * @param {type} processGroupId - * @param {type} selectedDescriptor - */ - showClusterProcessGroupChart: function (groupId, processGroupId, selectedDescriptor) { - $.ajax({ - type: 'GET', - url: config.urls.clusterProcessGroup + encodeURIComponent(processGroupId) + '/status/history', - dataType: 'json' - }).done(function (response) { - handleClusteredStatusHistoryResponse(groupId, processGroupId, response.clusterStatusHistory, config.type.processGroup, selectedDescriptor); - }).fail(nf.Common.handleAjaxError); - }, - - /** - * Shows the status history for the specified remote process group across the cluster. - * - * @param {type} groupId - * @param {type} remoteProcessGroupId - * @param {type} selectedDescriptor - */ - showClusterRemoteProcessGroupChart: function (groupId, remoteProcessGroupId, selectedDescriptor) { - $.ajax({ - type: 'GET', - url: config.urls.clusterRemoteProcessGroup + encodeURIComponent(remoteProcessGroupId) + '/status/history', - dataType: 'json' - }).done(function (response) { - handleClusteredStatusHistoryResponse(groupId, remoteProcessGroupId, response.clusterStatusHistory, config.type.remoteProcessGroup, selectedDescriptor); - }).fail(nf.Common.handleAjaxError); - }, - - /** * Shows the status history for the specified connection in this instance. * * @param {type} groupId * @param {type} connectionId * @param {type} selectedDescriptor */ - showStandaloneConnectionChart: function (groupId, connectionId, selectedDescriptor) { + showConnectionChart: function (groupId, connectionId, selectedDescriptor) { $.ajax({ type: 'GET', url: config.urls.processGroups + encodeURIComponent(groupId) + '/connections/' + encodeURIComponent(connectionId) + '/status/history', dataType: 'json' }).done(function (response) { - handleStandaloneStatusHistoryResponse(groupId, connectionId, response.statusHistory, config.type.connection, selectedDescriptor); + handleStatusHistoryResponse(groupId, connectionId, response.statusHistory, config.type.connection, selectedDescriptor); }).fail(nf.Common.handleAjaxError); }, @@ -1287,13 +1110,13 @@ nf.StatusHistory = (function () { * @param {type} processorId * @param {type} selectedDescriptor */ - showStandaloneProcessorChart: function (groupId, processorId, selectedDescriptor) { + showProcessorChart: function (groupId, processorId, selectedDescriptor) { $.ajax({ type: 'GET', url: config.urls.processGroups + encodeURIComponent(groupId) + '/processors/' + encodeURIComponent(processorId) + '/status/history', dataType: 'json' }).done(function (response) { - handleStandaloneStatusHistoryResponse(groupId, processorId, response.statusHistory, config.type.processor, selectedDescriptor); + handleStatusHistoryResponse(groupId, processorId, response.statusHistory, config.type.processor, selectedDescriptor); }).fail(nf.Common.handleAjaxError); }, @@ -1304,13 +1127,13 @@ nf.StatusHistory = (function () { * @param {type} processGroupId * @param {type} selectedDescriptor */ - showStandaloneProcessGroupChart: function (groupId, processGroupId, selectedDescriptor) { + showProcessGroupChart: function (groupId, processGroupId, selectedDescriptor) { $.ajax({ type: 'GET', url: config.urls.processGroups + encodeURIComponent(processGroupId) + '/status/history', dataType: 'json' }).done(function (response) { - handleStandaloneStatusHistoryResponse(groupId, processGroupId, response.statusHistory, config.type.processGroup, selectedDescriptor); + handleStatusHistoryResponse(groupId, processGroupId, response.statusHistory, config.type.processGroup, selectedDescriptor); }).fail(nf.Common.handleAjaxError); }, @@ -1321,13 +1144,13 @@ nf.StatusHistory = (function () { * @param {type} remoteProcessGroupId * @param {type} selectedDescriptor */ - showStandaloneRemoteProcessGroupChart: function (groupId, remoteProcessGroupId, selectedDescriptor) { + showRemoteProcessGroupChart: function (groupId, remoteProcessGroupId, selectedDescriptor) { $.ajax({ type: 'GET', url: config.urls.processGroups + encodeURIComponent(groupId) + '/remote-process-groups/' + encodeURIComponent(remoteProcessGroupId) + '/status/history', dataType: 'json' }).done(function (response) { - handleStandaloneStatusHistoryResponse(groupId, remoteProcessGroupId, response.statusHistory, config.type.remoteProcessGroup, selectedDescriptor); + handleStatusHistoryResponse(groupId, remoteProcessGroupId, response.statusHistory, config.type.remoteProcessGroup, selectedDescriptor); }).fail(nf.Common.handleAjaxError); } }; http://git-wip-us.apache.org/repos/asf/nifi/blob/8f187274/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 a48758a..057559a 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 @@ -364,11 +364,7 @@ nf.SummaryTable = (function () { } if (nf.Common.SUPPORTS_SVG) { - if (isClustered) { - markup += '<img src="images/iconChart.png" title="Show History" class="pointer show-cluster-processor-status-history" style="margin-top: 2px;"/> '; - } else { - markup += '<img src="images/iconChart.png" title="Show History" class="pointer show-processor-status-history" style="margin-top: 2px;"/> '; - } + markup += '<img src="images/iconChart.png" title="Show History" class="pointer show-processor-status-history" style="margin-top: 2px;"/> '; } if (isClustered) { @@ -432,10 +428,8 @@ nf.SummaryTable = (function () { if (processorsGrid.getColumns()[args.cell].id === 'actions') { if (target.hasClass('go-to')) { goTo(item.groupId, item.id); - } else if (target.hasClass('show-cluster-processor-status-history')) { - nf.StatusHistory.showClusterProcessorChart(item.groupId, item.id); } else if (target.hasClass('show-processor-status-history')) { - nf.StatusHistory.showStandaloneProcessorChart(item.groupId, item.id); + nf.StatusHistory.showProcessorChart(item.groupId, item.id); } else if (target.hasClass('show-cluster-processor-summary')) { // load the cluster processor summary loadClusterProcessorSummary(item.id); @@ -616,11 +610,7 @@ nf.SummaryTable = (function () { } if (nf.Common.SUPPORTS_SVG) { - if (isClustered) { - markup += '<img src="images/iconChart.png" title="Show History" class="pointer show-cluster-connection-status-history" style="margin-top: 2px;"/> '; - } else { - markup += '<img src="images/iconChart.png" title="Show History" class="pointer show-connection-status-history" style="margin-top: 2px;"/> '; - } + markup += '<img src="images/iconChart.png" title="Show History" class="pointer show-connection-status-history" style="margin-top: 2px;"/> '; } if (isClustered) { @@ -684,10 +674,8 @@ nf.SummaryTable = (function () { if (connectionsGrid.getColumns()[args.cell].id === 'actions') { if (target.hasClass('go-to')) { goTo(item.groupId, item.id); - } else if (target.hasClass('show-cluster-connection-status-history')) { - nf.StatusHistory.showClusterConnectionChart(item.groupId, item.id); } else if (target.hasClass('show-connection-status-history')) { - nf.StatusHistory.showStandaloneConnectionChart(item.groupId, item.id); + nf.StatusHistory.showConnectionChart(item.groupId, item.id); } else if (target.hasClass('show-cluster-connection-summary')) { // load the cluster processor summary loadClusterConnectionSummary(item.id); @@ -848,11 +836,7 @@ nf.SummaryTable = (function () { } if (nf.Common.SUPPORTS_SVG) { - if (isClustered) { - markup += '<img src="images/iconChart.png" title="Show History" class="pointer show-cluster-process-group-status-history" style="margin-top: 2px;"/> '; - } else { - markup += '<img src="images/iconChart.png" title="Show History" class="pointer show-process-group-status-history" style="margin-top: 2px;"/> '; - } + markup += '<img src="images/iconChart.png" title="Show History" class="pointer show-process-group-status-history" style="margin-top: 2px;"/> '; } if (isClustered) { @@ -919,10 +903,8 @@ nf.SummaryTable = (function () { parent.nf.CanvasUtils.enterGroup(item.id); parent.$('#shell-close-button').click(); } - } else if (target.hasClass('show-cluster-process-group-status-history')) { - nf.StatusHistory.showClusterProcessGroupChart(item.groupId, item.id); } else if (target.hasClass('show-process-group-status-history')) { - nf.StatusHistory.showStandaloneProcessGroupChart(item.groupId, item.id); + nf.StatusHistory.showProcessGroupChart(item.groupId, item.id); } else if (target.hasClass('show-cluster-process-group-summary')) { // load the cluster processor summary loadClusterProcessGroupSummary(item.id); @@ -1563,11 +1545,7 @@ nf.SummaryTable = (function () { } if (nf.Common.SUPPORTS_SVG) { - if (isClustered) { - markup += '<img src="images/iconChart.png" title="Show History" class="pointer show-cluster-remote-process-group-status-history" style="margin-top: 2px;"/> '; - } else { - markup += '<img src="images/iconChart.png" title="Show History" class="pointer show-remote-process-group-status-history" style="margin-top: 2px;"/> '; - } + markup += '<img src="images/iconChart.png" title="Show History" class="pointer show-remote-process-group-status-history" style="margin-top: 2px;"/> '; } if (isClustered) { @@ -1631,10 +1609,8 @@ nf.SummaryTable = (function () { if (remoteProcessGroupsGrid.getColumns()[args.cell].id === 'actions') { if (target.hasClass('go-to')) { goTo(item.groupId, item.id); - } else if (target.hasClass('show-cluster-remote-process-group-status-history')) { - nf.StatusHistory.showClusterRemoteProcessGroupChart(item.groupId, item.id); } else if (target.hasClass('show-remote-process-group-status-history')) { - nf.StatusHistory.showStandaloneRemoteProcessGroupChart(item.groupId, item.id); + nf.StatusHistory.showRemoteProcessGroupChart(item.groupId, item.id); } else if (target.hasClass('show-cluster-remote-process-group-summary')) { // load the cluster processor summary loadClusterRemoteProcessGroupSummary(item.id);
