You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by mc...@apache.org on 2015/02/17 21:32:55 UTC

[2/4] incubator-nifi git commit: NIFI-250: - Updating the controller service references endpoint to accept an activated flag that drivens whether processors/reporting tasks are started/stopped and controller services enabled/disabled.

NIFI-250:
- Updating the controller service references endpoint to accept an activated flag that drivens whether processors/reporting tasks are started/stopped and controller services enabled/disabled.

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

Branch: refs/heads/NIFI-250
Commit: f22407f59347010aede5c12cd64652a381f4fd59
Parents: e4e61da
Author: Matt Gilman <ma...@gmail.com>
Authored: Tue Feb 17 14:54:32 2015 -0500
Committer: Matt Gilman <ma...@gmail.com>
Committed: Tue Feb 17 14:54:32 2015 -0500

----------------------------------------------------------------------
 .../java/org/apache/nifi/web/NiFiServiceFacade.java    |  4 ++--
 .../org/apache/nifi/web/StandardNiFiServiceFacade.java |  4 ++--
 .../apache/nifi/web/api/ControllerServiceResource.java | 13 +++++++++----
 .../org/apache/nifi/web/dao/ControllerServiceDAO.java  |  4 ++--
 .../web/dao/impl/StandardControllerServiceDAO.java     | 12 ++++++++++--
 5 files changed, 25 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f22407f5/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java
index 8ed7062..77ed70a 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java
@@ -981,10 +981,10 @@ public interface NiFiServiceFacade {
      * 
      * @param revision
      * @param controllerServiceId
-     * @param state
+     * @param activated
      * @return 
      */
-    ConfigurationSnapshot<Set<ControllerServiceReferencingComponentDTO>> updateControllerServiceReferencingComponents(Revision revision, String controllerServiceId, String state);
+    ConfigurationSnapshot<Set<ControllerServiceReferencingComponentDTO>> updateControllerServiceReferencingComponents(Revision revision, String controllerServiceId, boolean activated);
     
     /**
      * Updates the specified label.

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f22407f5/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
index 2ed5611..75a281a 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
@@ -1210,11 +1210,11 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
     }
 
     @Override
-    public ConfigurationSnapshot<Set<ControllerServiceReferencingComponentDTO>> updateControllerServiceReferencingComponents(final Revision revision, final String controllerServiceId, final String state) {
+    public ConfigurationSnapshot<Set<ControllerServiceReferencingComponentDTO>> updateControllerServiceReferencingComponents(final Revision revision, final String controllerServiceId, final boolean activated) {
         return optimisticLockingManager.configureFlow(revision, new ConfigurationRequest<Set<ControllerServiceReferencingComponentDTO>>() {
             @Override
             public Set<ControllerServiceReferencingComponentDTO> execute() {
-                final ControllerServiceReference reference = controllerServiceDAO.updateControllerServiceReferencingComponents(controllerServiceId, state);
+                final ControllerServiceReference reference = controllerServiceDAO.updateControllerServiceReferencingComponents(controllerServiceId, activated);
                 return dtoFactory.createControllerServiceReferencingComponentsDto(reference);
             }
         });

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f22407f5/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java
index aaf3b40..c72b8ff 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java
@@ -385,8 +385,8 @@ public class ControllerServiceResource extends ApplicationResource {
      * @param availability Whether the controller service is available on the NCM only (ncm) or on the 
      * nodes only (node). If this instance is not clustered all services should use the node availability.
      * @param id The id of the controller service to retrieve
-     * @param state Possible values include 'START' or 'STOP'. For processors and reporting tasks this will
-     * set the scheduled state accordingly. For controller services this will enable or disable accordingly.
+     * @param activated Whether or not to activate referencing components. For processors and reporting tasks this 
+     * will set the scheduled state accordingly. For controller services this will enable or disable accordingly.
      * @return A controllerServiceEntity.
      */
     @PUT
@@ -400,8 +400,13 @@ public class ControllerServiceResource extends ApplicationResource {
             @FormParam(VERSION) LongParameter version,
             @FormParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId,
             @PathParam("availability") String availability, @PathParam("id") String id,
-            @FormParam("state") String state) {
+            @FormParam("activated") Boolean activated) {
 
+        // ensure the activate flag has been specified
+        if (activated == null) {
+            throw new IllegalArgumentException("Must specified whether or not to activate the controller service references.");
+        }
+        
         final Availability avail = parseAvailability(availability);
         
         // replicate if cluster manager
@@ -423,7 +428,7 @@ public class ControllerServiceResource extends ApplicationResource {
         
         // get the controller service
         final ConfigurationSnapshot<Set<ControllerServiceReferencingComponentDTO>> response = 
-                serviceFacade.updateControllerServiceReferencingComponents(new Revision(clientVersion, clientId.getClientId()), id, state);
+                serviceFacade.updateControllerServiceReferencingComponents(new Revision(clientVersion, clientId.getClientId()), id, activated);
 
         // create the revision
         final RevisionDTO revision = new RevisionDTO();

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f22407f5/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/ControllerServiceDAO.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/ControllerServiceDAO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/ControllerServiceDAO.java
index 293519e..a457833 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/ControllerServiceDAO.java
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/ControllerServiceDAO.java
@@ -70,10 +70,10 @@ public interface ControllerServiceDAO {
      * Updates the referencing components for the specified controller service.
      * 
      * @param controllerServiceId
-     * @param state
+     * @param activated
      * @return 
      */
-    ControllerServiceReference updateControllerServiceReferencingComponents(String controllerServiceId, String state);
+    ControllerServiceReference updateControllerServiceReferencingComponents(String controllerServiceId, boolean activated);
     
     /**
      * Determines whether this controller service can be updated.

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f22407f5/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardControllerServiceDAO.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardControllerServiceDAO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardControllerServiceDAO.java
index beb9460..0460a6c 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardControllerServiceDAO.java
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardControllerServiceDAO.java
@@ -137,11 +137,19 @@ public class StandardControllerServiceDAO extends ComponentDAO implements Contro
     }
 
     @Override
-    public ControllerServiceReference updateControllerServiceReferencingComponents(final String controllerServiceId, final String state) {
+    public ControllerServiceReference updateControllerServiceReferencingComponents(final String controllerServiceId, final boolean activated) {
         // get the controller service
         final ControllerServiceNode controllerService = locateControllerService(controllerServiceId);
         
-//        serviceProvider.
+        // TODO - these actions need to be atomic... can't have partial success... maybe already handled?
+        
+        // perform the desired action
+        if (activated) {
+            serviceProvider.activateReferencingComponents(controllerService);
+        } else {
+            serviceProvider.deactivateReferencingComponents(controllerService);
+        }
+        
         return controllerService.getReferences();
     }