mirror of https://github.com/apache/nifi.git
NIFI-1333 fixed FlowController shutdown deadlock. put read lock back. This closes #148
Signed-off-by: Matt Gilman <matt.c.gilman@gmail.com>
This commit is contained in:
parent
aa6bc5d505
commit
f70f7e3447
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1166,8 +1172,9 @@ public class FlowController implements EventAccess, ControllerServiceProvider, R
|
|||
}
|
||||
}
|
||||
} finally {
|
||||
writeLock.unlock();
|
||||
readLock.unlock();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue