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

mcgilman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/master by this push:
     new c263daf  [NIFI-7358] - Fix: Sorting on 'Estimated Time to Back 
Pressure' in the Connection summary table does not work properly - fix style 
issues - review feedback
c263daf is described below

commit c263daf20ba534aaca435826b21435c529a05505
Author: Rob Fellows <rob.fell...@gmail.com>
AuthorDate: Mon Apr 13 18:17:48 2020 -0400

    [NIFI-7358] - Fix: Sorting on 'Estimated Time to Back Pressure' in the 
Connection summary table does not work properly
    - fix style issues
    - review feedback
    
    This closes #4208
---
 .../main/webapp/js/nf/summary/nf-summary-table.js  | 38 ++++++++++++++--------
 1 file changed, 25 insertions(+), 13 deletions(-)

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 3585356..0bb87cf 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
@@ -2301,6 +2301,29 @@
 
     var sortState = {};
 
+    var getMinTimeToBackPressure = function (connection) {
+        var maxCurrentUsage = Math.max(_.get(connection, 'percentUseBytes', 
0), _.get(connection, 'percentUseCount', 0));
+
+        if (maxCurrentUsage >= 100) {
+            // currently experiencing back pressure
+            return 0;
+        }
+
+        var bytesPrediction = _.get(connection, 
'predictions.predictedMillisUntilBytesBackpressure', -1);
+        var countPrediction = _.get(connection, 
'predictions.predictedMillisUntilCountBackpressure', -1);
+
+        if (bytesPrediction < 0) {
+            // bytes prediction is unknown. return the count prediction if 
known, otherwise use the max
+            return countPrediction < 0 ? Number.MAX_VALUE : countPrediction;
+        } else if (countPrediction < 0) {
+            // count prediction is unknown but we know bytes prediction is 
known, return that
+            return bytesPrediction;
+        }
+
+        // if we get here, both predictions are known. return the minimum of 
the two
+        return Math.min(bytesPrediction, countPrediction);
+    }
+
     /**
      * Sorts the specified data using the specified sort details.
      *
@@ -2361,19 +2384,8 @@
                     return aPercentUseDataSize - bPercentUseDataSize;
                 }
             } else if (sortDetails.columnId === 'backpressurePrediction') {
-                // if the connection is at backpressure currently, "now" 
displays and not the estimate. Should account for that when sorting.
-                var aMaxCurrentUsage = Math.max(_.get(a, 'percentUseBytes', 
0), _.get(a, 'percentUseCount', 0));
-                var bMaxCurrentUsage = Math.max(_.get(b, 'percentUseBytes', 
0), _.get(b, 'percentUseCount', 0));
-
-                var aMinTime = Math.min(_.get(a, 
'predictions.predictedMillisUntilBytesBackpressure', Number.MAX_VALUE), 
_.get(a, 'predictions.predictedMillisUntilCountBackpressure', 
Number.MAX_VALUE));
-                var bMinTime = Math.min(_.get(b, 
'predictions.predictedMillisUntilBytesBackpressure', Number.MAX_VALUE), 
_.get(b, 'predictions.predictedMillisUntilCountBackpressure', 
Number.MAX_VALUE));
-
-                if (aMaxCurrentUsage >= 100) {
-                    aMinTime = 0;
-                }
-                if (bMaxCurrentUsage >= 100) {
-                    bMinTime = 0;
-                }
+                var aMinTime = getMinTimeToBackPressure(a);
+                var bMinTime = getMinTimeToBackPressure(b);
 
                 return aMinTime - bMinTime;
             } else if (sortDetails.columnId === 'sent' || sortDetails.columnId 
=== 'received' || sortDetails.columnId === 'input' || sortDetails.columnId === 
'output' || sortDetails.columnId === 'transferred') {

Reply via email to