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/03/06 16:17:32 UTC
[50/50] incubator-nifi git commit: NIFI-250: - Adding a factory bean
for obtaining the appropriate ReportingTaskProvider given the configured
operating mode (cluster/node). - Fixing copy/paste error with the
ControllerServiceProvicer factory bean.
NIFI-250:
- Adding a factory bean for obtaining the appropriate ReportingTaskProvider given the configured operating mode (cluster/node).
- Fixing copy/paste error with the ControllerServiceProvicer factory bean.
Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/91f69b0c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/91f69b0c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/91f69b0c
Branch: refs/heads/NIFI-250
Commit: 91f69b0cf23422838ca1f055064ae90e8749738f
Parents: ed22742
Author: Matt Gilman <ma...@gmail.com>
Authored: Fri Mar 6 10:16:23 2015 -0500
Committer: Matt Gilman <ma...@gmail.com>
Committed: Fri Mar 6 10:16:23 2015 -0500
----------------------------------------------------------------------
.../web/dao/impl/StandardReportingTaskDAO.java | 15 +++--
.../ControllerServiceProviderFactoryBean.java | 3 +-
.../ReportingTaskProviderFactoryBean.java | 69 ++++++++++++++++++++
.../src/main/resources/nifi-web-api-context.xml | 8 ++-
4 files changed, 84 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/91f69b0c/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardReportingTaskDAO.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/StandardReportingTaskDAO.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/StandardReportingTaskDAO.java
index 793f77d..aa4e034 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/StandardReportingTaskDAO.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/StandardReportingTaskDAO.java
@@ -26,6 +26,7 @@ import org.apache.nifi.controller.ReportingTaskNode;
import org.apache.nifi.controller.exception.ValidationException;
import org.apache.nifi.controller.reporting.ReportingTaskInstantiationException;
+import org.apache.nifi.controller.reporting.ReportingTaskProvider;
import org.apache.nifi.web.NiFiCoreException;
import org.apache.nifi.web.ResourceNotFoundException;
import org.apache.nifi.web.api.dto.ReportingTaskDTO;
@@ -33,7 +34,7 @@ import org.apache.nifi.web.dao.ReportingTaskDAO;
public class StandardReportingTaskDAO extends ComponentDAO implements ReportingTaskDAO {
- private FlowController flowController;
+ private ReportingTaskProvider reportingTaskProvider;
/**
* Locates the specified reporting task.
@@ -43,7 +44,7 @@ public class StandardReportingTaskDAO extends ComponentDAO implements ReportingT
*/
private ReportingTaskNode locateReportingTask(final String reportingTaskId) {
// get the reporting task
- final ReportingTaskNode reportingTask = flowController.getReportingTaskNode(reportingTaskId);
+ final ReportingTaskNode reportingTask = reportingTaskProvider.getReportingTaskNode(reportingTaskId);
// ensure the reporting task exists
if (reportingTask == null) {
@@ -63,7 +64,7 @@ public class StandardReportingTaskDAO extends ComponentDAO implements ReportingT
public ReportingTaskNode createReportingTask(final ReportingTaskDTO reportingTaskDTO) {
try {
// create the reporting task
- final ReportingTaskNode reportingTask = flowController.createReportingTask(reportingTaskDTO.getType(), reportingTaskDTO.getId(), true);
+ final ReportingTaskNode reportingTask = reportingTaskProvider.createReportingTask(reportingTaskDTO.getType(), reportingTaskDTO.getId(), true);
// ensure we can perform the update
verifyUpdate(reportingTask, reportingTaskDTO);
@@ -96,7 +97,7 @@ public class StandardReportingTaskDAO extends ComponentDAO implements ReportingT
*/
@Override
public boolean hasReportingTask(final String reportingTaskId) {
- return flowController.getReportingTaskNode(reportingTaskId) != null;
+ return reportingTaskProvider.getReportingTaskNode(reportingTaskId) != null;
}
/**
@@ -220,12 +221,12 @@ public class StandardReportingTaskDAO extends ComponentDAO implements ReportingT
@Override
public void deleteReportingTask(String reportingTaskId) {
final ReportingTaskNode reportingTask = locateReportingTask(reportingTaskId);
- flowController.removeReportingTask(reportingTask);
+ reportingTaskProvider.removeReportingTask(reportingTask);
}
/* setters */
- public void setFlowController(FlowController flowController) {
- this.flowController = flowController;
+ public void setReportingTaskProvider(ReportingTaskProvider reportingTaskProvider) {
+ this.reportingTaskProvider = reportingTaskProvider;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/91f69b0c/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/spring/ControllerServiceProviderFactoryBean.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/ControllerServiceProviderFactoryBean.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/spring/ControllerServiceProviderFactoryBean.java
index 6433510..5c10de6 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/spring/ControllerServiceProviderFactoryBean.java
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/spring/ControllerServiceProviderFactoryBean.java
@@ -20,7 +20,6 @@ import org.apache.nifi.cluster.manager.impl.WebClusterManager;
import org.apache.nifi.controller.FlowController;
import org.apache.nifi.controller.service.ControllerServiceProvider;
import org.apache.nifi.util.NiFiProperties;
-import org.apache.nifi.web.dao.ControllerServiceDAO;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.context.ApplicationContext;
@@ -50,7 +49,7 @@ public class ControllerServiceProviderFactoryBean implements FactoryBean, Applic
@Override
public Class getObjectType() {
- return ControllerServiceDAO.class;
+ return ControllerServiceProvider.class;
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/91f69b0c/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/spring/ReportingTaskProviderFactoryBean.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/ReportingTaskProviderFactoryBean.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/spring/ReportingTaskProviderFactoryBean.java
new file mode 100644
index 0000000..d344fa6
--- /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/ReportingTaskProviderFactoryBean.java
@@ -0,0 +1,69 @@
+/*
+ * 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.reporting.ReportingTaskProvider;
+import org.apache.nifi.util.NiFiProperties;
+import org.apache.nifi.web.dao.ControllerServiceDAO;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+/**
+ *
+ */
+public class ReportingTaskProviderFactoryBean implements FactoryBean, ApplicationContextAware {
+
+ private ApplicationContext context;
+ private ReportingTaskProvider reportingTaskProvider;
+ private NiFiProperties properties;
+
+ @Override
+ public Object getObject() throws Exception {
+ if (reportingTaskProvider == null) {
+ if (properties.isClusterManager()) {
+ reportingTaskProvider = context.getBean("clusterManager", WebClusterManager.class);
+ } else {
+ reportingTaskProvider = context.getBean("flowController", FlowController.class);
+ }
+ }
+
+ return reportingTaskProvider;
+ }
+
+ @Override
+ public Class getObjectType() {
+ return ReportingTaskProvider.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/91f69b0c/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 34c56b6..940eb62 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
@@ -24,7 +24,11 @@
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd">
- <bean id="controllerServiceProvider" class="org.apache.nifi.web.spring.ControllerServiceProviderFactoryBean" depends-on="clusterManagerOptimisticLockingManager">
+ <!-- controller service / reporting task -->
+ <bean id="controllerServiceProvider" class="org.apache.nifi.web.spring.ControllerServiceProviderFactoryBean" depends-on="clusterManager flowController">
+ <property name="properties" ref="nifiProperties"/>
+ </bean>
+ <bean id="reportingTaskProvider" class="org.apache.nifi.web.spring.ReportingTaskProviderFactoryBean" depends-on="clusterManager flowController">
<property name="properties" ref="nifiProperties"/>
</bean>
@@ -73,7 +77,7 @@
<property name="serviceProvider" ref="controllerServiceProvider"/>
</bean>
<bean id="reportingTaskDAO" class="org.apache.nifi.web.dao.impl.StandardReportingTaskDAO">
- <property name="flowController" ref="flowController"/>
+ <property name="reportingTaskProvider" ref="reportingTaskProvider"/>
</bean>
<bean id="templateDAO" class="org.apache.nifi.web.dao.impl.StandardTemplateDAO">
<property name="flowController" ref="flowController"/>