nifi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joew...@apache.org
Subject [17/50] [abbrv] incubator-nifi git commit: NIFI-362: Ensure that we synchronize on ScheduleState before modifying it
Date Mon, 02 Mar 2015 04:03:56 GMT
NIFI-362: Ensure that we synchronize on ScheduleState before modifying it


Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/f1e74cc0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/f1e74cc0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/f1e74cc0

Branch: refs/heads/NIFI-360
Commit: f1e74cc04199354a6688e15de3c9947274992caa
Parents: 4cc106a
Author: Mark Payne <markap14@hotmail.com>
Authored: Sun Feb 22 10:59:14 2015 -0500
Committer: Mark Payne <markap14@hotmail.com>
Committed: Sun Feb 22 10:59:14 2015 -0500

----------------------------------------------------------------------
 .../scheduling/TimerDrivenSchedulingAgent.java    | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f1e74cc0/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/scheduling/TimerDrivenSchedulingAgent.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/scheduling/TimerDrivenSchedulingAgent.java
b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/scheduling/TimerDrivenSchedulingAgent.java
index efa8acd..a620202 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/scheduling/TimerDrivenSchedulingAgent.java
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/scheduling/TimerDrivenSchedulingAgent.java
@@ -132,8 +132,13 @@ public class TimerDrivenSchedulingAgent implements SchedulingAgent {
                             final long yieldNanos = TimeUnit.MILLISECONDS.toNanos(yieldMillis);
                             final ScheduledFuture<?> newFuture = flowEngine.scheduleWithFixedDelay(this,
yieldNanos, 
                                     connectable.getSchedulingPeriod(TimeUnit.NANOSECONDS),
TimeUnit.NANOSECONDS);
-                            scheduleState.replaceFuture(scheduledFuture, newFuture);
-                            futureRef.set(newFuture);
+                            
+                            synchronized (scheduleState) {
+                                if ( scheduleState.isScheduled() ) {
+                                    scheduleState.replaceFuture(scheduledFuture, newFuture);
+                                    futureRef.set(newFuture);
+                                }
+                            }
                         }
                     } else if ( shouldYield ) {
                         // Component itself didn't yield but there was no work to do, so
the framework will choose
@@ -149,8 +154,13 @@ public class TimerDrivenSchedulingAgent implements SchedulingAgent {
                         if (scheduledFuture.cancel(false)) {
                             final ScheduledFuture<?> newFuture = flowEngine.scheduleWithFixedDelay(this,
NO_WORK_YIELD_NANOS, 
                                     connectable.getSchedulingPeriod(TimeUnit.NANOSECONDS),
TimeUnit.NANOSECONDS);
-                            scheduleState.replaceFuture(scheduledFuture, newFuture);
-                            futureRef.set(newFuture);
+                            
+                            synchronized (scheduleState) {
+                                if ( scheduleState.isScheduled() ) {
+                                    scheduleState.replaceFuture(scheduledFuture, newFuture);
+                                    futureRef.set(newFuture);
+                                }
+                            }
                         }
                     }
                 }


Mime
View raw message