Repository: incubator-nifi Updated Branches: refs/heads/NIFI-250 d5a9a1a62 -> f556490fb
NIFI-250: Added verify methods to controller service provider Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/f556490f Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/f556490f Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/f556490f Branch: refs/heads/NIFI-250 Commit: f556490fb789706d4670ba6aef717de82285f29d Parents: d5a9a1a Author: Mark Payne <marka...@hotmail.com> Authored: Fri Mar 13 09:16:41 2015 -0400 Committer: Mark Payne <marka...@hotmail.com> Committed: Fri Mar 13 09:16:41 2015 -0400 ---------------------------------------------------------------------- .../cluster/manager/impl/WebClusterManager.java | 9 ++++++ .../service/ControllerServiceProvider.java | 33 ++++++++++++++++---- .../apache/nifi/controller/FlowController.java | 10 ++++++ .../StandardControllerServiceProvider.java | 20 ++++++++++++ 4 files changed, 66 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f556490f/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java index 2f17a35..d47f104 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java @@ -1410,6 +1410,15 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C controllerServiceProvider.verifyCanScheduleReferencingComponents(serviceNode); } + @Override + public void verifyCanDisableReferencingServices(final ControllerServiceNode serviceNode) { + controllerServiceProvider.verifyCanDisableReferencingServices(serviceNode); + } + + @Override + public void verifyCanStopReferencingComponents(final ControllerServiceNode serviceNode) { + controllerServiceProvider.verifyCanStopReferencingComponents(serviceNode); + } private byte[] serialize(final Document doc) throws TransformerException { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f556490f/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/service/ControllerServiceProvider.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/service/ControllerServiceProvider.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/service/ControllerServiceProvider.java index 351a036..aac65dc 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/service/ControllerServiceProvider.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/service/ControllerServiceProvider.java @@ -75,6 +75,14 @@ public interface ControllerServiceProvider extends ControllerServiceLookup { */ Set<ControllerServiceNode> getAllControllerServices(); + /** + * Verifies that all running Processors and Reporting Tasks referencing the Controller Service (or a service + * that depends on the provided service) can be stopped. + * @param serviceNode + * + * @throws IllegalStateException if any referencing component cannot be stopped + */ + void verifyCanStopReferencingComponents(ControllerServiceNode serviceNode); /** * Recursively unschedules all schedulable components (Processors and Reporting Tasks) that reference the given @@ -85,6 +93,14 @@ public interface ControllerServiceProvider extends ControllerServiceLookup { void unscheduleReferencingComponents(ControllerServiceNode serviceNode); /** + * Verifies that all Controller Services referencing the provided Controller Service can be disabled. + * @param serviceNode + * + * @throws IllegalStateException if any referencing service cannot be disabled + */ + void verifyCanDisableReferencingServices(ControllerServiceNode serviceNode); + + /** * Disables any Controller Service that references the provided Controller Service. This action is performed recursively * so that if service A references B and B references C, disabling references for C will first disable A, then B. * @param serviceNode @@ -94,15 +110,11 @@ public interface ControllerServiceProvider extends ControllerServiceLookup { /** * Verifies that all Controller Services referencing the provided ControllerService can be enabled. * @param serviceNode + * + * @throws IllegalStateException if any referencing component cannot be enabled */ void verifyCanEnableReferencingServices(ControllerServiceNode serviceNode); - /** - * Verifies that all enabled Processors referencing the ControllerService (or a service that depends on - * the provided service) can be scheduled to run. - * @param serviceNode - */ - void verifyCanScheduleReferencingComponents(ControllerServiceNode serviceNode); /** * Enables all Controller Services that are referencing the given service. If Service A references Service B and Service @@ -112,6 +124,15 @@ public interface ControllerServiceProvider extends ControllerServiceLookup { void enableReferencingServices(ControllerServiceNode serviceNode); /** + * Verifies that all enabled Processors referencing the ControllerService (or a service that depends on + * the provided service) can be scheduled to run. + * @param serviceNode + * + * @throws IllegalStateException if any referencing component cannot be scheduled + */ + void verifyCanScheduleReferencingComponents(ControllerServiceNode serviceNode); + + /** * Schedules any schedulable component (Processor, ReportingTask) that is referencing the given Controller Service * to run. This is performed recursively, so if a Processor is referencing Service A, which is referencing serviceNode, * then the Processor will also be started. http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f556490f/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java index 112e171..fade0e6 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java @@ -2638,6 +2638,16 @@ public class FlowController implements EventAccess, ControllerServiceProvider, R } @Override + public void verifyCanDisableReferencingServices(final ControllerServiceNode serviceNode) { + controllerServiceProvider.verifyCanDisableReferencingServices(serviceNode); + } + + @Override + public void verifyCanStopReferencingComponents(final ControllerServiceNode serviceNode) { + controllerServiceProvider.verifyCanStopReferencingComponents(serviceNode); + } + + @Override public ControllerService getControllerService(final String serviceIdentifier) { return controllerServiceProvider.getControllerService(serviceIdentifier); } http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f556490f/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceProvider.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceProvider.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceProvider.java index 79132b1..cca825c 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceProvider.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceProvider.java @@ -458,4 +458,24 @@ public class StandardControllerServiceProvider implements ControllerServiceProvi } } + @Override + public void verifyCanDisableReferencingServices(final ControllerServiceNode serviceNode) { + // Get a list of all Controller Services that need to be disabled, in the order that they need to be + // disabled. + final List<ControllerServiceNode> toDisable = findRecursiveReferences(serviceNode, ControllerServiceNode.class); + final Set<ControllerServiceNode> serviceSet = new HashSet<>(toDisable); + + for ( final ControllerServiceNode nodeToDisable : toDisable ) { + final ControllerServiceState state = nodeToDisable.getState(); + + if ( state != ControllerServiceState.DISABLED && state != ControllerServiceState.DISABLING ) { + nodeToDisable.verifyCanDisable(serviceSet); + } + } + } + + @Override + public void verifyCanStopReferencingComponents(final ControllerServiceNode serviceNode) { + // we can always stop referencing components + } }