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;
|
this.shutdown = true;
|
||||||
stopAllProcessors();
|
stopAllProcessors();
|
||||||
|
|
||||||
writeLock.lock();
|
readLock.lock();
|
||||||
try {
|
try {
|
||||||
if (isTerminated() || timerDrivenEngineRef.get().isTerminating()) {
|
if (isTerminated() || timerDrivenEngineRef.get().isTerminating()) {
|
||||||
throw new IllegalStateException("Controller already stopped or still stopping...");
|
throw new IllegalStateException("Controller already stopped or still stopping...");
|
||||||
|
@ -1099,19 +1099,24 @@ public class FlowController implements EventAccess, ControllerServiceProvider, R
|
||||||
} else {
|
} else {
|
||||||
this.timerDrivenEngineRef.get().shutdown();
|
this.timerDrivenEngineRef.get().shutdown();
|
||||||
this.eventDrivenEngineRef.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();
|
clusterTaskExecutor.shutdown();
|
||||||
|
|
||||||
// Trigger any processors' methods marked with @OnShutdown to be called
|
// Trigger any processors' methods marked with @OnShutdown to be
|
||||||
|
// called
|
||||||
rootGroup.shutdown();
|
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()) {
|
for (final ControllerServiceNode serviceNode : getAllControllerServices()) {
|
||||||
try (final NarCloseable narCloseable = NarCloseable.withNarLoader()) {
|
try (final NarCloseable narCloseable = NarCloseable.withNarLoader()) {
|
||||||
final ConfigurationContext configContext = new StandardConfigurationContext(serviceNode, controllerServiceProvider, null);
|
final ConfigurationContext configContext = new StandardConfigurationContext(serviceNode,
|
||||||
ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnShutdown.class, serviceNode.getControllerServiceImplementation(), configContext);
|
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()) {
|
for (final ReportingTaskNode taskNode : getAllReportingTasks()) {
|
||||||
final ConfigurationContext configContext = taskNode.getConfigurationContext();
|
final ConfigurationContext configContext = taskNode.getConfigurationContext();
|
||||||
try (final NarCloseable narCloseable = NarCloseable.withNarLoader()) {
|
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 {
|
} finally {
|
||||||
writeLock.unlock();
|
readLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue