You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nifi.apache.org by "Pasqualino S. Ferrentino" <se...@gmail.com> on 2016/02/11 15:40:10 UTC

patch for issue NIFI-1003

Hi all,

 my name is Lino Ferrentino and this is my first post.

I have worked on NiFi to solve the issue

https://issues.apache.org/jira/browse/NIFI-1003

and I enclose here a patch which I have tested
with the current 0.5 snapshot tree.

It adds a flag to the relationship. This flag tells the
processor to terminate it automatically, so in this
case we can add new relationships to a processor
and make the processor still runnable (otherwise the
framework will report a validation error).

I paste below the patch, hoping that it is in the correct format.

Lino




>From 51b9d70cbac7d79457cc62fbe8fb5c5df4cc2920 Mon Sep 17 00:00:00 2001
From: Pasqualino Ferrentino <se...@gmail.com>
Date: Thu, 11 Feb 2016 01:10:24 -0600
Subject: [PATCH] A relationship can be auto-terminable. In this case the processor will auto-terminate the relationship and allow the user to run it even he does not connect those relationship and he does not terminate them

---
 .../org/apache/nifi/processor/Relationship.java    |   18 ++++++++++++++++++
 .../nifi/controller/StandardProcessorNode.java     |    2 ++
 2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/nifi-api/src/main/java/org/apache/nifi/processor/Relationship.java b/nifi-api/src/main/java/org/apache/nifi/processor/Relationship.java
