You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by al...@apache.org on 2017/08/11 01:42:31 UTC
nifi git commit: NIFI-2167 - include disabled state for processors
when copy/paste/templates
Repository: nifi
Updated Branches:
refs/heads/master 96f5407ed -> 69f263c4d
NIFI-2167 - include disabled state for processors when copy/paste/templates
This closes #2057.
Signed-off-by: Andy LoPresto <al...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/69f263c4
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/69f263c4
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/69f263c4
Branch: refs/heads/master
Commit: 69f263c4d116ed10f659ef121df948d9780f8d46
Parents: 96f5407
Author: Pierre Villard <pi...@gmail.com>
Authored: Fri Aug 4 16:46:17 2017 +0200
Committer: Andy LoPresto <al...@apache.org>
Committed: Thu Aug 10 18:41:24 2017 -0700
----------------------------------------------------------------------
.../apache/nifi/controller/FlowController.java | 4 ++
.../apache/nifi/controller/TemplateUtils.java | 1 -
.../nifi/controller/TestFlowController.java | 56 ++++++++++++++++++++
.../org/apache/nifi/web/util/SnippetUtils.java | 6 ++-
4 files changed, 65 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/nifi/blob/69f263c4/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java
index 8da894f..2e351a3 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java
@@ -1870,6 +1870,10 @@ public class FlowController implements EventAccess, ControllerServiceProvider, R
procNode.setExecutionNode(ExecutionNode.valueOf(config.getExecutionNode()));
}
+ if (processorDTO.getState().equals(ScheduledState.DISABLED.toString())) {
+ procNode.disable();
+ }
+
// ensure that the scheduling strategy is set prior to these values
procNode.setMaxConcurrentTasks(config.getConcurrentlySchedulableTaskCount());
procNode.setScheduldingPeriod(config.getSchedulingPeriod());
http://git-wip-us.apache.org/repos/asf/nifi/blob/69f263c4/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/TemplateUtils.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/TemplateUtils.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/TemplateUtils.java
index ff7d61f..be27c5e 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/TemplateUtils.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/TemplateUtils.java
@@ -205,7 +205,6 @@ public class TemplateUtils {
processorDTO.setDescription(null);
processorDTO.setInputRequirement(null);
processorDTO.setPersistsState(null);
- processorDTO.setState(null);
processorDTO.setSupportsBatching(null);
processorDTO.setSupportsEventDriven(null);
processorDTO.setSupportsParallelProcessing(null);
http://git-wip-us.apache.org/repos/asf/nifi/blob/69f263c4/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestFlowController.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestFlowController.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestFlowController.java
index 31bf497..691af10 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestFlowController.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestFlowController.java
@@ -846,6 +846,62 @@ public class TestFlowController {
assertEquals(1, controller.getRootGroup().getProcessors().size());
}
+ @Test
+ public void testInstantiateSnippetWithDisabledProcessor() throws ProcessorInstantiationException {
+ final String id = UUID.randomUUID().toString();
+ final BundleCoordinate coordinate = systemBundle.getBundleDetails().getCoordinate();
+ final ProcessorNode processorNode = controller.createProcessor(DummyProcessor.class.getName(), id, coordinate);
+ processorNode.disable();
+
+ // create a processor dto
+ final ProcessorDTO processorDTO = new ProcessorDTO();
+ processorDTO.setId(UUID.randomUUID().toString()); // use a different id here
+ processorDTO.setPosition(new PositionDTO(new Double(0), new Double(0)));
+ processorDTO.setStyle(processorNode.getStyle());
+ processorDTO.setParentGroupId("1234");
+ processorDTO.setInputRequirement(processorNode.getInputRequirement().name());
+ processorDTO.setPersistsState(processorNode.getProcessor().getClass().isAnnotationPresent(Stateful.class));
+ processorDTO.setRestricted(processorNode.isRestricted());
+ processorDTO.setExtensionMissing(processorNode.isExtensionMissing());
+
+ processorDTO.setType(processorNode.getCanonicalClassName());
+ processorDTO.setBundle(new BundleDTO(coordinate.getGroup(), coordinate.getId(), coordinate.getVersion()));
+ processorDTO.setName(processorNode.getName());
+ processorDTO.setState(processorNode.getScheduledState().toString());
+
+ processorDTO.setRelationships(new ArrayList<>());
+
+ processorDTO.setDescription("description");
+ processorDTO.setSupportsParallelProcessing(!processorNode.isTriggeredSerially());
+ processorDTO.setSupportsEventDriven(processorNode.isEventDrivenSupported());
+ processorDTO.setSupportsBatching(processorNode.isHighThroughputSupported());
+
+ ProcessorConfigDTO configDTO = new ProcessorConfigDTO();
+ configDTO.setSchedulingPeriod(processorNode.getSchedulingPeriod());
+ configDTO.setPenaltyDuration(processorNode.getPenalizationPeriod());
+ configDTO.setYieldDuration(processorNode.getYieldPeriod());
+ configDTO.setRunDurationMillis(processorNode.getRunDuration(TimeUnit.MILLISECONDS));
+ configDTO.setConcurrentlySchedulableTaskCount(processorNode.getMaxConcurrentTasks());
+ configDTO.setLossTolerant(processorNode.isLossTolerant());
+ configDTO.setComments(processorNode.getComments());
+ configDTO.setBulletinLevel(processorNode.getBulletinLevel().name());
+ configDTO.setSchedulingStrategy(processorNode.getSchedulingStrategy().name());
+ configDTO.setExecutionNode(processorNode.getExecutionNode().name());
+ configDTO.setAnnotationData(processorNode.getAnnotationData());
+
+ processorDTO.setConfig(configDTO);
+
+ // create the snippet with the processor
+ final FlowSnippetDTO flowSnippetDTO = new FlowSnippetDTO();
+ flowSnippetDTO.setProcessors(Collections.singleton(processorDTO));
+
+ // instantiate the snippet
+ assertEquals(0, controller.getRootGroup().getProcessors().size());
+ controller.instantiateSnippet(controller.getRootGroup(), flowSnippetDTO);
+ assertEquals(1, controller.getRootGroup().getProcessors().size());
+ assertTrue(controller.getRootGroup().getProcessors().iterator().next().getScheduledState().equals(ScheduledState.DISABLED));
+ }
+
@Test(expected = IllegalArgumentException.class)
public void testInstantiateSnippetWhenControllerServiceMissingBundle() throws ProcessorInstantiationException {
final String id = UUID.randomUUID().toString();
http://git-wip-us.apache.org/repos/asf/nifi/blob/69f263c4/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/util/SnippetUtils.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/util/SnippetUtils.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/util/SnippetUtils.java
index ff8b566..db7a5b0 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/util/SnippetUtils.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/util/SnippetUtils.java
@@ -599,7 +599,11 @@ public final class SnippetUtils {
final ProcessorDTO cp = dtoFactory.copy(processorDTO);
cp.setId(generateId(processorDTO.getId(), idGenerationSeed, isCopy));
cp.setParentGroupId(groupId);
- cp.setState(ScheduledState.STOPPED.toString());
+ if(processorDTO.getState() != null && processorDTO.getState().equals(ScheduledState.DISABLED.toString())) {
+ cp.setState(ScheduledState.DISABLED.toString());
+ } else {
+ cp.setState(ScheduledState.STOPPED.toString());
+ }
processors.add(cp);
connectableMap.put(processorDTO.getParentGroupId() + "-" + processorDTO.getId(), dtoFactory.createConnectableDto(cp));