YolandaMDavis commented on a change in pull request #4274:
URL: https://github.com/apache/nifi/pull/4274#discussion_r425357901



##########
File path: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java
##########
@@ -683,8 +685,28 @@ private FlowController(
 
             StatusAnalyticsModelMapFactory statusAnalyticsModelMapFactory = 
new StatusAnalyticsModelMapFactory(extensionManager, nifiProperties);
 
-            analyticsEngine = new 
CachingConnectionStatusAnalyticsEngine(flowManager, componentStatusRepository, 
flowFileEventRepository, statusAnalyticsModelMapFactory,
+            analyticsEngine = new 
CachingConnectionStatusAnalyticsEngine(flowManager, componentStatusRepository, 
statusAnalyticsModelMapFactory,
                     predictionIntervalMillis, queryIntervalMillis, 
modelScoreName, modelScoreThreshold);
+
+            timerDrivenEngineRef.get().scheduleWithFixedDelay(new Runnable() {
+                @Override
+                public void run() {
+                    try {
+                        Long startTs = System.currentTimeMillis();
+                        RepositoryStatusReport statusReport = 
flowFileEventRepository.reportTransferEvents(startTs);
+                        flowManager.findAllConnections().forEach(connection -> 
{
+                            ConnectionStatusAnalytics 
connectionStatusAnalytics = 
((ConnectionStatusAnalytics)analyticsEngine.getStatusAnalytics(connection.getIdentifier()));
+                            connectionStatusAnalytics.refresh();
+                            
connectionStatusAnalytics.loadPredictions(statusReport);
+                        });
+                        Long endTs = System.currentTimeMillis();
+                        LOG.debug("Time Elapsed for Prediction for loading all 
predictions: {}", endTs - startTs);
+                    } catch (final Exception e) {
+                        LOG.error("Failed to generate predictions", e);
+                    }
+                }
+            }, 0L, 30, TimeUnit.SECONDS);

Review comment:
       yes agreed.  I think 15 seconds would be optimal as a default but will 
confirm with some large flow scenarios to be sure.




----------------------------------------------------------------
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]


Reply via email to