Repository: nifi-minifi
Updated Branches:
  refs/heads/master 3b6cf270f -> bd842d339


MINIFI-82 Adding support for Processor 'Annotation Data'

This closes #34.

Signed-off-by: Aldrin Piri <ald...@apache.org>


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

Branch: refs/heads/master
Commit: bd842d339d4ed177d949ba43eca9445e5c0924f1
Parents: 3b6cf27
Author: Joseph Percivall <joeperciv...@yahoo.com>
Authored: Wed Sep 21 16:32:35 2016 -0400
Committer: Aldrin Piri <ald...@apache.org>
Committed: Thu Sep 22 14:35:48 2016 -0400

----------------------------------------------------------------------
 .../bootstrap/util/ConfigTransformer.java       |  5 +++
 .../minifi/commons/schema/ProcessorSchema.java  | 15 ++++++++
 .../src/main/markdown/System_Admin_Guide.md     |  1 +
 .../dto/ProcessorSchemaFunction.java            |  5 +++
 .../configuration/dto/ProcessorSchemaTest.java  | 39 ++++++++++++++++++++
 5 files changed, 65 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/bd842d33/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/ConfigTransformer.java
----------------------------------------------------------------------
diff --git 
a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/ConfigTransformer.java
 
b/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/ConfigTransformer.java
index 00e5ab8..ff16703 100644
--- 
a/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/ConfigTransformer.java
+++ 
b/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/util/ConfigTransformer.java
@@ -392,6 +392,11 @@ public final class ConfigTransformer {
             addTextElement(element, "schedulingStrategy", 
processorConfig.getSchedulingStrategy());
             addTextElement(element, "runDurationNanos", 
String.valueOf(processorConfig.getRunDurationNanos()));
 
+            String annotationData = processorConfig.getAnnotationData();
+            if(annotationData != null && !annotationData.isEmpty()) {
+                addTextElement(element, "annotationData", annotationData);
+            }
+
             addConfiguration(element, processorConfig.getProperties());
 
             Collection<String> autoTerminatedRelationships = 
processorConfig.getAutoTerminatedRelationshipsList();

http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/bd842d33/minifi-commons/minifi-commons-schema/src/main/java/org/apache/nifi/minifi/commons/schema/ProcessorSchema.java
----------------------------------------------------------------------
diff --git 
a/minifi-commons/minifi-commons-schema/src/main/java/org/apache/nifi/minifi/commons/schema/ProcessorSchema.java
 
b/minifi-commons/minifi-commons-schema/src/main/java/org/apache/nifi/minifi/commons/schema/ProcessorSchema.java
index 471762a..e2bde47 100644
--- 
a/minifi-commons/minifi-commons-schema/src/main/java/org/apache/nifi/minifi/commons/schema/ProcessorSchema.java
+++ 
b/minifi-commons/minifi-commons-schema/src/main/java/org/apache/nifi/minifi/commons/schema/ProcessorSchema.java
@@ -37,6 +37,8 @@ public class ProcessorSchema extends BaseSchemaWithIdAndName {
     public static final String RUN_DURATION_NANOS_KEY = "run duration nanos";
     public static final String AUTO_TERMINATED_RELATIONSHIPS_LIST_KEY = 
"auto-terminated relationships list";
     public static final String PROCESSOR_PROPS_KEY = "Properties";
+    public static final String ANNOTATION_DATA_KEY = "annotation data";
+
     public static final int DEFAULT_MAX_CONCURRENT_TASKS = 1;
     public static final String DEFAULT_PENALIZATION_PERIOD = "30 sec";
     public static final String DEFAULT_YIELD_DURATION = "1 sec";
@@ -54,6 +56,7 @@ public class ProcessorSchema extends BaseSchemaWithIdAndName {
     private Number runDurationNanos = DEFAULT_RUN_DURATION_NANOS;
     private List<String> autoTerminatedRelationshipsList = 
DEFAULT_AUTO_TERMINATED_RELATIONSHIPS_LIST;
     private Map<String, Object> properties = DEFAULT_PROPERTIES;
+    private String annotationData = "";
 
     public ProcessorSchema(Map map) {
         super(map, PROCESSORS_KEY);
@@ -70,6 +73,8 @@ public class ProcessorSchema extends BaseSchemaWithIdAndName {
         runDurationNanos = getOptionalKeyAsType(map, RUN_DURATION_NANOS_KEY, 
Number.class, PROCESSORS_KEY, DEFAULT_RUN_DURATION_NANOS);
         autoTerminatedRelationshipsList = getOptionalKeyAsType(map, 
AUTO_TERMINATED_RELATIONSHIPS_LIST_KEY, List.class, PROCESSORS_KEY, 
DEFAULT_AUTO_TERMINATED_RELATIONSHIPS_LIST);
         properties = getOptionalKeyAsType(map, PROCESSOR_PROPS_KEY, Map.class, 
PROCESSORS_KEY, DEFAULT_PROPERTIES);
+
+        annotationData = getOptionalKeyAsType(map, ANNOTATION_DATA_KEY, 
String.class, PROCESSORS_KEY, "");
     }
 
     private static boolean isSchedulingStrategy(String string) {
@@ -93,6 +98,11 @@ public class ProcessorSchema extends BaseSchemaWithIdAndName 
{
         result.put(RUN_DURATION_NANOS_KEY, runDurationNanos);
         result.put(AUTO_TERMINATED_RELATIONSHIPS_LIST_KEY, 
autoTerminatedRelationshipsList);
         result.put(PROCESSOR_PROPS_KEY, new TreeMap<>(properties));
+
+        if(annotationData != null && !annotationData.isEmpty()) {
+            result.put(ANNOTATION_DATA_KEY, annotationData);
+        }
+
         return result;
     }
 
@@ -131,4 +141,9 @@ public class ProcessorSchema extends 
BaseSchemaWithIdAndName {
     public Map<String, Object> getProperties() {
         return properties;
     }
+
+    public String getAnnotationData() {
+        return annotationData;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/bd842d33/minifi-docs/src/main/markdown/System_Admin_Guide.md
----------------------------------------------------------------------
diff --git a/minifi-docs/src/main/markdown/System_Admin_Guide.md 
b/minifi-docs/src/main/markdown/System_Admin_Guide.md
index 1bab1ea..5ee87e0 100644
--- a/minifi-docs/src/main/markdown/System_Admin_Guide.md
+++ b/minifi-docs/src/main/markdown/System_Admin_Guide.md
@@ -299,6 +299,7 @@ penalization period                 | Specifies how long 
FlowFiles will be penal
 yield period                        | In the event the processor cannot make 
progress it should `yield` which will prevent the processor from being 
scheduled to run for some period of time. That period of time is specific using 
this property.
 run duration nanos                  | If the processor supports batching this 
property can be used to control how long the Processor should be scheduled to 
run each time that it is triggered. Smaller values will have lower latency but 
larger values will have higher throughput. This period should typically only be 
set between 0 and 2000000000 (2 seconds).
 auto-terminated relationships list  | A YAML list of the relationships to 
auto-terminate for the processor.
+annotation data                     | Some processors make use of "Annotation 
Data" in order to do more complex configuration, such as the Advanced portion 
of UpdateAttribute. This data will be unique to each implementing processor and 
more than likely will not be written out manually.
 
 #### Processor Properties
 

http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/bd842d33/minifi-toolkit/minifi-toolkit-configuration/src/main/java/org/apache/nifi/minifi/toolkit/configuration/dto/ProcessorSchemaFunction.java
----------------------------------------------------------------------
diff --git 
a/minifi-toolkit/minifi-toolkit-configuration/src/main/java/org/apache/nifi/minifi/toolkit/configuration/dto/ProcessorSchemaFunction.java
 
b/minifi-toolkit/minifi-toolkit-configuration/src/main/java/org/apache/nifi/minifi/toolkit/configuration/dto/ProcessorSchemaFunction.java
index dde36bc..21b3345 100644
--- 
a/minifi-toolkit/minifi-toolkit-configuration/src/main/java/org/apache/nifi/minifi/toolkit/configuration/dto/ProcessorSchemaFunction.java
+++ 
b/minifi-toolkit/minifi-toolkit-configuration/src/main/java/org/apache/nifi/minifi/toolkit/configuration/dto/ProcessorSchemaFunction.java
@@ -59,6 +59,11 @@ public class ProcessorSchemaFunction implements 
Function<ProcessorDTO, Processor
                 .collect(Collectors.toList()));
         map.put(ProcessorSchema.PROCESSOR_PROPS_KEY, new 
HashMap<>(BaseSchema.nullToEmpty(processorDTOConfig.getProperties())));
 
+        String annotationData = processorDTOConfig.getAnnotationData();
+        if(annotationData != null && !annotationData.isEmpty()) {
+            map.put(ProcessorSchema.ANNOTATION_DATA_KEY, annotationData);
+        }
+
         return new ProcessorSchema(map);
     }
 }

http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/bd842d33/minifi-toolkit/minifi-toolkit-configuration/src/test/java/org/apache/nifi/minifi/toolkit/configuration/dto/ProcessorSchemaTest.java
----------------------------------------------------------------------
diff --git 
a/minifi-toolkit/minifi-toolkit-configuration/src/test/java/org/apache/nifi/minifi/toolkit/configuration/dto/ProcessorSchemaTest.java
 
b/minifi-toolkit/minifi-toolkit-configuration/src/test/java/org/apache/nifi/minifi/toolkit/configuration/dto/ProcessorSchemaTest.java
index bf072d2..f98afe3 100644
--- 
a/minifi-toolkit/minifi-toolkit-configuration/src/test/java/org/apache/nifi/minifi/toolkit/configuration/dto/ProcessorSchemaTest.java
+++ 
b/minifi-toolkit/minifi-toolkit-configuration/src/test/java/org/apache/nifi/minifi/toolkit/configuration/dto/ProcessorSchemaTest.java
@@ -45,6 +45,35 @@ public class ProcessorSchemaTest extends 
BaseSchemaTester<ProcessorSchema, Proce
     private final String testKey = "testKey";
     private final String testValue = "testValue";
     private final String testPenalizationPeriod = "55 s";
+    private final String testAnnotationData = "&lt;criteria&gt;\n" +
+            "    &lt;flowFilePolicy&gt;USE_ORIGINAL&lt;/flowFilePolicy&gt;\n" +
+            "    &lt;rules&gt;\n" +
+            "        &lt;actions&gt;\n" +
+            "            &lt;attribute&gt;it's the one&lt;/attribute&gt;\n" +
+            "            
&lt;id&gt;364cdf1a-3ac8-46a7-9d5d-e83618d9dfde&lt;/id&gt;\n" +
+            "            &lt;value&gt;true&lt;/value&gt;\n" +
+            "        &lt;/actions&gt;\n" +
+            "        &lt;conditions&gt;\n" +
+            "            
&lt;expression&gt;${uuid:equals(\"theUUID!\")}&lt;/expression&gt;\n" +
+            "            
&lt;id&gt;c0ceadcd-6de5-4994-bf76-f76a5fd1640c&lt;/id&gt;\n" +
+            "        &lt;/conditions&gt;\n" +
+            "        
&lt;id&gt;e6fb8d10-49ac-494b-8f02-ced1109c9445&lt;/id&gt;\n" +
+            "        &lt;name&gt;testRule&lt;/name&gt;\n" +
+            "    &lt;/rules&gt;\n" +
+            "    &lt;rules&gt;\n" +
+            "        &lt;actions&gt;\n" +
+            "            &lt;attribute&gt;the tenth&lt;/attribute&gt;\n" +
+            "            
&lt;id&gt;0bbe7bcd-e6b9-4801-b1e4-337da5f0532f&lt;/id&gt;\n" +
+            "            &lt;value&gt;${hostname()}&lt;/value&gt;\n" +
+            "        &lt;/actions&gt;\n" +
+            "        &lt;conditions&gt;\n" +
+            "            
&lt;expression&gt;${random:mod(10):equals(0)}&lt;/expression&gt;\n" +
+            "            
&lt;id&gt;48735bfe-02ef-4634-8d99-f384ebcd8fa8&lt;/id&gt;\n" +
+            "        &lt;/conditions&gt;\n" +
+            "        
&lt;id&gt;74b86ba2-4a8b-4952-8aef-ea672847c589&lt;/id&gt;\n" +
+            "        &lt;name&gt;testRule3&lt;/name&gt;\n" +
+            "    &lt;/rules&gt;\n" +
+            "&lt;/criteria&gt;";
     private ProcessorConfigDTO config;
 
     public ProcessorSchemaTest() {
@@ -70,6 +99,7 @@ public class ProcessorSchemaTest extends 
BaseSchemaTester<ProcessorSchema, Proce
         config.setPenaltyDuration(testPenalizationPeriod);
         config.setYieldDuration(testYieldDuration);
         config.setRunDurationMillis(testRunDurationNanos / 1000);
+        config.setAnnotationData(testAnnotationData);
         dto.setRelationships(Arrays.asList(relationshipDTO));
         Map<String, String> properties = new HashMap<>();
         properties.put(testKey, testValue);
@@ -87,6 +117,7 @@ public class ProcessorSchemaTest extends 
BaseSchemaTester<ProcessorSchema, Proce
         map.put(ProcessorSchema.RUN_DURATION_NANOS_KEY, testRunDurationNanos);
         map.put(ProcessorSchema.AUTO_TERMINATED_RELATIONSHIPS_LIST_KEY, 
Arrays.asList(testRelationship));
         map.put(ProcessorSchema.PROCESSOR_PROPS_KEY, new 
HashMap<>(properties));
+        map.put(ProcessorSchema.ANNOTATION_DATA_KEY, testAnnotationData);
     }
 
     @Test
@@ -174,6 +205,13 @@ public class ProcessorSchemaTest extends 
BaseSchemaTester<ProcessorSchema, Proce
         assertDtoAndMapConstructorAreSame(0);
     }
 
+    @Test
+    public void testNoAnnotationData() {
+        config.setAnnotationData(null);
+        map.remove(ProcessorSchema.ANNOTATION_DATA_KEY);
+        assertDtoAndMapConstructorAreSame(0);
+    }
+
     @Override
     public void assertSchemaEquals(ProcessorSchema one, ProcessorSchema two) {
         assertEquals(one.getName(), two.getName());
@@ -186,5 +224,6 @@ public class ProcessorSchemaTest extends 
BaseSchemaTester<ProcessorSchema, Proce
         assertEquals(one.getRunDurationNanos(), two.getRunDurationNanos());
         assertEquals(one.getAutoTerminatedRelationshipsList(), 
two.getAutoTerminatedRelationshipsList());
         assertEquals(one.getProperties(), two.getProperties());
+        assertEquals(one.getAnnotationData(), two.getAnnotationData());
     }
 }

Reply via email to