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 2019/02/26 12:46:18 UTC

[nifi-minifi] branch master updated: MINIFI-493 Provide handling of templates created by NiFi versions <1.0

This is an automated email from the ASF dual-hosted git repository.

aldrin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi-minifi.git


The following commit(s) were added to refs/heads/master by this push:
     new fb24662  MINIFI-493 Provide handling of templates created by NiFi versions <1.0
fb24662 is described below

commit fb246621474c6a4e4b4d5cf935202dfeec16ada6
Author: Aldrin Piri <al...@apache.org>
AuthorDate: Fri Feb 15 14:26:58 2019 -0500

    MINIFI-493 Provide handling of templates created by NiFi versions <1.0
    
    This closes #150.
    
    Signed-off-by: Aldrin Piri <al...@apache.org>
---
 .../configuration/dto/FlowSnippetDTOEnricher.java  |  24 ++-
 .../toolkit/configuration/ConfigMainTest.java      |   5 +
 .../test/resources/NoTemplateEncodingVersion.xml   | 214 +++++++++++++++++++++
 .../test/resources/NoTemplateEncodingVersion.yml   | 123 ++++++++++++
 4 files changed, 357 insertions(+), 9 deletions(-)

diff --git a/minifi-toolkit/minifi-toolkit-configuration/src/main/java/org/apache/nifi/minifi/toolkit/configuration/dto/FlowSnippetDTOEnricher.java b/minifi-toolkit/minifi-toolkit-configuration/src/main/java/org/apache/nifi/minifi/toolkit/configuration/dto/FlowSnippetDTOEnricher.java
index 487db2d..a197925 100644
--- a/minifi-toolkit/minifi-toolkit-configuration/src/main/java/org/apache/nifi/minifi/toolkit/configuration/dto/FlowSnippetDTOEnricher.java
+++ b/minifi-toolkit/minifi-toolkit-configuration/src/main/java/org/apache/nifi/minifi/toolkit/configuration/dto/FlowSnippetDTOEnricher.java
@@ -59,15 +59,21 @@ public class FlowSnippetDTOEnricher {
             final Set<RemoteProcessGroupPortDTO> rpgInputPortDtos = nullToEmpty(contents.getInputPorts());
             final Set<RemoteProcessGroupPortDTO> rpgOutputPortDtos = nullToEmpty(contents.getOutputPorts());
 
-            switch (encodingVersion) {
-                case "1.2":
-                    // Map all port DTOs to their respective targetIds
-                    rpgIdToTargetIdMap.putAll(
-                            Stream.concat(rpgInputPortDtos.stream(), rpgOutputPortDtos.stream())
-                                    .collect(Collectors.toMap(RemoteProcessGroupPortDTO::getId, RemoteProcessGroupPortDTO::getTargetId)));
-                    break;
-                default:
-                    break;
+            /*
+             *  Templates created prior to version 1.0 of NiFi did not have an encoding-version specified
+             *   There are no material changes to the flow representation that affect MiNiFi prior to the 1.2 encoding-version introduced in NiFi 1.5, so we avoid evaluating
+             */
+            if (encodingVersion != null) {
+                switch (encodingVersion) {
+                    case "1.2":
+                        // Map all port DTOs to their respective targetIds
+                        rpgIdToTargetIdMap.putAll(
+                                Stream.concat(rpgInputPortDtos.stream(), rpgOutputPortDtos.stream())
+                                        .collect(Collectors.toMap(RemoteProcessGroupPortDTO::getId, RemoteProcessGroupPortDTO::getTargetId)));
+                        break;
+                    default:
+                        break;
+                }
             }
 
             addConnectables(connectableNameMap, rpgInputPortDtos, RemoteProcessGroupPortDTO::getId, RemoteProcessGroupPortDTO::getId);
diff --git a/minifi-toolkit/minifi-toolkit-configuration/src/test/java/org/apache/nifi/minifi/toolkit/configuration/ConfigMainTest.java b/minifi-toolkit/minifi-toolkit-configuration/src/test/java/org/apache/nifi/minifi/toolkit/configuration/ConfigMainTest.java
index af454bb..c022dbf 100644
--- a/minifi-toolkit/minifi-toolkit-configuration/src/test/java/org/apache/nifi/minifi/toolkit/configuration/ConfigMainTest.java
+++ b/minifi-toolkit/minifi-toolkit-configuration/src/test/java/org/apache/nifi/minifi/toolkit/configuration/ConfigMainTest.java
@@ -168,6 +168,11 @@ public class ConfigMainTest {
     }
 
     @Test
+    public void testTransformRoundTripTemplateNoEncodingVersion() throws IOException, JAXBException, SchemaLoaderException {
+        transformRoundTrip("NoTemplateEncodingVersion");
+    }
+
+    @Test
     public void testTransformRoundTrip15RPGHandling() throws IOException, JAXBException, SchemaLoaderException {
         transformRoundTrip("1.5_RPG_Handling");
     }
diff --git a/minifi-toolkit/minifi-toolkit-configuration/src/test/resources/NoTemplateEncodingVersion.xml b/minifi-toolkit/minifi-toolkit-configuration/src/test/resources/NoTemplateEncodingVersion.xml
new file mode 100644
index 0000000..e4ea628
--- /dev/null
+++ b/minifi-toolkit/minifi-toolkit-configuration/src/test/resources/NoTemplateEncodingVersion.xml
@@ -0,0 +1,214 @@
+<?xml version="1.0" ?>
+<!--
+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.
+ -->
+<template>
+  <description></description>
+  <groupId>92d57ac5-0158-1000-aab7-42ca398aadea</groupId>
+  <name>Simple TailFile To RPG</name>
+  <snippet>
+    <connections>
+      <id>b0c0c3cc-0158-1000-0000-000000000000</id>
+      <parentGroupId>92d57ac5-0158-1000-0000-000000000000</parentGroupId>
+      <backPressureDataSizeThreshold>1 GB</backPressureDataSizeThreshold>
+      <backPressureObjectThreshold>10000</backPressureObjectThreshold>
+      <destination>
+        <groupId>b0c09ff0-0158-1000-0000-000000000000</groupId>
+        <id>ac0e798c-0158-1000-0588-cda9b944e011</id>
+        <type>REMOTE_INPUT_PORT</type>
+      </destination>
+      <flowFileExpiration>0 sec</flowFileExpiration>
+      <labelIndex>1</labelIndex>
+      <name></name>
+      <selectedRelationships>success</selectedRelationships>
+      <source>
+        <groupId>92d57ac5-0158-1000-0000-000000000000</groupId>
+        <id>b0c04f28-0158-1000-0000-000000000000</id>
+        <type>PROCESSOR</type>
+      </source>
+      <zIndex>0</zIndex>
+    </connections>
+    <processors>
+      <id>b0c04f28-0158-1000-0000-000000000000</id>
+      <parentGroupId>92d57ac5-0158-1000-0000-000000000000</parentGroupId>
+      <position>
+        <x>20.698639744598154</x>
+        <y>0.0</y>
+      </position>
+      <config>
+        <bulletinLevel>WARN</bulletinLevel>
+        <comments></comments>
+        <concurrentlySchedulableTaskCount>1</concurrentlySchedulableTaskCount>
+        <descriptors>
+          <entry>
+            <key>tail-mode</key>
+            <value>
+              <name>tail-mode</name>
+            </value>
+          </entry>
+          <entry>
+            <key>File to Tail</key>
+            <value>
+              <name>File to Tail</name>
+            </value>
+          </entry>
+          <entry>
+            <key>Rolling Filename Pattern</key>
+            <value>
+              <name>Rolling Filename Pattern</name>
+            </value>
+          </entry>
+          <entry>
+            <key>tail-base-directory</key>
+            <value>
+              <name>tail-base-directory</name>
+            </value>
+          </entry>
+          <entry>
+            <key>Initial Start Position</key>
+            <value>
+              <name>Initial Start Position</name>
+            </value>
+          </entry>
+          <entry>
+            <key>File Location</key>
+            <value>
+              <name>File Location</name>
+            </value>
+          </entry>
+          <entry>
+            <key>tailfile-recursive-lookup</key>
+            <value>
+              <name>tailfile-recursive-lookup</name>
+            </value>
+          </entry>
+          <entry>
+            <key>tailfile-rolling-strategy</key>
+            <value>
+              <name>tailfile-rolling-strategy</name>
+            </value>
+          </entry>
+          <entry>
+            <key>tailfile-lookup-frequency</key>
+            <value>
+              <name>tailfile-lookup-frequency</name>
+            </value>
+          </entry>
+          <entry>
+            <key>tailfile-maximum-age</key>
+            <value>
+              <name>tailfile-maximum-age</name>
+            </value>
+          </entry>
+        </descriptors>
+        <executionNode>ALL</executionNode>
+        <lossTolerant>false</lossTolerant>
+        <penaltyDuration>30 sec</penaltyDuration>
+        <properties>
+          <entry>
+            <key>tail-mode</key>
+            <value>Single file</value>
+          </entry>
+          <entry>
+            <key>File to Tail</key>
+            <value>./logs/minifi-app.log</value>
+          </entry>
+          <entry>
+            <key>Rolling Filename Pattern</key>
+          </entry>
+          <entry>
+            <key>tail-base-directory</key>
+          </entry>
+          <entry>
+            <key>Initial Start Position</key>
+            <value>Beginning of File</value>
+          </entry>
+          <entry>
+            <key>File Location</key>
+            <value>Local</value>
+          </entry>
+          <entry>
+            <key>tailfile-recursive-lookup</key>
+            <value>false</value>
+          </entry>
+          <entry>
+            <key>tailfile-rolling-strategy</key>
+            <value>Fixed name</value>
+          </entry>
+          <entry>
+            <key>tailfile-lookup-frequency</key>
+            <value>10 minutes</value>
+          </entry>
+          <entry>
+            <key>tailfile-maximum-age</key>
+            <value>24 hours</value>
+          </entry>
+        </properties>
+        <runDurationMillis>0</runDurationMillis>
+        <schedulingPeriod>1 sec</schedulingPeriod>
+        <schedulingStrategy>TIMER_DRIVEN</schedulingStrategy>
+        <yieldDuration>1 sec</yieldDuration>
+      </config>
+      <name>TailFile</name>
+      <relationships>
+        <autoTerminate>false</autoTerminate>
+        <name>success</name>
+      </relationships>
+      <style></style>
+      <type>org.apache.nifi.processors.standard.TailFile</type>
+    </processors>
+    <remoteProcessGroups>
+      <id>b0c09ff0-0158-1000-0000-000000000000</id>
+      <parentGroupId>92d57ac5-0158-1000-0000-000000000000</parentGroupId>
+      <position>
+        <x>0.0</x>
+        <y>255.68887264079288</y>
+      </position>
+      <communicationsTimeout>30 sec</communicationsTimeout>
+      <contents>
+        <inputPorts>
+          <comments></comments>
+          <concurrentlySchedulableTaskCount>1</concurrentlySchedulableTaskCount>
+          <connected>false</connected>
+          <exists>true</exists>
+          <id>aca664f8-0158-1000-a139-92485891d349</id>
+          <name>test2</name>
+          <targetRunning>false</targetRunning>
+          <transmitting>false</transmitting>
+          <useCompression>false</useCompression>
+        </inputPorts>
+        <inputPorts>
+          <comments></comments>
+          <concurrentlySchedulableTaskCount>1</concurrentlySchedulableTaskCount>
+          <connected>true</connected>
+          <exists>true</exists>
+          <id>ac0e798c-0158-1000-0588-cda9b944e011</id>
+          <name>test</name>
+          <targetRunning>false</targetRunning>
+          <transmitting>false</transmitting>
+          <useCompression>false</useCompression>
+        </inputPorts>
+      </contents>
+      <proxyHost></proxyHost>
+      <proxyUser></proxyUser>
+      <targetUri>http://localhost:8080/nifi</targetUri>
+      <transportProtocol>RAW</transportProtocol>
+      <yieldDuration>10 sec</yieldDuration>
+      <networkInterface></networkInterface>
+    </remoteProcessGroups>
+  </snippet>
+  <timestamp>11/29/2016 10:43:33 EST</timestamp>
+</template>
\ No newline at end of file
diff --git a/minifi-toolkit/minifi-toolkit-configuration/src/test/resources/NoTemplateEncodingVersion.yml b/minifi-toolkit/minifi-toolkit-configuration/src/test/resources/NoTemplateEncodingVersion.yml
new file mode 100644
index 0000000..aa3ee7c
--- /dev/null
+++ b/minifi-toolkit/minifi-toolkit-configuration/src/test/resources/NoTemplateEncodingVersion.yml
@@ -0,0 +1,123 @@
+# 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.
+
+MiNiFi Config Version: 3
+Flow Controller:
+  name: Simple TailFile To RPG
+  comment: ''
+Core Properties:
+  flow controller graceful shutdown period: 10 sec
+  flow service write delay interval: 500 ms
+  administrative yield duration: 30 sec
+  bored yield duration: 10 millis
+  max concurrent threads: 1
+  variable registry properties: ''
+FlowFile Repository:
+  partitions: 256
+  checkpoint interval: 2 mins
+  always sync: false
+  Swap:
+    threshold: 20000
+    in period: 5 sec
+    in threads: 1
+    out period: 5 sec
+    out threads: 4
+Content Repository:
+  content claim max appendable size: 10 MB
+  content claim max flow files: 100
+  always sync: false
+Provenance Repository:
+  provenance rollover time: 1 min
+  implementation: org.apache.nifi.provenance.MiNiFiPersistentProvenanceRepository
+Component Status Repository:
+  buffer size: 1440
+  snapshot frequency: 1 min
+Security Properties:
+  keystore: ''
+  keystore type: ''
+  keystore password: ''
+  key password: ''
+  truststore: ''
+  truststore type: ''
+  truststore password: ''
+  ssl protocol: ''
+  Sensitive Props:
+    key:
+    algorithm: PBEWITHMD5AND256BITAES-CBC-OPENSSL
+    provider: BC
+Processors:
+- id: b0c04f28-0158-1000-0000-000000000000
+  name: TailFile
+  class: org.apache.nifi.processors.standard.TailFile
+  max concurrent tasks: 1
+  scheduling strategy: TIMER_DRIVEN
+  scheduling period: 1 sec
+  penalization period: 30 sec
+  yield period: 1 sec
+  run duration nanos: 0
+  auto-terminated relationships list: []
+  Properties:
+    File Location: Local
+    File to Tail: ./logs/minifi-app.log
+    Initial Start Position: Beginning of File
+    Rolling Filename Pattern:
+    tail-base-directory:
+    tail-mode: Single file
+    tailfile-lookup-frequency: 10 minutes
+    tailfile-maximum-age: 24 hours
+    tailfile-recursive-lookup: 'false'
+    tailfile-rolling-strategy: Fixed name
+Controller Services: []
+Process Groups: []
+Input Ports: []
+Output Ports: []
+Funnels: []
+Connections:
+- id: b0c0c3cc-0158-1000-0000-000000000000
+  name: TailFile/success/ac0e798c-0158-1000-0588-cda9b944e011
+  source id: b0c04f28-0158-1000-0000-000000000000
+  source relationship names:
+  - success
+  destination id: ac0e798c-0158-1000-0588-cda9b944e011
+  max work queue size: 10000
+  max work queue data size: 1 GB
+  flowfile expiration: 0 sec
+  queue prioritizer class: ''
+Remote Process Groups:
+- id: b0c09ff0-0158-1000-0000-000000000000
+  name: ''
+  url: http://localhost:8080/nifi
+  comment: ''
+  timeout: 30 sec
+  yield period: 10 sec
+  transport protocol: RAW
+  proxy host: ''
+  proxy port: ''
+  proxy user: ''
+  proxy password: ''
+  local network interface: ''
+  Input Ports:
+  - id: aca664f8-0158-1000-a139-92485891d349
+    name: test2
+    comment: ''
+    max concurrent tasks: 1
+    use compression: false
+  - id: ac0e798c-0158-1000-0588-cda9b944e011
+    name: test
+    comment: ''
+    max concurrent tasks: 1
+    use compression: false
+  Output Ports: []
+NiFi Properties Overrides: {}