NIFI-381: do not re-schedule processor to run after yield if not scheduled to run anymore

This commit is contained in:
Mark Payne 2015-02-25 11:38:28 -05:00
parent e370d7d7e3
commit a956623ff9
2 changed files with 8 additions and 8 deletions

View File

@ -43,7 +43,6 @@ import org.apache.nifi.controller.ProcessorNode;
import org.apache.nifi.controller.ReportingTaskNode;
import org.apache.nifi.controller.ScheduledState;
import org.apache.nifi.controller.annotation.OnConfigured;
import org.apache.nifi.controller.service.ControllerServiceNode;
import org.apache.nifi.controller.service.ControllerServiceProvider;
import org.apache.nifi.encrypt.StringEncryptor;
import org.apache.nifi.engine.FlowEngine;
@ -374,9 +373,9 @@ public final class StandardProcessScheduler implements ProcessScheduler {
return;
}
state.setScheduled(false);
getSchedulingAgent(procNode).unschedule(procNode, state);
procNode.setScheduledState(ScheduledState.STOPPED);
state.setScheduled(false);
}
final Runnable stopProcRunnable = new Runnable() {
@ -474,8 +473,8 @@ public final class StandardProcessScheduler implements ProcessScheduler {
if (!state.isScheduled()) {
return;
}
state.setScheduled(false);
state.setScheduled(false);
getSchedulingAgent(connectable).unschedule(connectable, state);
if (!state.isScheduled() && state.getActiveThreadCount() == 0 && state.mustCallOnStoppedMethods()) {

View File

@ -130,11 +130,12 @@ public class TimerDrivenSchedulingAgent implements SchedulingAgent {
// so that we can do this again the next time that the component is yielded.
if (scheduledFuture.cancel(false)) {
final long yieldNanos = TimeUnit.MILLISECONDS.toNanos(yieldMillis);
final ScheduledFuture<?> newFuture = flowEngine.scheduleWithFixedDelay(this, yieldNanos,
connectable.getSchedulingPeriod(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS);
synchronized (scheduleState) {
if ( scheduleState.isScheduled() ) {
final ScheduledFuture<?> newFuture = flowEngine.scheduleWithFixedDelay(this, yieldNanos,
connectable.getSchedulingPeriod(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS);
scheduleState.replaceFuture(scheduledFuture, newFuture);
futureRef.set(newFuture);
}
@ -152,11 +153,11 @@ public class TimerDrivenSchedulingAgent implements SchedulingAgent {
// an accurate accounting of which futures are outstanding; we must then also update the futureRef
// so that we can do this again the next time that the component is yielded.
if (scheduledFuture.cancel(false)) {
final ScheduledFuture<?> newFuture = flowEngine.scheduleWithFixedDelay(this, NO_WORK_YIELD_NANOS,
connectable.getSchedulingPeriod(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS);
synchronized (scheduleState) {
if ( scheduleState.isScheduled() ) {
final ScheduledFuture<?> newFuture = flowEngine.scheduleWithFixedDelay(this, NO_WORK_YIELD_NANOS,
connectable.getSchedulingPeriod(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS);
scheduleState.replaceFuture(scheduledFuture, newFuture);
futureRef.set(newFuture);
}