index d9f13be..3c32e09 100644
--- a/nifi-api/src/main/java/org/apache/nifi/processor/Relationship.java
+++ b/nifi-api/src/main/java/org/apache/nifi/processor/Relationship.java
@@ -41,9 +41,17 @@ public final class Relationship implements Comparable<Relationship> {
      */
     private final int hashCode;
 
+    /**
+     * The flag which tells the controller to auto terminate this
+     * relationship, so that the processor can be run even if it does
+     * not have connections from this relationship
+     */
+    private final boolean isAutoTerminate;
+
     protected Relationship(final Builder builder) {
         this.name = builder.name == null ? null : builder.name.intern();
         this.description = builder.description;
+        this.isAutoTerminate = builder.autoTerminate;
         this.hashCode = 301 + this.name.hashCode(); // compute only once, since it gets called a bunch and will never change
     }
 
@@ -71,6 +79,7 @@ public final class Relationship implements Comparable<Relationship> {
 
         private String name = "";
         private String description = "";
+        private boolean autoTerminate = false;
 
         public Builder name(final String name) {
             if (null != name) {
@@ -86,6 +95,11 @@ public final class Relationship implements Comparable<Relationship> {
             return this;
         }
 
+        public Builder autoTerminateDefault(boolean autoTerminate) {
+            this.autoTerminate = autoTerminate;
+            return this;
+        }
+
         public Relationship build() {
             return new Relationship(this);
         }
@@ -99,6 +113,10 @@ public final class Relationship implements Comparable<Relationship> {
         return this.description;
     }
 
+    public boolean isAutoTerminated() {
+        return this.isAutoTerminate;
+    }
+
     @Override
     public boolean equals(final Object other) {
         if (other == null) {
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java
index 2db506c..931d26a 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java
@@ -304,6 +304,8 @@ public class StandardProcessorNode extends ProcessorNode implements Connectable
 
     @Override
     public boolean isAutoTerminated(final Relationship relationship) {
+        if (relationship.isAutoTerminated() && getConnections(relationship).isEmpty())
+            return true;
         final Set<Relationship> terminatable = undefinedRelationshipsToTerminate.get();
         if (terminatable == null) {
             return false;
-- 
1.7.1





Re: patch for issue NIFI-1003

Posted by Joe Witt <jo...@gmail.com>.
Hello Lino

First welcome to the community and thank you for contributing.  It is
great that you selected something and dove in.  Please take a look
here https://cwiki.apache.org/confluence/display/NIFI/Contributor+Guide
to get a sense of how to best submit contributions that can then help
most effectively drive the review process.

Could attach a patch to the JIRA (the text you have in the email looks
like the right structure) or could submit a PR through Github.

Thanks
Joe

On Thu, Feb 11, 2016 at 9:40 AM, Pasqualino S. Ferrentino
<se...@gmail.com> wrote:
>
> Hi all,
>
>  my name is Lino Ferrentino and this is my first post.
>
> I have worked on NiFi to solve the issue
>
> https://issues.apache.org/jira/browse/NIFI-1003
>
> and I enclose here a patch which I have tested
> with the current 0.5 snapshot tree.
>
> It adds a flag to the relationship. This flag tells the
> processor to terminate it automatically, so in this
> case we can add new relationships to a processor
> and make the processor still runnable (otherwise the
> framework will report a validation error).
>
> I paste below the patch, hoping that it is in the correct format.
>
> Lino
>
>
>
>
> From 51b9d70cbac7d79457cc62fbe8fb5c5df4cc2920 Mon Sep 17 00:00:00 2001
> From: Pasqualino Ferrentino <se...@gmail.com>
> Date: Thu, 11 Feb 2016 01:10:24 -0600
> Subject: [PATCH] A relationship can be auto-terminable. In this case the processor will auto-terminate the relationship and allow the user to run it even he does not connect those relationship and he does not terminate them
>
> ---
>  .../org/apache/nifi/processor/Relationship.java    |   18 ++++++++++++++++++
>  .../nifi/controller/StandardProcessorNode.java     |    2 ++
>  2 files changed, 20 insertions(+), 0 deletions(-)
>
> diff --git a/nifi-api/src/main/java/org/apache/nifi/processor/Relationship.java b/nifi-api/src/main/java/org/apache/nifi/processor/Relationship.java
> index d9f13be..3c32e09 100644
> --- a/nifi-api/src/main/java/org/apache/nifi/processor/Relationship.java
> +++ b/nifi-api/src/main/java/org/apache/nifi/processor/Relationship.java
> @@ -41,9 +41,17 @@ public final class Relationship implements Comparable<Relationship> {
>       */
>      private final int hashCode;
>
> +    /**
> +     * The flag which tells the controller to auto terminate this
> +     * relationship, so that the processor can be run even if it does
> +     * not have connections from this relationship
> +     */
> +    private final boolean isAutoTerminate;
> +
>      protected Relationship(final Builder builder) {
>          this.name = builder.name == null ? null : builder.name.intern();
>          this.description = builder.description;
> +        this.isAutoTerminate = builder.autoTerminate;
>          this.hashCode = 301 + this.name.hashCode(); // compute only once, since it gets called a bunch and will never change
>      }
>
> @@ -71,6 +79,7 @@ public final class Relationship implements Comparable<Relationship> {
>
>          private String name = "";
>          private String description = "";
> +        private boolean autoTerminate = false;
>
>          public Builder name(final String name) {
>              if (null != name) {
> @@ -86,6 +95,11 @@ public final class Relationship implements Comparable<Relationship> {
>              return this;
>          }
>
> +        public Builder autoTerminateDefault(boolean autoTerminate) {
> +            this.autoTerminate = autoTerminate;
> +            return this;
> +        }
> +
>          public Relationship build() {
>              return new Relationship(this);
>          }
> @@ -99,6 +113,10 @@ public final class Relationship implements Comparable<Relationship> {
>          return this.description;
>      }
>
> +    public boolean isAutoTerminated() {
> +        return this.isAutoTerminate;
> +    }
> +
>      @Override
>      public boolean equals(final Object other) {
>          if (other == null) {
> diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java
> index 2db506c..931d26a 100644
> --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java
> +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java
> @@ -304,6 +304,8 @@ public class StandardProcessorNode extends ProcessorNode implements Connectable
>
>      @Override
>      public boolean isAutoTerminated(final Relationship relationship) {
> +        if (relationship.isAutoTerminated() && getConnections(relationship).isEmpty())
> +            return true;
>          final Set<Relationship> terminatable = undefinedRelationshipsToTerminate.get();
>          if (terminatable == null) {
>              return false;
> --
> 1.7.1
>
>
>
>