You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ai...@apache.org on 2019/08/27 16:43:05 UTC

[nifi] 11/23: NIFI-6510 Added prediction fields for use by UI, still need to be populated

This is an automated email from the ASF dual-hosted git repository.

aichrist pushed a commit to branch analytics-framework
in repository https://gitbox.apache.org/repos/asf/nifi.git

commit 84d981d6f568c1c2c47cf44cdef71bd8960b0822
Author: Matthew Burgess <ma...@apache.org>
AuthorDate: Wed Jul 24 17:09:27 2019 -0400

    NIFI-6510 Added prediction fields for use by UI, still need to be populated
---
 .../nifi/controller/status/ConnectionStatus.java   |  9 ++++++
 .../dto/status/ConnectionStatusSnapshotDTO.java    | 33 ++++++++++++++++++++++
 .../apache/nifi/cluster/manager/StatusMerger.java  | 28 ++++++++++++++++++
 .../org/apache/nifi/web/api/dto/DtoFactory.java    |  4 +++
 4 files changed, 74 insertions(+)

diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/status/ConnectionStatus.java b/nifi-api/src/main/java/org/apache/nifi/controller/status/ConnectionStatus.java
index 0e5d306..ee7dd45 100644
--- a/nifi-api/src/main/java/org/apache/nifi/controller/status/ConnectionStatus.java
+++ b/nifi-api/src/main/java/org/apache/nifi/controller/status/ConnectionStatus.java
@@ -40,6 +40,7 @@ public class ConnectionStatus implements Cloneable {
     private long outputBytes;
     private int maxQueuedCount;
     private long maxQueuedBytes;
+    private long predictionIntervalMillis;
     private int nextPredictedQueuedCount;
     private long nextPredictedQueuedBytes;
     private long predictedTimeToCountBackpressureMillis;
@@ -190,6 +191,14 @@ public class ConnectionStatus implements Cloneable {
         this.backPressureBytesThreshold = backPressureBytesThreshold;
     }
 
+    public long getPredictionIntervalMillis() {
+        return predictionIntervalMillis;
+    }
+
+    public void setPredictionIntervalMillis(long predictionIntervalMillis) {
+        this.predictionIntervalMillis = predictionIntervalMillis;
+    }
+
     public int getNextPredictedQueuedCount() {
         return nextPredictedQueuedCount;
     }
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ConnectionStatusSnapshotDTO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ConnectionStatusSnapshotDTO.java
index 3237385..f48e145 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ConnectionStatusSnapshotDTO.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ConnectionStatusSnapshotDTO.java
@@ -50,8 +50,11 @@ public class ConnectionStatusSnapshotDTO implements Cloneable {
     private Integer percentUseBytes;
     private Long predictedMillisUntilCountBackpressure = 0L;
     private Long predictedMillisUntilBytesBackpressure = 0L;
+    private Integer predictionIntervalSeconds;
     private Integer predictedCountAtNextInterval = 0;
     private Long predictedBytesAtNextInterval = 0L;
+    private Integer predictedPercentCount;
+    private Integer predictedPercentBytes;
 
     /* getters / setters */
     /**
@@ -302,6 +305,15 @@ public class ConnectionStatusSnapshotDTO implements Cloneable {
         this.predictedCountAtNextInterval = predictedCountAtNextInterval;
     }
 
+    @ApiModelProperty("The configured interval (in seconds) for predicting connection queue count and size (and percent usage).")
+    public Integer getPredictionIntervalSeconds() {
+        return predictionIntervalSeconds;
+    }
+
+    public void setPredictionIntervalSeconds(Integer predictionIntervalSeconds) {
+        this.predictionIntervalSeconds = predictionIntervalSeconds;
+    }
+
     @ApiModelProperty("The predicted total number of bytes in the queue at the next configured interval.")
     public Long getPredictedBytesAtNextInterval() {
         return predictedBytesAtNextInterval;
@@ -311,6 +323,24 @@ public class ConnectionStatusSnapshotDTO implements Cloneable {
         this.predictedBytesAtNextInterval = predictedBytesAtNextInterval;
     }
 
+    @ApiModelProperty("Predicted connection percent use regarding queued flow files count and backpressure threshold if configured.")
+    public Integer getPredictedPercentCount() {
+        return predictedPercentCount;
+    }
+
+    public void setPredictedPercentCount(Integer predictedPercentCount) {
+        this.predictedPercentCount = predictedPercentCount;
+    }
+
+    @ApiModelProperty("Predicted connection percent use regarding queued flow files size and backpressure threshold if configured.")
+    public Integer getPredictedPercentBytes() {
+        return predictedPercentBytes;
+    }
+
+    public void setPredictedPercentBytes(Integer predictedPercentBytes) {
+        this.predictedPercentBytes = predictedPercentBytes;
+    }
+
     @Override
     public ConnectionStatusSnapshotDTO clone() {
         final ConnectionStatusSnapshotDTO other = new ConnectionStatusSnapshotDTO();
@@ -337,8 +367,11 @@ public class ConnectionStatusSnapshotDTO implements Cloneable {
         other.setPercentUseCount(getPercentUseCount());
         other.setPredictedMillisUntilCountBackpressure(getPredictedMillisUntilCountBackpressure());
         other.setPredictedMillisUntilBytesBackpressure(getPredictedMillisUntilBytesBackpressure());
+        other.setPredictionIntervalSeconds(getPredictionIntervalSeconds());
         other.setPredictedCountAtNextInterval(getPredictedCountAtNextInterval());
         other.setPredictedBytesAtNextInterval(getPredictedBytesAtNextInterval());
+        other.setPredictedPercentBytes(getPredictedPercentBytes());
+        other.setPredictedPercentCount(getPredictedPercentCount());
 
         return other;
     }
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/StatusMerger.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/StatusMerger.java
index 946295a..4d21ce4 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/StatusMerger.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/StatusMerger.java
@@ -500,6 +500,34 @@ public class StatusMerger {
             target.setPercentUseCount(Math.max(target.getPercentUseCount(), toMerge.getPercentUseCount()));
         }
 
+        // Merge predicted values (minimum time to backpressure, maximum percent at next interval
+
+        if (target.getPredictionIntervalSeconds() == null) {
+            target.setPredictionIntervalSeconds(toMerge.getPredictionIntervalSeconds());
+        }
+
+        if (target.getPredictedMillisUntilBytesBackpressure() == null) {
+            target.setPredictedMillisUntilBytesBackpressure(toMerge.getPredictedMillisUntilBytesBackpressure());
+        } else if (toMerge.getPredictedMillisUntilBytesBackpressure() != null) {
+            target.setPredictedMillisUntilBytesBackpressure(Math.min(target.getPredictedMillisUntilBytesBackpressure(), toMerge.getPredictedMillisUntilBytesBackpressure()));
+        }
+        if (target.getPredictedMillisUntilCountBackpressure() == null) {
+            target.setPredictedMillisUntilCountBackpressure(toMerge.getPredictedMillisUntilCountBackpressure());
+        } else if (toMerge.getPredictedMillisUntilCountBackpressure() != null) {
+            target.setPredictedMillisUntilCountBackpressure(Math.min(target.getPredictedMillisUntilCountBackpressure(), toMerge.getPredictedMillisUntilCountBackpressure()));
+        }
+
+        if (target.getPredictedPercentBytes() == null) {
+            target.setPredictedPercentBytes(toMerge.getPredictedPercentBytes());
+        } else if (toMerge.getPercentUseBytes() != null) {
+            target.setPredictedPercentBytes(Math.max(target.getPredictedPercentBytes(), toMerge.getPredictedPercentBytes()));
+        }
+        if (target.getPredictedPercentCount() == null) {
+            target.setPredictedPercentCount(toMerge.getPredictedPercentCount());
+        } else if (toMerge.getPredictedPercentCount() != null) {
+            target.setPredictedPercentCount(Math.max(target.getPredictedPercentCount(), toMerge.getPredictedPercentCount()));
+        }
+
         updatePrettyPrintedFields(target);
     }
 
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 2ff12e6..88cc299 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
@@ -1179,11 +1179,15 @@ public final class DtoFactory {
 
         if (connectionStatus.getBackPressureObjectThreshold() > 0) {
             snapshot.setPercentUseCount(Math.min(100, StatusMerger.getUtilization(connectionStatus.getQueuedCount(), connectionStatus.getBackPressureObjectThreshold())));
+
+            snapshot.setPredictionIntervalSeconds(((Long) (connectionStatus.getPredictionIntervalMillis() / 1000L)).intValue());
             snapshot.setPredictedMillisUntilCountBackpressure(connectionStatus.getPredictedTimeToCountBackpressureMillis());
             snapshot.setPredictedCountAtNextInterval(connectionStatus.getNextPredictedQueuedCount());
         }
         if (connectionStatus.getBackPressureBytesThreshold() > 0) {
             snapshot.setPercentUseBytes(Math.min(100, StatusMerger.getUtilization(connectionStatus.getQueuedBytes(), connectionStatus.getBackPressureBytesThreshold())));
+
+            snapshot.setPredictionIntervalSeconds(((Long) (connectionStatus.getPredictionIntervalMillis() / 1000L)).intValue());
             snapshot.setPredictedMillisUntilBytesBackpressure(connectionStatus.getPredictedTimeToBytesBackpressureMillis());
             snapshot.setPredictedBytesAtNextInterval(connectionStatus.getNextPredictedQueuedBytes());
         }