NIFI-1697 Ensuring FlowController appropriately wraps code with NarCloseable. This closes #312

This commit is contained in:
Bryan Bende 2016-03-30 11:46:52 -04:00 committed by Matt Gilman
parent 65b26e6f41
commit 65b5c1a5f1
2 changed files with 12 additions and 4 deletions

View File

@ -3220,13 +3220,19 @@ public class FlowController implements EventAccess, ControllerServiceProvider, R
final PrimaryNodeState nodeState = primary ? PrimaryNodeState.ELECTED_PRIMARY_NODE : PrimaryNodeState.PRIMARY_NODE_REVOKED; final PrimaryNodeState nodeState = primary ? PrimaryNodeState.ELECTED_PRIMARY_NODE : PrimaryNodeState.PRIMARY_NODE_REVOKED;
final ProcessGroup rootGroup = getGroup(getRootGroupId()); final ProcessGroup rootGroup = getGroup(getRootGroupId());
for (final ProcessorNode procNode : rootGroup.findAllProcessors()) { for (final ProcessorNode procNode : rootGroup.findAllProcessors()) {
ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnPrimaryNodeStateChange.class, procNode.getProcessor(), nodeState); try (final NarCloseable narCloseable = NarCloseable.withNarLoader()) {
ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnPrimaryNodeStateChange.class, procNode.getProcessor(), nodeState);
}
} }
for (final ControllerServiceNode serviceNode : getAllControllerServices()) { for (final ControllerServiceNode serviceNode : getAllControllerServices()) {
ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnPrimaryNodeStateChange.class, serviceNode.getControllerServiceImplementation(), nodeState); try (final NarCloseable narCloseable = NarCloseable.withNarLoader()) {
ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnPrimaryNodeStateChange.class, serviceNode.getControllerServiceImplementation(), nodeState);
}
} }
for (final ReportingTaskNode reportingTaskNode : getAllReportingTasks()) { for (final ReportingTaskNode reportingTaskNode : getAllReportingTasks()) {
ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnPrimaryNodeStateChange.class, reportingTaskNode.getReportingTask(), nodeState); try (final NarCloseable narCloseable = NarCloseable.withNarLoader()) {
ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnPrimaryNodeStateChange.class, reportingTaskNode.getReportingTask(), nodeState);
}
} }
// update primary // update primary

View File

@ -908,7 +908,9 @@ public class StandardProcessorNode extends ProcessorNode implements Connectable
getAnnotationData()); getAnnotationData());
final Collection<ValidationResult> validationResults; final Collection<ValidationResult> validationResults;
validationResults = getProcessor().validate(validationContext); try (final NarCloseable narCloseable = NarCloseable.withNarLoader()) {
validationResults = getProcessor().validate(validationContext);
}
for (final ValidationResult result : validationResults) { for (final ValidationResult result : validationResults) {
if (!result.isValid()) { if (!result.isValid()) {