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/02 15:25:00 UTC

[1/6] incubator-nifi git commit: NIFI-250: - Adding support to go to a controller service.

Repository: incubator-nifi
Updated Branches:
  refs/heads/NIFI-250 cc25d1d21 -> 22822d33a


NIFI-250:
- Adding support to go to a controller service.

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

Branch: refs/heads/NIFI-250
Commit: 600f8f7869161b50dc9939401ce8a91a64e3462a
Parents: e7beef8
Author: Matt Gilman <ma...@gmail.com>
Authored: Fri Jan 30 07:46:47 2015 -0500
Committer: Matt Gilman <ma...@gmail.com>
Committed: Fri Jan 30 07:46:47 2015 -0500

----------------------------------------------------------------------
 .../nf/canvas/nf-controller-service-configuration.js | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/600f8f78/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service-configuration.js
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service-configuration.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service-configuration.js
index 08f7399..f122c55 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service-configuration.js
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service-configuration.js
@@ -189,13 +189,26 @@ nf.ControllerServiceConfiguration = (function () {
                 var processorItem = $('<li></li>').append(processorLink).append(processorType);
                 processors.append(processorItem);
             } else if (reference.referenceType === 'ControllerService') {
-                var serviceItem = $('<li></li>').text(reference.name).on('click', function () {
+                var serviceLink = $('<span class="link"></span>').text(reference.name).on('click', function () {
+                    var controllerServiceGrid = $('#controller-services-table').data('gridInstance');
+                    var controllerServiceData = controllerServiceGrid.getData();
                     
+                    // select the selected row
+                    var row = controllerServiceData.getRowById(reference.id);
+                    controllerServiceGrid.setSelectedRows([row]);
+                    
+                    // close the dialog and shell
+                    $('#controller-service-configuration').modal('hide');
                 });
+                
+                var serviceType = $('<span class="reference-type"></span>').text('(' + nf.Common.substringAfterLast(reference.type, '.') + ')');
+                var serviceItem = $('<li></li>').append(serviceLink).append(serviceType);
                 services.append(serviceItem);
             } else if (reference.referenceType === 'ReportingTask') {
                 var taskItem = $('<li></li>').text(reference.name).on('click', function () {
                     
+                    // close the dialog and shell
+                    $('#controller-service-configuration').modal('hide');
                 });
                 tasks.append(taskItem);
             }


[3/6] incubator-nifi git commit: NIFI-250: - Updating REST API for managing controller services. - Starting to add a dialog for disabling a controller service.

Posted by mc...@apache.org.
NIFI-250:
- Updating REST API for managing controller services.
- Starting to add a dialog for disabling a controller service.

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

Branch: refs/heads/NIFI-250
Commit: d1caa7ee3e2e8662eeb2b368b2ed81fface22711
Parents: 2de754a
Author: Matt Gilman <ma...@gmail.com>
Authored: Mon Feb 2 07:52:32 2015 -0500
Committer: Matt Gilman <ma...@gmail.com>
Committed: Mon Feb 2 07:52:32 2015 -0500

----------------------------------------------------------------------
 .../nifi/web/StandardNiFiServiceFacade.java     | 14 ++-
 .../nifi/web/api/ControllerServiceResource.java |  7 +-
 .../dao/impl/StandardControllerServiceDAO.java  |  2 +-
 .../spring/ControllerServiceDAOFactoryBean.java | 71 +++++++++++++++
 .../src/main/resources/nifi-web-api-context.xml |  4 +-
 .../nifi-framework/nifi-web/nifi-web-ui/pom.xml |  1 +
 .../src/main/webapp/WEB-INF/pages/canvas.jsp    |  1 +
 .../disable-controller-service-dialog.jsp       | 27 ++++++
 .../nifi-web-ui/src/main/webapp/css/canvas.css  |  1 +
 .../css/disable-controller-service-dialog.css   | 29 +++++++
 .../src/main/webapp/js/nf/canvas/nf-settings.js | 91 +++++++++++++++-----
 11 files changed, 218 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d1caa7ee/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 a7fa12f..41cdb58 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
@@ -1289,8 +1289,10 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
         final Revision updatedRevision = updateRevision(revision);
         final ConfigurationSnapshot<ControllerServiceDTO> response = new ConfigurationSnapshot<>(updatedRevision.getVersion(), dtoFactory.createControllerServiceDto(controllerService));
 
-        // save the flow
-        controllerFacade.save();
+        // save the flow on the node
+        if (properties.isNode()) {
+            controllerFacade.save();
+        }
 
         return response;
     }
@@ -1312,7 +1314,9 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
         final ConfigurationSnapshot<ControllerServiceDTO> response = new ConfigurationSnapshot<>(updatedRevision.getVersion(), dtoFactory.createControllerServiceDto(controllerService));
 
         // save the flow
-        controllerFacade.save();
+        if (properties.isNode()) {
+            controllerFacade.save();
+        }
 
         return response;
     }
@@ -1330,7 +1334,9 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
         final ConfigurationSnapshot<Void> response = new ConfigurationSnapshot<>(updatedRevision.getVersion());
 
         // save the flow
-        controllerFacade.save();
+        if (properties.isNode()) {
+            controllerFacade.save();
+        }
 
         return response;
     }

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d1caa7ee/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 4f33756..83d9abd 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
@@ -192,6 +192,9 @@ public class ControllerServiceResource extends ApplicationResource {
         if (controllerServiceEntity.getRevision() == null) {
             throw new IllegalArgumentException("Revision must be specified.");
         }
+        
+        // get the revision
+        final RevisionDTO revision = controllerServiceEntity.getRevision();
 
         if (controllerServiceEntity.getControllerService().getId() != null) {
             throw new IllegalArgumentException("Controller service ID cannot be specified.");
@@ -200,6 +203,9 @@ public class ControllerServiceResource extends ApplicationResource {
         // if cluster manager, convert POST to PUT (to maintain same ID across nodes) and replicate
         if (properties.isClusterManager()) {
 
+            // apply action to the cluster manager first
+            serviceFacade.createControllerService(new Revision(revision.getVersion(), revision.getClientId()), controllerServiceEntity.getControllerService());
+            
             // create ID for resource
             final String id = UUID.randomUUID().toString();
 
@@ -229,7 +235,6 @@ public class ControllerServiceResource extends ApplicationResource {
         }
 
         // create the controller service and generate the json
-        final RevisionDTO revision = controllerServiceEntity.getRevision();
         final ConfigurationSnapshot<ControllerServiceDTO> controllerResponse = serviceFacade.createControllerService(
                 new Revision(revision.getVersion(), revision.getClientId()), controllerServiceEntity.getControllerService());
         final ControllerServiceDTO controllerService = controllerResponse.getConfiguration();

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d1caa7ee/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 394e33d..65311cb 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
@@ -22,8 +22,8 @@ import java.util.Map;
 import java.util.Set;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.nifi.controller.Availability;
-
 import org.apache.nifi.controller.FlowController;
+
 import org.apache.nifi.controller.exception.ValidationException;
 import org.apache.nifi.controller.service.ControllerServiceNode;
 import org.apache.nifi.web.ResourceNotFoundException;

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d1caa7ee/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/spring/ControllerServiceDAOFactoryBean.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/spring/ControllerServiceDAOFactoryBean.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/spring/ControllerServiceDAOFactoryBean.java
new file mode 100644
index 0000000..af41a9f
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/spring/ControllerServiceDAOFactoryBean.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.web.spring;
+
+import org.apache.nifi.cluster.manager.impl.WebClusterManager;
+import org.apache.nifi.controller.FlowController;
+import org.apache.nifi.controller.repository.FlowFileEventRepository;
+import org.apache.nifi.util.NiFiProperties;
+import org.apache.nifi.web.dao.ControllerServiceDAO;
+import org.apache.nifi.web.dao.impl.StandardControllerServiceDAO;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+/**
+ *
+ */
+public class ControllerServiceDAOFactoryBean implements FactoryBean, ApplicationContextAware {
+
+    private ApplicationContext context;
+    private StandardControllerServiceDAO controllerServiceDao;
+    private NiFiProperties properties;
+
+    @Override
+    public Object getObject() throws Exception {
+        if (controllerServiceDao == null) {
+            controllerServiceDao = new StandardControllerServiceDAO();
+            if (properties.isClusterManager()) {
+                controllerServiceDao.setServiceProvider(context.getBean("clusterManager", WebClusterManager.class));
+            } else {
+                controllerServiceDao.setServiceProvider(context.getBean("flowController", FlowController.class));
+            }
+        }
+
+        return controllerServiceDao;
+    }
+
+    @Override
+    public Class getObjectType() {
+        return ControllerServiceDAO.class;
+    }
+
+    @Override
+    public boolean isSingleton() {
+        return true;
+    }
+
+    public void setProperties(NiFiProperties properties) {
+        this.properties = properties;
+    }
+
+    @Override
+    public void setApplicationContext(ApplicationContext context) throws BeansException {
+        this.context = context;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d1caa7ee/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/resources/nifi-web-api-context.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/resources/nifi-web-api-context.xml b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/resources/nifi-web-api-context.xml
index c6aa6c0..8bc4fdd 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/resources/nifi-web-api-context.xml
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/resources/nifi-web-api-context.xml
@@ -68,8 +68,8 @@
     <bean id="processorDAO" class="org.apache.nifi.web.dao.impl.StandardProcessorDAO">
         <property name="flowController" ref="flowController"/>
     </bean>
-    <bean id="controllerServiceDAO" class="org.apache.nifi.web.dao.impl.StandardControllerServiceDAO">
-        <property name="flowController" ref="flowController"/>
+    <bean id="controllerServiceDAO" class="org.apache.nifi.web.spring.ControllerServiceDAOFactoryBean" depends-on="clusterManager flowController">
+        <property name="properties" ref="nifiProperties"/>
     </bean>
     <bean id="templateDAO" class="org.apache.nifi.web.dao.impl.StandardTemplateDAO">
         <property name="flowController" ref="flowController"/>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d1caa7ee/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/pom.xml b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/pom.xml
index 4a54a48..f16c372 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/pom.xml
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/pom.xml
@@ -419,6 +419,7 @@
                                                 <include>${staging.dir}/css/dialog.css</include>
                                                 <include>${staging.dir}/css/new-processor-dialog.css</include>
                                                 <include>${staging.dir}/css/new-controller-service-dialog.css</include>
+                                                <include>${staging.dir}/css/disable-controller-service-dialog.css</include>
                                                 <include>${staging.dir}/css/graph.css</include>
                                                 <include>${staging.dir}/css/header.css</include>
                                                 <include>${staging.dir}/css/main.css</include>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d1caa7ee/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp
index 9afc26c..d306368 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp
@@ -80,6 +80,7 @@
         <jsp:include page="/WEB-INF/partials/ok-dialog.jsp"/>
         <jsp:include page="/WEB-INF/partials/yes-no-dialog.jsp"/>
         <jsp:include page="/WEB-INF/partials/status-history-dialog.jsp"/>
+        <jsp:include page="/WEB-INF/partials/canvas/disable-controller-service-dialog.jsp"/>
         <jsp:include page="/WEB-INF/partials/canvas/new-controller-service-dialog.jsp"/>
         <jsp:include page="/WEB-INF/partials/canvas/new-processor-dialog.jsp"/>
         <jsp:include page="/WEB-INF/partials/canvas/new-port-dialog.jsp"/>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d1caa7ee/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/disable-controller-service-dialog.jsp
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/disable-controller-service-dialog.jsp b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/disable-controller-service-dialog.jsp
new file mode 100644
index 0000000..f4a4e72
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/disable-controller-service-dialog.jsp
@@ -0,0 +1,27 @@
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+--%>
+<%@ page contentType="text/html" pageEncoding="UTF-8" session="false" %>
+<div id="disable-controller-service-dialog">
+    <div class="dialog-content">
+        <div class="setting">
+            <div class="setting-name">Service</div>
+            <div class="setting-field">
+                <span id="disable-controller-service-name"></span>
+            </div>
+        </div>
+    </div>
+</div>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d1caa7ee/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/canvas.css
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/canvas.css b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/canvas.css
index a472a42..e59aba7 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/canvas.css
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/canvas.css
@@ -31,6 +31,7 @@
 @import url(dialog.css);
 @import url(new-processor-dialog.css);
 @import url(new-controller-service-dialog.css);
+@import url(disable-controller-service-dialog.css);
 @import url(graph.css);
 @import url(header.css);
 @import url(main.css);

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d1caa7ee/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/disable-controller-service-dialog.css
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/disable-controller-service-dialog.css b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/disable-controller-service-dialog.css
new file mode 100644
index 0000000..1da8f09
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/disable-controller-service-dialog.css
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* 
+    New controller service dialog.
+*/
+
+#disable-controller-service-dialog {
+    z-index: 1301;
+    display: none;
+    width: 500px;
+    height: 450px;
+    border: 1px solid #eee;
+    line-height: normal;
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d1caa7ee/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js
index 64f6dac..61b3156 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js
@@ -635,12 +635,76 @@ nf.Settings = (function () {
         });
     };
     
+    // sets whether the specified controller service is enabled
+    var setEnabled = function (controllerService, enabled) {
+        var revision = nf.Client.getRevision();
+        return $.ajax({
+            type: 'PUT',
+            url: controllerService.uri,
+            data: {
+                clientId: revision.clientId,
+                version: revision.version,
+                enabled: enabled
+            },
+            dataType: 'json'
+        }).done(function (response) {
+            // update the revision
+            nf.Client.setRevision(response.revision);
+
+            // update the service
+            var controllerServicesGrid = $('#controller-services-table').data('gridInstance');
+            var controllerServicesData = controllerServicesGrid.getData();
+            controllerServicesData.updateItem(controllerService.id, response.controllerService);
+        }).fail(nf.Common.handleAjaxError);
+    };
+    
+    /**
+     * Initializes the dialog used to disable controller services.
+     */
+    var initDisableControllerSerivceDialog = function () {
+        $('#disable-controller-service-dialog').modal({
+            headerText: 'Disable Controller Service',
+            overlayBackground: false,
+            buttons: [{
+                buttonText: 'Disable',
+                handler: {
+                    click: function () {
+                        
+                    }
+                }
+            }, {
+                buttonText: 'Cancel',
+                handler: {
+                    click: function () {
+                        $(this).modal('hide');
+                    }
+                }
+            }],
+            close: function() {
+                
+            }
+        });
+    };
+    
+    /**
+     * Shows the dialog for disabling a controller service.
+     * 
+     * @argument {object} controllerService The controller service to disable
+     */
+    var showDisableControllerServiceDialog = function (controllerService) {
+        $('#disable-controller-service-name').text(controllerService.name);
+        $('#disable-controller-service-dialog').modal('show');
+    };
+    
     /**
      * Initializes the controller services tab.
      */
     var initControllerServices = function () {
         // initialize the new controller service dialog
         initNewControllerServiceDialog();
+      
+        // initialize the disable controller service dialog
+        initDisableControllerSerivceDialog();
         
         // more details formatter
         var moreControllerServiceDetails = function (row, cell, value, columnDef, dataContext) {
@@ -711,27 +775,6 @@ nf.Settings = (function () {
         controllerServicesGrid.registerPlugin(new Slick.AutoTooltips());
         controllerServicesGrid.setSortColumn('name', true);
         
-        // sets whether the specified controller service is enabled
-        var setEnabled = function (controllerService, enabled) {
-            var revision = nf.Client.getRevision();
-            return $.ajax({
-                type: 'PUT',
-                url: controllerService.uri,
-                data: {
-                    clientId: revision.clientId,
-                    version: revision.version,
-                    enabled: enabled
-                },
-                dataType: 'json'
-            }).done(function (response) {
-                // update the revision
-                nf.Client.setRevision(response.revision);
-
-                // update the service
-                controllerServicesData.updateItem(controllerService.id, response.controllerService);
-            }).fail(nf.Common.handleAjaxError);
-        };
-        
         // configure a click listener
         controllerServicesGrid.onClick.subscribe(function (e, args) {
             var target = $(e.target);
@@ -746,7 +789,11 @@ nf.Settings = (function () {
                 } else if (target.hasClass('enable-controller-service')) {
                     setEnabled(controllerService, true);
                 } else if (target.hasClass('disable-controller-service')) {
-                    setEnabled(controllerService, false);
+                    if (nf.Common.isEmpty(controllerService.references)) {
+                        setEnabled(controllerService, false);
+                    } else {
+                        showDisableControllerServiceDialog(controllerService);
+                    }
                 } else if (target.hasClass('delete-controller-service')) {
                     var revision = nf.Client.getRevision();
                     return $.ajax({


[2/6] incubator-nifi git commit: NIFI-250: - Showing controller service validation errors.

Posted by mc...@apache.org.
NIFI-250:
- Showing controller service validation errors.

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

Branch: refs/heads/NIFI-250
Commit: 2de754a11af2f3d545ae9358c06dd6838e3d920c
Parents: 600f8f7
Author: Matt Gilman <ma...@gmail.com>
Authored: Fri Jan 30 08:35:18 2015 -0500
Committer: Matt Gilman <ma...@gmail.com>
Committed: Fri Jan 30 08:35:18 2015 -0500

----------------------------------------------------------------------
 .../nifi/web/api/dto/ControllerServiceDTO.java  | 18 ++++++++
 .../org/apache/nifi/web/api/dto/DtoFactory.java | 11 +++++
 .../src/main/webapp/js/nf/canvas/nf-settings.js | 43 ++++++++++++++++++--
 3 files changed, 69 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2de754a1/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerServiceDTO.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerServiceDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerServiceDTO.java
index 992d8e5..c66eb7a 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerServiceDTO.java
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerServiceDTO.java
@@ -16,6 +16,7 @@
  */
 package org.apache.nifi.web.api.dto;
 
+import java.util.Collection;
 import java.util.Map;
 import java.util.Set;
 import javax.xml.bind.annotation.XmlType;
@@ -38,6 +39,8 @@ public class ControllerServiceDTO extends NiFiComponentDTO {
     private String annotationData;
     
     private Set<ControllerServiceReferenceDTO> references;
+    
+    private Collection<String> validationErrors;
 
     /**
      * The controller service name.
@@ -157,6 +160,21 @@ public class ControllerServiceDTO extends NiFiComponentDTO {
     }
 
     /**
+     * Gets the validation errors from this controller service. These validation errors
+     * represent the problems with the controller service that must be resolved before it
+     * can be enabled.
+     *
+     * @return The validation errors
+     */
+    public Collection<String> getValidationErrors() {
+        return validationErrors;
+    }
+
+    public void setValidationErrors(Collection<String> validationErrors) {
+        this.validationErrors = validationErrors;
+    }
+    
+    /**
      * A component reference a controller service. This can either be another
      * controller service or a processor. Depending on the type of component
      * different properties may be set.

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2de754a1/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.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/dto/DtoFactory.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java
index 198ffab..aef2feb 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java
@@ -920,6 +920,17 @@ public final class DtoFactory {
             dto.getReferences().add(reference);
         }
         
+        // add the validation errors
+        final Collection<ValidationResult> validationErrors = controllerServiceNode.getValidationErrors();
+        if (validationErrors != null && !validationErrors.isEmpty()) {
+            final List<String> errors = new ArrayList<>();
+            for (final ValidationResult validationResult : validationErrors) {
+                errors.add(validationResult.toString());
+            }
+
+            dto.setValidationErrors(errors);
+        }
+        
         return dto;
     }
     

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2de754a1/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js
index 4f982fb..64f6dac 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js
@@ -642,14 +642,21 @@ nf.Settings = (function () {
         // initialize the new controller service dialog
         initNewControllerServiceDialog();
         
+        // more details formatter
         var moreControllerServiceDetails = function (row, cell, value, columnDef, dataContext) {
-            return '<img src="images/iconDetails.png" title="View Details" class="pointer view-controller-service" style="margin-top: 5px; float: left;" />';
+            var markup = '<img src="images/iconDetails.png" title="View Details" class="pointer view-controller-service" style="margin-top: 5px; float: left;" />&nbsp;';
+            if (!nf.Common.isEmpty(dataContext.validationErrors)) {
+                markup += '<img src="images/iconAlert.png" class="has-errors" style="margin-top: 4px; float: left;" /><span class="hidden row-id">' + nf.Common.escapeHtml(dataContext.id) + '</span>';
+            }
+            return markup;
         };
         
+        // type formatter
         var typeFormatter = function (row, cell, value, columnDef, dataContext) {
             return nf.Common.substringAfterLast(value, '.');
         };
         
+        // service state formatter
         var enabledFormatter = function (row, cell, value, columnDef, dataContext) {
             if (dataContext.enabled === true) {
                 return 'Enabled';
@@ -776,7 +783,34 @@ nf.Settings = (function () {
         controllerServicesData.syncGridSelection(controllerServicesGrid, true);
 
         // hold onto an instance of the grid
-        $('#controller-services-table').data('gridInstance', controllerServicesGrid);
+        $('#controller-services-table').data('gridInstance', controllerServicesGrid).on('mouseenter', 'div.slick-cell', function (e) {
+            var errorIcon = $(this).find('img.has-errors');
+            if (errorIcon.length && !errorIcon.data('qtip')) {
+                var serviceId = $(this).find('span.row-id').text();
+
+                // get the service item
+                var item = controllerServicesData.getItemById(serviceId);
+
+                // format the errors
+                var tooltip = nf.Common.formatUnorderedList(item.validationErrors);
+
+                // show the tooltip
+                if (nf.Common.isDefinedAndNotNull(tooltip)) {
+                    errorIcon.qtip($.extend({
+                        content: tooltip,
+                        position: {
+                            target: 'mouse',
+                            viewport: $(window),
+                            adjust: {
+                                x: 8,
+                                y: 8,
+                                method: 'flipinvert flipinvert'
+                            }
+                        }
+                    }, nf.Common.config.tooltipConfig));
+                }
+            }
+        });
     };
     
     /**
@@ -790,7 +824,10 @@ nf.Settings = (function () {
         }).done(function (response) {
             var controllerServices = response.controllerServices;
             if (nf.Common.isDefinedAndNotNull(controllerServices)) {
-                var controllerServicesGrid = $('#controller-services-table').data('gridInstance');
+                var controllerServicesElement = $('#controller-services-table');
+                nf.Common.cleanUpTooltips(controllerServicesElement, 'img.has-errors');
+                
+                var controllerServicesGrid = controllerServicesElement.data('gridInstance');
                 var controllerServicesData = controllerServicesGrid.getData();
 
                 // update the processors


[4/6] incubator-nifi git commit: Merge branch 'NIFI-250' of https://git-wip-us.apache.org/repos/asf/incubator-nifi into NIFI-250

Posted by mc...@apache.org.
Merge branch 'NIFI-250' of https://git-wip-us.apache.org/repos/asf/incubator-nifi into NIFI-250


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

Branch: refs/heads/NIFI-250
Commit: 0cb1adbc1f1bf0272be813bf58b90444243b65b5
Parents: d1caa7e cc25d1d
Author: Matt Gilman <ma...@gmail.com>
Authored: Mon Feb 2 07:52:38 2015 -0500
Committer: Matt Gilman <ma...@gmail.com>
Committed: Mon Feb 2 07:52:38 2015 -0500

----------------------------------------------------------------------
 .../nifi/cluster/flow/ClusterDataFlow.java      |  15 +-
 .../cluster/flow/DataFlowManagementService.java |  17 ++
 .../nifi/cluster/flow/impl/DataFlowDaoImpl.java |  16 +-
 .../impl/DataFlowManagementServiceImpl.java     |  65 +++++-
 .../cluster/manager/impl/WebClusterManager.java | 217 +++++++++++++++----
 .../spring/WebClusterManagerFactoryBean.java    |   6 -
 .../reporting/ClusteredReportingTaskNode.java   |   3 +-
 .../apache/nifi/controller/Availability.java    |  12 +-
 .../nifi/controller/ReportingTaskNode.java      |   2 -
 .../service/ControllerServiceNode.java          |   2 -
 .../service/ControllerServiceProvider.java      |  16 +-
 .../apache/nifi/controller/FlowController.java  |  65 ++----
 .../nifi/controller/StandardFlowSerializer.java |  20 +-
 .../nifi/controller/StandardFlowService.java    |   4 +-
 .../controller/StandardFlowSynchronizer.java    |  54 ++++-
 .../reporting/AbstractReportingTaskNode.java    |  12 +-
 .../reporting/StandardReportingTaskNode.java    |   3 +-
 .../service/ControllerServiceLoader.java        |  86 +++-----
 .../service/StandardControllerServiceNode.java  |  12 +-
 .../StandardControllerServiceProvider.java      |  11 +-
 .../nifi/persistence/FlowConfigurationDAO.java  |  12 -
 .../StandardXMLFlowConfigurationDAO.java        |  11 +-
 .../nifi/web/controller/ControllerFacade.java   |   9 +-
 .../dao/impl/StandardControllerServiceDAO.java  |   6 +-
 .../nifi/processors/standard/PostHTTP.java      |  38 ++--
 .../DistributedMapCacheClientService.java       |  18 +-
 .../DistributedSetCacheClientService.java       |  11 +-
 .../cache/server/DistributedCacheServer.java    |   9 +-
 .../nifi/ssl/StandardSSLContextService.java     |   2 -
 29 files changed, 475 insertions(+), 279 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/0cb1adbc/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
----------------------------------------------------------------------


[6/6] incubator-nifi git commit: NIFI-250: - Updating the ControllerService endpoint to specify the availability of the service. - Updating the optimistic locking manager to ensure the proper revision is checked.

Posted by mc...@apache.org.
NIFI-250:
- Updating the ControllerService endpoint to specify the availability of the service.
- Updating the optimistic locking manager to ensure the proper revision is checked.

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

Branch: refs/heads/NIFI-250
Commit: 22822d33a2159d1f9a2b12caafbce7c2b46ebe52
Parents: 346cc0c
Author: Matt Gilman <ma...@gmail.com>
Authored: Mon Feb 2 09:10:12 2015 -0500
Committer: Matt Gilman <ma...@gmail.com>
Committed: Mon Feb 2 09:10:12 2015 -0500

----------------------------------------------------------------------
 .../cluster/manager/impl/WebClusterManager.java | 10 +-
 .../spring/WebClusterManagerFactoryBean.java    | 10 +-
 .../resources/nifi-cluster-manager-context.xml  |  4 +
 .../nifi/web/api/ControllerServiceResource.java | 99 +++++++++++++++-----
 .../dao/impl/StandardControllerServiceDAO.java  |  1 -
 .../OptimisticLockingManagerFactoryBean.java    | 74 +++++++++++++++
 .../src/main/resources/nifi-web-api-context.xml |  8 +-
 7 files changed, 172 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/22822d33/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 fec8e0c..585d151 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
@@ -210,6 +210,7 @@ import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 
 import com.sun.jersey.api.client.ClientResponse;
+import org.apache.nifi.web.OptimisticLockingManager;
 
 /**
  * Provides a cluster manager implementation. The manager federates incoming
@@ -303,6 +304,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C
     private final HttpResponseMapper httpResponseMapper;
     private final DataFlowManagementService dataFlowManagementService;
     private final ClusterManagerProtocolSenderListener senderListener;
+    private final OptimisticLockingManager optimisticLockingManager;
     private final StringEncryptor encryptor;
     private final Queue<Heartbeat> pendingHeartbeats = new ConcurrentLinkedQueue<>();
     private final ReentrantReadWriteLock resourceRWLock = new ReentrantReadWriteLock();
@@ -315,7 +317,6 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C
     // null means the dataflow should be read from disk
     private StandardDataFlow cachedDataFlow = null;
     private NodeIdentifier primaryNodeId = null;
-    private Revision revision = new Revision(0L, "");
     private Timer heartbeatMonitor;
     private Timer heartbeatProcessor;
     private volatile ClusterServicesBroadcaster servicesBroadcaster = null;
@@ -336,7 +337,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C
 
     public WebClusterManager(final HttpRequestReplicator httpRequestReplicator, final HttpResponseMapper httpResponseMapper,
             final DataFlowManagementService dataFlowManagementService, final ClusterManagerProtocolSenderListener senderListener,
-            final NiFiProperties properties, final StringEncryptor encryptor) {
+            final NiFiProperties properties, final StringEncryptor encryptor, final OptimisticLockingManager optimisticLockingManager) {
 
         if (httpRequestReplicator == null) {
             throw new IllegalArgumentException("HttpRequestReplicator may not be null.");
@@ -360,6 +361,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C
         this.instanceId = UUID.randomUUID().toString();
         this.senderListener = senderListener;
         this.encryptor = encryptor;
+        this.optimisticLockingManager = optimisticLockingManager;
         senderListener.addHandler(this);
         senderListener.setBulletinRepository(bulletinRepository);
 
@@ -2135,7 +2137,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C
         final Map<String, String> updatedHeaders = new HashMap<>(headers);
         final ClusterContext clusterCtx = new ClusterContextImpl();
         clusterCtx.setRequestSentByClusterManager(true);                 // indicate request is sent from cluster manager
-        clusterCtx.setRevision(revision);
+        clusterCtx.setRevision(optimisticLockingManager.getRevision());
 
         // serialize cluster context and add to request header
         final String serializedClusterCtx = WebUtils.serializeObjectToHex(clusterCtx);
@@ -2804,7 +2806,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C
                                     }
                                 }
                             }
-                            revision = clusterContext.getRevision();
+                            optimisticLockingManager.setRevision(clusterContext.getRevision());
                         }
                     }
                 } catch (final ClassNotFoundException cnfe) {

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/22822d33/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/spring/WebClusterManagerFactoryBean.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/spring/WebClusterManagerFactoryBean.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/spring/WebClusterManagerFactoryBean.java
index 3881461..86bc07c 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/spring/WebClusterManagerFactoryBean.java
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/java/org/apache/nifi/cluster/spring/WebClusterManagerFactoryBean.java
@@ -29,6 +29,7 @@ import org.apache.nifi.encrypt.StringEncryptor;
 import org.apache.nifi.io.socket.multicast.DiscoverableService;
 import org.apache.nifi.io.socket.multicast.DiscoverableServiceImpl;
 import org.apache.nifi.util.NiFiProperties;
+import org.apache.nifi.web.OptimisticLockingManager;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.FactoryBean;
 import org.springframework.context.ApplicationContext;
@@ -48,6 +49,8 @@ public class WebClusterManagerFactoryBean implements FactoryBean, ApplicationCon
     private NiFiProperties properties;
 
     private StringEncryptor encryptor;
+    
+    private OptimisticLockingManager optimisticLockingManager;
 
     @Override
     public Object getObject() throws Exception {
@@ -79,7 +82,8 @@ public class WebClusterManagerFactoryBean implements FactoryBean, ApplicationCon
                     dataFlowService,
                     senderListener,
                     properties,
-                    encryptor
+                    encryptor,
+                    optimisticLockingManager
             );
 
             // set the service broadcaster
@@ -130,4 +134,8 @@ public class WebClusterManagerFactoryBean implements FactoryBean, ApplicationCon
     public void setEncryptor(final StringEncryptor encryptor) {
         this.encryptor = encryptor;
     }
+    
+    public void setOptimisticLockingManager(OptimisticLockingManager optimisticLockingManager) {
+        this.optimisticLockingManager = optimisticLockingManager;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/22822d33/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/resources/nifi-cluster-manager-context.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/resources/nifi-cluster-manager-context.xml b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/resources/nifi-cluster-manager-context.xml
index 68c29bc..72c7bff 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/resources/nifi-cluster-manager-context.xml
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster/src/main/resources/nifi-cluster-manager-context.xml
@@ -91,10 +91,14 @@
         <property name="properties" ref="nifiProperties"/>
     </bean>
 
+    <!-- cluster manager optimistic locking manager -->
+    <bean id="clusterManagerOptimisticLockingManager" class="org.apache.nifi.web.StandardOptimisticLockingManager"/>
+
     <!-- cluster manager -->
     <bean id="clusterManager" class="org.apache.nifi.cluster.spring.WebClusterManagerFactoryBean">
         <property name="properties" ref="nifiProperties"/>
         <property name="encryptor" ref="stringEncryptor"/>
+        <property name="optimisticLockingManager" ref="clusterManagerOptimisticLockingManager"/>
     </bean>
     
     <!-- discoverable services -->

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/22822d33/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 83d9abd..4b36f28 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
@@ -51,6 +51,7 @@ import org.apache.nifi.web.api.dto.RevisionDTO;
 import org.apache.nifi.web.api.request.ClientIdParameter;
 import org.apache.nifi.web.api.request.LongParameter;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.nifi.controller.Availability;
 import org.apache.nifi.web.api.dto.ControllerServiceDTO;
 import org.apache.nifi.web.api.entity.ControllerServiceEntity;
 import org.apache.nifi.web.api.entity.ControllerServicesEntity;
@@ -93,21 +94,48 @@ public class ControllerServiceResource extends ApplicationResource {
     }
 
     /**
+     * Parses the availability and ensure that the specified availability makes sense for the
+     * given NiFi instance.
+     * 
+     * @param availability
+     * @return 
+     */
+    private Availability parseAvailability(final String availability) {
+        final Availability avail;
+        try {
+            avail = Availability.valueOf(availability.toUpperCase());
+        } catch (IllegalArgumentException iae) {
+            throw new IllegalArgumentException(String.format("Availability: Value must be one of [%s]", StringUtils.join(Availability.values(), ", ")));
+        }
+        
+        // ensure this nifi is an NCM is specifying NCM availability
+        if (!properties.isClusterManager() && Availability.NCM.equals(avail)) {
+            throw new IllegalArgumentException("Availability of NCM is only applicable when the NiFi instance is the cluster manager.");
+        }
+        
+        return avail;
+    }
+    
+    /**
      * Retrieves all the of controller services in this NiFi.
      *
      * @param clientId Optional client id. If the client id is not specified, a
      * new one will be generated. This value (whether specified or generated) is
      * included in the response.
+     * @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.
      * @return A controllerServicesEntity.
      */
     @GET
     @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+    @Path("{availability}")
     @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
     @TypeHint(ControllerServicesEntity.class)
-    public Response getControllerServices(@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId) {
-
+    public Response getControllerServices(@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId, @PathParam("availability") String availability) {
+        final Availability avail = parseAvailability(availability);
+        
         // replicate if cluster manager
-        if (properties.isClusterManager()) {
+        if (properties.isClusterManager() && Availability.NODE.equals(avail)) {
             return clusterManager.applyRequest(HttpMethod.GET, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse();
         }
 
@@ -136,20 +164,24 @@ public class ControllerServiceResource extends ApplicationResource {
      * @param clientId Optional client id. If the client id is not specified, a
      * new one will be generated. This value (whether specified or generated) is
      * included in the response.
+     * @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 type The type of controller service to create.
      * @return A controllerServiceEntity.
      */
     @POST
     @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
     @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+    @Path("{availability}")
     @PreAuthorize("hasRole('ROLE_DFM')")
     @TypeHint(ControllerServiceEntity.class)
     public Response createControllerService(
             @Context HttpServletRequest httpServletRequest,
             @FormParam(VERSION) LongParameter version,
             @FormParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId,
+            @PathParam("availability") String availability, 
             @FormParam("type") String type) {
-
+        
         // create the controller service DTO
         final ControllerServiceDTO controllerServiceDTO = new ControllerServiceDTO();
         controllerServiceDTO.setType(type);
@@ -166,24 +198,30 @@ public class ControllerServiceResource extends ApplicationResource {
         controllerServiceEntity.setRevision(revision);
         controllerServiceEntity.setControllerService(controllerServiceDTO);
 
-        return createControllerService(httpServletRequest, controllerServiceEntity);
+        return createControllerService(httpServletRequest, availability, controllerServiceEntity);
     }
 
     /**
      * Creates a new Controller Service.
      *
      * @param httpServletRequest
+     * @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 controllerServiceEntity A controllerServiceEntity.
      * @return A controllerServiceEntity.
      */
     @POST
     @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
     @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+    @Path("{availability}")
     @PreAuthorize("hasRole('ROLE_DFM')")
     @TypeHint(ControllerServiceEntity.class)
     public Response createControllerService(
             @Context HttpServletRequest httpServletRequest,
+            @PathParam("availability") String availability, 
             ControllerServiceEntity controllerServiceEntity) {
+        
+        final Availability avail = parseAvailability(availability);
 
         if (controllerServiceEntity == null || controllerServiceEntity.getControllerService()== null) {
             throw new IllegalArgumentException("Controller service details must be specified.");
@@ -201,7 +239,7 @@ public class ControllerServiceResource extends ApplicationResource {
         }
 
         // if cluster manager, convert POST to PUT (to maintain same ID across nodes) and replicate
-        if (properties.isClusterManager()) {
+        if (properties.isClusterManager() && Availability.NODE.equals(avail)) {
 
             // apply action to the cluster manager first
             serviceFacade.createControllerService(new Revision(revision.getVersion(), revision.getClientId()), controllerServiceEntity.getControllerService());
@@ -260,18 +298,23 @@ public class ControllerServiceResource extends ApplicationResource {
      * @param clientId Optional client id. If the client id is not specified, a
      * new one will be generated. This value (whether specified or generated) is
      * included in the response.
+     * @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
      * @return A controllerServiceEntity.
      */
     @GET
     @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Path("{id}")
+    @Path("{availability}/{id}")
     @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
     @TypeHint(ControllerServiceEntity.class)
-    public Response getControllerService(@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId, @PathParam("id") String id) {
+    public Response getControllerService(@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId, 
+            @PathParam("availability") String availability, @PathParam("id") String id) {
 
+        final Availability avail = parseAvailability(availability);
+        
         // replicate if cluster manager
-        if (properties.isClusterManager()) {
+        if (properties.isClusterManager() && Availability.NODE.equals(avail)) {
             return clusterManager.applyRequest(HttpMethod.GET, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse();
         }
 
@@ -299,6 +342,8 @@ public class ControllerServiceResource extends ApplicationResource {
      * @param clientId Optional client id. If the client id is not specified, a
      * new one will be generated. This value (whether specified or generated) is
      * included in the response.
+     * @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 update.
      * @param name The name of the controller service
      * @param annotationData The annotation data for the controller service
@@ -324,20 +369,20 @@ public class ControllerServiceResource extends ApplicationResource {
     @PUT
     @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
     @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Path("{id}")
+    @Path("{availability}/{id}")
     @PreAuthorize("hasRole('ROLE_DFM')")
     @TypeHint(ControllerServiceEntity.class)
     public Response updateControllerService(
             @Context HttpServletRequest httpServletRequest,
             @FormParam(VERSION) LongParameter version,
             @FormParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId,
-            @PathParam("id") String id, @FormParam("name") String name,
+            @PathParam("availability") String availability, @PathParam("id") String id, @FormParam("name") String name,
             @FormParam("annotationData") String annotationData, @FormParam("comments") String comments,
             @FormParam("enabled") Boolean enabled, @FormParam("markedForDeletion[]") List<String> markedForDeletion,
             MultivaluedMap<String, String> formParams) {
 
         // create collections for holding the controller service properties
-        final Map<String, String> properties = new LinkedHashMap<>();
+        final Map<String, String> updatedProperties = new LinkedHashMap<>();
         
         // go through each parameter and look for processor properties
         for (String parameterName : formParams.keySet()) {
@@ -349,7 +394,7 @@ public class ControllerServiceResource extends ApplicationResource {
                     final int endIndex = StringUtils.lastIndexOf(parameterName, "]");
                     if (startIndex != -1 && endIndex != -1) {
                         final String propertyName = StringUtils.substring(parameterName, startIndex + 1, endIndex);
-                        properties.put(propertyName, formParams.getFirst(parameterName));
+                        updatedProperties.put(propertyName, formParams.getFirst(parameterName));
                     }
                 }
             }
@@ -357,7 +402,7 @@ public class ControllerServiceResource extends ApplicationResource {
         
         // set the properties to remove
         for (String propertyToDelete : markedForDeletion) {
-            properties.put(propertyToDelete, null);
+            updatedProperties.put(propertyToDelete, null);
         }
         
         // create the controller service DTO
@@ -369,8 +414,8 @@ public class ControllerServiceResource extends ApplicationResource {
         controllerServiceDTO.setEnabled(enabled);
 
         // only set the properties when appropriate
-        if (!properties.isEmpty()) {
-            controllerServiceDTO.setProperties(properties);
+        if (!updatedProperties.isEmpty()) {
+            controllerServiceDTO.setProperties(updatedProperties);
         }
         
         // create the revision
@@ -386,13 +431,15 @@ public class ControllerServiceResource extends ApplicationResource {
         controllerServiceEntity.setControllerService(controllerServiceDTO);
 
         // update the controller service
-        return updateControllerService(httpServletRequest, id, controllerServiceEntity);
+        return updateControllerService(httpServletRequest, availability, id, controllerServiceEntity);
     }
 
     /**
      * Updates the specified a new Controller Service.
      *
      * @param httpServletRequest
+     * @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 update.
      * @param controllerServiceEntity A controllerServiceEntity.
      * @return A controllerServiceEntity.
@@ -400,14 +447,17 @@ public class ControllerServiceResource extends ApplicationResource {
     @PUT
     @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
     @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Path("{id}")
+    @Path("{availability}/{id}")
     @PreAuthorize("hasRole('ROLE_DFM')")
     @TypeHint(ControllerServiceEntity.class)
     public Response updateControllerService(
             @Context HttpServletRequest httpServletRequest,
+            @PathParam("availability") String availability, 
             @PathParam("id") String id,
             ControllerServiceEntity controllerServiceEntity) {
 
+        final Availability avail = parseAvailability(availability);
+        
         if (controllerServiceEntity == null || controllerServiceEntity.getControllerService()== null) {
             throw new IllegalArgumentException("Controller service details must be specified.");
         }
@@ -424,7 +474,7 @@ public class ControllerServiceResource extends ApplicationResource {
         }
 
         // replicate if cluster manager
-        if (properties.isClusterManager()) {
+        if (properties.isClusterManager() && Availability.NODE.equals(avail)) {
             // change content type to JSON for serializing entity
             final Map<String, String> headersToOverride = new HashMap<>();
             headersToOverride.put("content-type", MediaType.APPLICATION_JSON);
@@ -471,22 +521,26 @@ public class ControllerServiceResource extends ApplicationResource {
      * @param clientId Optional client id. If the client id is not specified, a
      * new one will be generated. This value (whether specified or generated) is
      * included in the response.
+     * @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 remove.
      * @return A entity containing the client id and an updated revision.
      */
     @DELETE
     @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Path("{id}")
+    @Path("{availability}/{id}")
     @PreAuthorize("hasRole('ROLE_DFM')")
     @TypeHint(ControllerServiceEntity.class)
     public Response removeControllerService(
             @Context HttpServletRequest httpServletRequest,
             @QueryParam(VERSION) LongParameter version,
             @QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId,
-            @PathParam("id") String id) {
+            @PathParam("availability") String availability, @PathParam("id") String id) {
 
+        final Availability avail = parseAvailability(availability);
+        
         // replicate if cluster manager
-        if (properties.isClusterManager()) {
+        if (properties.isClusterManager() && Availability.NODE.equals(avail)) {
             return clusterManager.applyRequest(HttpMethod.DELETE, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse();
         }
 
@@ -519,6 +573,7 @@ public class ControllerServiceResource extends ApplicationResource {
     }
 
     // setters
+    
     public void setServiceFacade(NiFiServiceFacade serviceFacade) {
         this.serviceFacade = serviceFacade;
     }

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/22822d33/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 ccc8023..551dcd3 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
@@ -216,7 +216,6 @@ public class StandardControllerServiceDAO extends ComponentDAO implements Contro
      */
     private void configureControllerService(final ControllerServiceNode controllerService, final ControllerServiceDTO controllerServiceDTO) {
         final String name = controllerServiceDTO.getName();
-        final String availability = controllerServiceDTO.getAvailability();
         final String annotationData = controllerServiceDTO.getAnnotationData();
         final String comments = controllerServiceDTO.getComments();
         final Map<String, String> properties = controllerServiceDTO.getProperties();

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/22822d33/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/spring/OptimisticLockingManagerFactoryBean.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/spring/OptimisticLockingManagerFactoryBean.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/spring/OptimisticLockingManagerFactoryBean.java
new file mode 100644
index 0000000..850d2fd
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/spring/OptimisticLockingManagerFactoryBean.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.web.spring;
+
+import org.apache.nifi.cluster.manager.impl.WebClusterManager;
+import org.apache.nifi.controller.FlowController;
+import org.apache.nifi.controller.repository.FlowFileEventRepository;
+import org.apache.nifi.util.NiFiProperties;
+import org.apache.nifi.web.ClusterAwareOptimisticLockingManager;
+import org.apache.nifi.web.ClusterRequestException;
+import org.apache.nifi.web.OptimisticLockingManager;
+import org.apache.nifi.web.StandardOptimisticLockingManager;
+import org.apache.nifi.web.dao.ControllerServiceDAO;
+import org.apache.nifi.web.dao.impl.StandardControllerServiceDAO;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+/**
+ *
+ */
+public class OptimisticLockingManagerFactoryBean implements FactoryBean, ApplicationContextAware {
+
+    private ApplicationContext context;
+    private OptimisticLockingManager optimisticLockingManager;
+    private NiFiProperties properties;
+
+    @Override
+    public Object getObject() throws Exception {
+        if (optimisticLockingManager == null) {
+            if (properties.isClusterManager()) {
+                optimisticLockingManager = context.getBean("clusterManagerOptimisticLockingManager", OptimisticLockingManager.class);
+            } else {
+                optimisticLockingManager = new ClusterAwareOptimisticLockingManager(new StandardOptimisticLockingManager());
+            }
+        }
+
+        return optimisticLockingManager;
+    }
+
+    @Override
+    public Class getObjectType() {
+        return OptimisticLockingManager.class;
+    }
+
+    @Override
+    public boolean isSingleton() {
+        return true;
+    }
+
+    public void setProperties(NiFiProperties properties) {
+        this.properties = properties;
+    }
+
+    @Override
+    public void setApplicationContext(ApplicationContext context) throws BeansException {
+        this.context = context;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/22822d33/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/resources/nifi-web-api-context.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/resources/nifi-web-api-context.xml b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/resources/nifi-web-api-context.xml
index 8bc4fdd..61b68c5 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/resources/nifi-web-api-context.xml
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/resources/nifi-web-api-context.xml
@@ -25,11 +25,7 @@
     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd">
 
     <!-- optimistic locking manager -->
-    <bean id="optimisticLockingManager" class="org.apache.nifi.web.ClusterAwareOptimisticLockingManager">
-        <constructor-arg>
-            <bean class="org.apache.nifi.web.StandardOptimisticLockingManager" />
-        </constructor-arg>
-    </bean>
+    <bean id="webOptimisticLockingManager" class="org.apache.nifi.web.spring.OptimisticLockingManagerFactoryBean" depends-on="clusterManagerOptimisticLockingManager"/>
 
     <!-- dto factory -->
     <bean id="dtoFactory" class="org.apache.nifi.web.api.dto.DtoFactory">
@@ -103,7 +99,7 @@
         <property name="auditService" ref="auditService"/>
         <property name="userService" ref="userService"/>
         <property name="snippetUtils" ref="snippetUtils"/>
-        <property name="optimisticLockingManager" ref="optimisticLockingManager"/>
+        <property name="optimisticLockingManager" ref="webOptimisticLockingManager"/>
         <property name="dtoFactory" ref="dtoFactory"/>
         <property name="clusterManager" ref="clusterManager"/>
     </bean>


[5/6] incubator-nifi git commit: NIFI-250: - Using the ControllerServiceProvider instead of delegating directly to the FlowController. This will allow us to work with the NCM when clustered.

Posted by mc...@apache.org.
NIFI-250:
- Using the ControllerServiceProvider instead of delegating directly to the FlowController. This will allow us to work with the NCM when clustered.

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

Branch: refs/heads/NIFI-250
Commit: 346cc0cf14aad3f2240336eda711e63f29e62a7c
Parents: 0cb1adb
Author: Matt Gilman <ma...@gmail.com>
Authored: Mon Feb 2 07:55:57 2015 -0500
Committer: Matt Gilman <ma...@gmail.com>
Committed: Mon Feb 2 07:55:57 2015 -0500

----------------------------------------------------------------------
 .../dao/impl/StandardControllerServiceDAO.java  | 22 ++++++++++----------
 1 file changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/346cc0cf/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 73db3eb..ccc8023 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
@@ -22,17 +22,17 @@ import java.util.Map;
 import java.util.Set;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.nifi.controller.Availability;
-import org.apache.nifi.controller.FlowController;
 
 import org.apache.nifi.controller.exception.ValidationException;
 import org.apache.nifi.controller.service.ControllerServiceNode;
+import org.apache.nifi.controller.service.ControllerServiceProvider;
 import org.apache.nifi.web.ResourceNotFoundException;
 import org.apache.nifi.web.api.dto.ControllerServiceDTO;
 import org.apache.nifi.web.dao.ControllerServiceDAO;
 
 public class StandardControllerServiceDAO extends ComponentDAO implements ControllerServiceDAO {
 
-    private FlowController flowController;
+    private ControllerServiceProvider serviceProvider;
 
     /**
      * Locates the specified controller service.
@@ -42,7 +42,7 @@ public class StandardControllerServiceDAO extends ComponentDAO implements Contro
      */
     private ControllerServiceNode locateControllerService(final String controllerServiceId) {
         // get the controller service
-        final ControllerServiceNode controllerService = flowController.getControllerServiceNode(controllerServiceId);
+        final ControllerServiceNode controllerService = serviceProvider.getControllerServiceNode(controllerServiceId);
 
         // ensure the controller service exists
         if (controllerService == null) {
@@ -62,7 +62,7 @@ public class StandardControllerServiceDAO extends ComponentDAO implements Contro
     public ControllerServiceNode createControllerService(final ControllerServiceDTO controllerServiceDTO) {
         // create the controller service
     	final Availability availability = Availability.valueOf(controllerServiceDTO.getAvailability().toUpperCase());
-        final ControllerServiceNode controllerService = flowController.createControllerService(controllerServiceDTO.getType(), availability, true);
+        final ControllerServiceNode controllerService = serviceProvider.createControllerService(controllerServiceDTO.getType(), availability, true);
         
         // ensure we can perform the update 
         verifyUpdate(controllerService, controllerServiceDTO);
@@ -92,7 +92,7 @@ public class StandardControllerServiceDAO extends ComponentDAO implements Contro
      */
     @Override
     public boolean hasControllerService(final String controllerServiceId) {
-        return flowController.getControllerServiceNode(controllerServiceId) != null;
+        return serviceProvider.getControllerServiceNode(controllerServiceId) != null;
     }
 
     /**
@@ -102,7 +102,7 @@ public class StandardControllerServiceDAO extends ComponentDAO implements Contro
      */
     @Override
     public Set<ControllerServiceNode> getControllerServices() {
-        return flowController.getAllControllerServices();
+        return serviceProvider.getAllControllerServices();
     }
 
     /**
@@ -128,9 +128,9 @@ public class StandardControllerServiceDAO extends ComponentDAO implements Contro
             
             if (proposedDisabled != controllerService.isDisabled()) {
                 if (proposedDisabled) {
-                    flowController.disableControllerService(controllerService);
+                    serviceProvider.disableControllerService(controllerService);
                 } else {
-                    flowController.enableControllerService(controllerService);
+                    serviceProvider.enableControllerService(controllerService);
                 }
             }
         }
@@ -251,11 +251,11 @@ public class StandardControllerServiceDAO extends ComponentDAO implements Contro
     @Override
     public void deleteControllerService(String controllerServiceId) {
         final ControllerServiceNode controllerService = locateControllerService(controllerServiceId);
-        flowController.removeControllerService(controllerService);
+        serviceProvider.removeControllerService(controllerService);
     }
 
     /* setters */
-    public void setFlowController(FlowController flowController) {
-        this.flowController = flowController;
+    public void setServiceProvider(ControllerServiceProvider serviceProvider) {
+        this.serviceProvider = serviceProvider;
     }
 }