markap14 commented on a change in pull request #3681: NIFI-6510 - Analytics 
framework
URL: https://github.com/apache/nifi/pull/3681#discussion_r320944831
 
 

 ##########
 File path: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java
 ##########
 @@ -1178,16 +1183,63 @@ public ConnectionStatusDTO 
createConnectionStatusDto(final ConnectionStatus conn
 
         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());
+            
snapshot.setPredictedPercentCount(connectionStatus.getPredictedPercentCount());
+            
snapshot.setPredictedPercentBytes(connectionStatus.getPredictedPercentBytes());
+            
snapshot.setPredictionIntervalSeconds(((Long)(connectionStatus.getPredictionIntervalMillis()
 / 1000L)).intValue());
         }
         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());
+            
snapshot.setPredictedPercentCount(connectionStatus.getPredictedPercentCount());
+            
snapshot.setPredictedPercentBytes(connectionStatus.getPredictedPercentBytes());
+            
snapshot.setPredictionIntervalSeconds(((Long)(connectionStatus.getPredictionIntervalMillis()
 / 1000L)).intValue());
         }
 
         StatusMerger.updatePrettyPrintedFields(snapshot);
 
         return connectionStatusDto;
     }
 
+    public ConnectionStatisticsDTO createConnectionStatisticsDto(final 
Connection connection, final StatusAnalytics statusAnalytics) {
+        final ConnectionStatisticsDTO connectionStatisticsDTO = new 
ConnectionStatisticsDTO();
+
+        
connectionStatisticsDTO.setGroupId(connection.getProcessGroup().getIdentifier());
+        connectionStatisticsDTO.setId(connection.getIdentifier());
+        connectionStatisticsDTO.setName(connection.getName());
 
 Review comment:
   The Authorization that is checked for this endpoint is the authority to READ 
the flow. Which I think is fine for determining whether or not statistics can 
be retrieved. However, this data model contains the name of the Connection, the 
name of the Source, and the Name of the Destination. In order to include these, 
the user's permissions must first be checked to see if they have READ 
permissions to the Connection, the Source, and the Destination, respectively. 
If the user does not have READ permissions to the Source, for instance, the 
Name of the Source needs to be set to the ID. Similarly for the name of the 
Connection and the name of the Destination.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to