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 2016/09/30 14:00:30 UTC
nifi git commit: NIFI-2832 State management should be part of the
documentation/usage. This closes #1074
Repository: nifi
Updated Branches:
refs/heads/master 4e13fef72 -> d6867283b
NIFI-2832 State management should be part of the documentation/usage. This closes #1074
Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/d6867283
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/d6867283
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/d6867283
Branch: refs/heads/master
Commit: d6867283b55a8b40a4467197ed611c5c8669dff8
Parents: 4e13fef
Author: Pierre Villard <pi...@gmail.com>
Authored: Tue Sep 27 23:17:19 2016 +0200
Committer: Matt Gilman <ma...@gmail.com>
Committed: Fri Sep 30 09:59:35 2016 -0400
----------------------------------------------------------------------
.../html/HtmlDocumentationWriter.java | 42 ++++++++++++++++++--
.../example/FullyDocumentedProcessor.java | 3 ++
.../html/ProcessorDocumentationWriterTest.java | 6 +++
3 files changed, 47 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/nifi/blob/d6867283/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlDocumentationWriter.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlDocumentationWriter.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlDocumentationWriter.java
index ae21e70..236ff83 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlDocumentationWriter.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlDocumentationWriter.java
@@ -29,6 +29,7 @@ import javax.xml.stream.XMLStreamWriter;
import org.apache.nifi.annotation.behavior.DynamicProperties;
import org.apache.nifi.annotation.behavior.DynamicProperty;
+import org.apache.nifi.annotation.behavior.Stateful;
import org.apache.nifi.annotation.documentation.CapabilityDescription;
import org.apache.nifi.annotation.documentation.SeeAlso;
import org.apache.nifi.annotation.documentation.Tags;
@@ -127,11 +128,44 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
writeProperties(configurableComponent, xmlStreamWriter);
writeDynamicProperties(configurableComponent, xmlStreamWriter);
writeAdditionalBodyInfo(configurableComponent, xmlStreamWriter);
+ writeStatefulInfo(configurableComponent, xmlStreamWriter);
writeSeeAlso(configurableComponent, xmlStreamWriter);
xmlStreamWriter.writeEndElement();
}
/**
+ * Write the description of the Stateful annotation if provided in this component.
+ *
+ * @param configurableComponent the component to describe
+ * @param xmlStreamWriter the stream writer to use
+ * @throws XMLStreamException thrown if there was a problem writing the XML
+ */
+ private void writeStatefulInfo(ConfigurableComponent configurableComponent, XMLStreamWriter xmlStreamWriter)
+ throws XMLStreamException {
+ final Stateful stateful = configurableComponent.getClass().getAnnotation(Stateful.class);
+
+ writeSimpleElement(xmlStreamWriter, "h3", "State management: ");
+
+ if(stateful != null) {
+ xmlStreamWriter.writeStartElement("table");
+ xmlStreamWriter.writeAttribute("id", "stateful");
+ xmlStreamWriter.writeStartElement("tr");
+ writeSimpleElement(xmlStreamWriter, "th", "Scope");
+ writeSimpleElement(xmlStreamWriter, "th", "Description");
+ xmlStreamWriter.writeEndElement();
+
+ xmlStreamWriter.writeStartElement("tr");
+ writeSimpleElement(xmlStreamWriter, "td", join(stateful.scopes(), ", "));
+ writeSimpleElement(xmlStreamWriter, "td", stateful.description());
+ xmlStreamWriter.writeEndElement();
+
+ xmlStreamWriter.writeEndElement();
+ } else {
+ xmlStreamWriter.writeCharacters("This processor has no state management.");
+ }
+ }
+
+ /**
* Writes the list of components that may be linked from this component.
*
* @param configurableComponent the component to describe
@@ -202,11 +236,11 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
xmlStreamWriter.writeEndElement();
}
- static String join(final String[] toJoin, final String delimiter) {
+ static String join(final Object[] objects, final String delimiter) {
final StringBuilder sb = new StringBuilder();
- for (int i = 0; i < toJoin.length; i++) {
- sb.append(toJoin[i]);
- if (i < toJoin.length - 1) {
+ for (int i = 0; i < objects.length; i++) {
+ sb.append(objects[i].toString());
+ if (i < objects.length - 1) {
sb.append(delimiter);
}
}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d6867283/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedProcessor.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedProcessor.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedProcessor.java
index 1144e25..af668ba 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedProcessor.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedProcessor.java
@@ -25,6 +25,7 @@ import java.util.Set;
import org.apache.nifi.annotation.behavior.DynamicProperty;
import org.apache.nifi.annotation.behavior.DynamicRelationship;
import org.apache.nifi.annotation.behavior.ReadsAttribute;
+import org.apache.nifi.annotation.behavior.Stateful;
import org.apache.nifi.annotation.behavior.WritesAttribute;
import org.apache.nifi.annotation.behavior.WritesAttributes;
import org.apache.nifi.annotation.documentation.CapabilityDescription;
@@ -34,6 +35,7 @@ import org.apache.nifi.annotation.lifecycle.OnRemoved;
import org.apache.nifi.annotation.lifecycle.OnShutdown;
import org.apache.nifi.components.AllowableValue;
import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.components.state.Scope;
import org.apache.nifi.processor.AbstractProcessor;
import org.apache.nifi.processor.ProcessContext;
import org.apache.nifi.processor.ProcessSession;
@@ -51,6 +53,7 @@ import org.apache.nifi.processor.util.StandardValidators;
@SeeAlso(value = {FullyDocumentedControllerService.class, FullyDocumentedReportingTask.class}, classNames = {"org.apache.nifi.processor.ExampleProcessor"})
@DynamicProperty(name = "Relationship Name", supportsExpressionLanguage = true, value = "some XPath", description = "Routes FlowFiles to relationships based on XPath")
@DynamicRelationship(name = "name from dynamic property", description = "all files that match the properties XPath")
+@Stateful(scopes = {Scope.CLUSTER, Scope.LOCAL}, description = "state management description")
public class FullyDocumentedProcessor extends AbstractProcessor {
public static final PropertyDescriptor DIRECTORY = new PropertyDescriptor.Builder().name("Input Directory")
http://git-wip-us.apache.org/repos/asf/nifi/blob/d6867283/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/ProcessorDocumentationWriterTest.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/ProcessorDocumentationWriterTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/ProcessorDocumentationWriterTest.java
index a4a8dcd..7c6173a 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/ProcessorDocumentationWriterTest.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/ProcessorDocumentationWriterTest.java
@@ -66,6 +66,9 @@ public class ProcessorDocumentationWriterTest {
assertContains(results, "Controller Service API: ");
assertContains(results, "SampleService");
+ assertContains(results, "CLUSTER, LOCAL");
+ assertContains(results, "state management description");
+
assertNotContains(results, "iconSecure.png");
assertContains(results, FullyDocumentedProcessor.class.getAnnotation(CapabilityDescription.class)
.value());
@@ -110,6 +113,9 @@ public class ProcessorDocumentationWriterTest {
// relationships
assertContains(results, "This processor has no relationships.");
+ // state management
+ assertContains(results, "This processor has no state management.");
+
}
@Test