You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "NissimShiman (via GitHub)" <gi...@apache.org> on 2023/05/16 19:04:59 UTC

[GitHub] [nifi] NissimShiman commented on a diff in pull request #7232: NIFI-11392 for CRON scheduled components, improved cancellation of …

NissimShiman commented on code in PR #7232:
URL: https://github.com/apache/nifi/pull/7232#discussion_r1195555875


##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/scheduling/QuartzSchedulingAgent.java:
##########
@@ -71,37 +76,30 @@ public void doSchedule(final ReportingTaskNode taskNode, final LifecycleState sc
 
             @Override
             public void run() {
-                if (canceled.get()) {
-                    return;
-                }
-
                 taskWrapper.run();
 
-                if (canceled.get()) {
-                    return;
-                }
-
                 nextSchedule = getNextSchedule(nextSchedule, cronExpression);
                 final long delay = getDelay(nextSchedule);
 
                 logger.debug("Finished running Reporting Task {}; next scheduled time is at {} after a delay of {} milliseconds", taskNode, nextSchedule, delay);
-                flowEngine.schedule(this, delay, TimeUnit.MILLISECONDS);
+                final ScheduledFuture<?> newFuture = flowEngine.schedule(this, delay, TimeUnit.MILLISECONDS);
+                final ScheduledFuture<?> oldFuture = componentFuturesMap.put(0, newFuture);
+                scheduleState.replaceFuture(oldFuture, newFuture);

Review Comment:
   Did some testing where task was stopped, new cron time was set and restarted and it only ran on the new schedule (also did for a processor as well to test parallel change made for that), so this does a nice job keeping track of that.



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

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org