mattyb149 commented on a change in pull request #4274: URL: https://github.com/apache/nifi/pull/4274#discussion_r425317571
########## 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: Should we make this a configurable property in the nifi.properties analytics section? That way for small flows we could set it to run more often to get better resolution, and slower for very large flows. Is 30 seconds a good default, or would ~15 work better on average (I think that's the current rate at which the UI was asking for updates)? ---------------------------------------------------------------- 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: us...@infra.apache.org