Repository: nifi
Updated Branches:
  refs/heads/master aa6bc5d50 -> f70f7e344


NIFI-1333 fixed FlowController shutdown deadlock. put read lock back. This 
closes #148

Signed-off-by: Matt Gilman <[email protected]>


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

Branch: refs/heads/master
Commit: f70f7e34470142437f2e4f2c7ef78fa7711858aa
Parents: aa6bc5d
Author: Oleg Zhurakousky <[email protected]>
Authored: Wed Dec 23 15:41:54 2015 -0500
Committer: Matt Gilman <[email protected]>
Committed: Thu Jan 28 08:31:30 2016 -0500

----------------------------------------------------------------------
 .../apache/nifi/controller/FlowController.java  | 27 ++++++++++++--------
 1 file changed, 17 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/f70f7e34/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java
index 0cab9ad..04b48dd 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java
@@ -1086,7 +1086,7 @@ public class FlowController implements EventAccess, 
ControllerServiceProvider, R
         this.shutdown = true;
         stopAllProcessors();
 
-        writeLock.lock();
+        readLock.lock();
         try {
             if (isTerminated() || timerDrivenEngineRef.get().isTerminating()) {
                 throw new IllegalStateException("Controller already stopped or 
still stopping...");
@@ -1099,19 +1099,24 @@ public class FlowController implements EventAccess, 
ControllerServiceProvider, R
             } else {
                 this.timerDrivenEngineRef.get().shutdown();
                 this.eventDrivenEngineRef.get().shutdown();
-                LOG.info("Initiated graceful shutdown of flow 
controller...waiting up to " + gracefulShutdownSeconds + " seconds");
+                LOG.info("Initiated graceful shutdown of flow 
controller...waiting up to " + gracefulShutdownSeconds
+                        + " seconds");
             }
 
             clusterTaskExecutor.shutdown();
 
-            // Trigger any processors' methods marked with @OnShutdown to be 
called
+            // Trigger any processors' methods marked with @OnShutdown to be
+            // called
             rootGroup.shutdown();
 
-            // invoke any methods annotated with @OnShutdown on Controller 
Services
+            // invoke any methods annotated with @OnShutdown on Controller
+            // Services
             for (final ControllerServiceNode serviceNode : 
getAllControllerServices()) {
                 try (final NarCloseable narCloseable = 
NarCloseable.withNarLoader()) {
-                    final ConfigurationContext configContext = new 
StandardConfigurationContext(serviceNode, controllerServiceProvider, null);
-                    
ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnShutdown.class, 
serviceNode.getControllerServiceImplementation(), configContext);
+                    final ConfigurationContext configContext = new 
StandardConfigurationContext(serviceNode,
+                            controllerServiceProvider, null);
+                    
ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnShutdown.class,
+                            serviceNode.getControllerServiceImplementation(), 
configContext);
                 }
             }
 
@@ -1119,7 +1124,8 @@ public class FlowController implements EventAccess, 
ControllerServiceProvider, R
             for (final ReportingTaskNode taskNode : getAllReportingTasks()) {
                 final ConfigurationContext configContext = 
taskNode.getConfigurationContext();
                 try (final NarCloseable narCloseable = 
NarCloseable.withNarLoader()) {
-                    
ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnShutdown.class, 
taskNode.getReportingTask(), configContext);
+                    
ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnShutdown.class, 
taskNode.getReportingTask(),
+                            configContext);
                 }
             }
 
@@ -1133,14 +1139,14 @@ public class FlowController implements EventAccess, 
ControllerServiceProvider, R
             try {
                 flowFileRepository.close();
             } catch (final Throwable t) {
-                LOG.warn("Unable to shut down FlowFileRepository due to {}", 
new Object[] {t});
+                LOG.warn("Unable to shut down FlowFileRepository due to {}", 
new Object[] { t });
             }
 
             if (this.timerDrivenEngineRef.get().isTerminated() && 
eventDrivenEngineRef.get().isTerminated()) {
                 LOG.info("Controller has been terminated successfully.");
             } else {
                 LOG.warn("Controller hasn't terminated properly.  There exists 
an uninterruptable thread that "
-                    + "will take an indeterminate amount of time to stop.  
Might need to kill the program manually.");
+                        + "will take an indeterminate amount of time to stop.  
Might need to kill the program manually.");
             }
 
             if (externalSiteListener != null) {
@@ -1166,8 +1172,9 @@ public class FlowController implements EventAccess, 
ControllerServiceProvider, R
                 }
             }
         } finally {
-            writeLock.unlock();
+            readLock.unlock();
         }
+
     }
 
     /**

Reply via email to