[GitHub] nifi pull request #2634: NIFI-5075: Do not execute Funnels with no outgoing ...

2018-04-23 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/nifi/pull/2634


---


[GitHub] nifi pull request #2634: NIFI-5075: Do not execute Funnels with no outgoing ...

2018-04-16 Thread ijokarumawak
Github user ijokarumawak commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2634#discussion_r181951840
  
--- Diff: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/tasks/ConnectableTask.java
 ---
@@ -103,8 +104,24 @@ private boolean isYielded() {
 return connectable.getYieldExpiration() > 
System.currentTimeMillis();
 }
 
+/**
+ * Make sure processor has work to do. This means that it meets one of 
these criteria:
+ * 
+ * It is annotated with @TriggerWhenEmpty
+ * It has no incoming connections
+ * All incoming connections are self-loops
+ * It has data in an incoming Connection
+ * AND It is not a Funnel without outgoing connections
+ * 
+ * 
+ * @return true if there is work to do, otherwise false
+ */
 private boolean isWorkToDo() {
-return connectable.isTriggerWhenEmpty() || 
!connectable.hasIncomingConnection() || !hasNonLoopConnection || 
Connectables.flowFilesQueued(connectable);
+return connectable.isTriggerWhenEmpty()
+|| !connectable.hasIncomingConnection()
+|| !hasNonLoopConnection
+|| (Connectables.flowFilesQueued(connectable)
--- End diff --

@markap14 Thank you for testing.

I understand what went wrong. I tested with an existing flow including 
Funnel which had an incoming connection from GenerateFlowFile already. Since 
Funnels are not stopped/scheduled, the `hasNonLoopConnection` field only gets 
populated when the Funnel is added. 
`hasNonLoopConnection` becomes `false` for a newly created Funnels, and 
stays false even incoming connections are added later. ConnectableTasks for 
other components than Funnel can be recreated when the component is 
re-scheduled, however, those components should also NOT cache 
`hasNonLoopConnection` because NiFi allows new connections to be added while a 
component is running, without requiring stop/start.

I will update the PR.


---


[GitHub] nifi pull request #2634: NIFI-5075: Do not execute Funnels with no outgoing ...

2018-04-16 Thread markap14
Github user markap14 commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2634#discussion_r181792251
  
--- Diff: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/tasks/ConnectableTask.java
 ---
@@ -103,8 +104,24 @@ private boolean isYielded() {
 return connectable.getYieldExpiration() > 
System.currentTimeMillis();
 }
 
+/**
+ * Make sure processor has work to do. This means that it meets one of 
these criteria:
+ * 
+ * It is annotated with @TriggerWhenEmpty
+ * It has no incoming connections
+ * All incoming connections are self-loops
+ * It has data in an incoming Connection
+ * AND It is not a Funnel without outgoing connections
+ * 
+ * 
+ * @return true if there is work to do, otherwise false
+ */
 private boolean isWorkToDo() {
-return connectable.isTriggerWhenEmpty() || 
!connectable.hasIncomingConnection() || !hasNonLoopConnection || 
Connectables.flowFilesQueued(connectable);
+return connectable.isTriggerWhenEmpty()
+|| !connectable.hasIncomingConnection()
+|| !hasNonLoopConnection
+|| (Connectables.flowFilesQueued(connectable)
--- End diff --

@ijokarumawak unfortunately, this doesn't appear to fully address the 
issue. It appears that the clause above this one, "!hasNonLoopConnection" is 
evaluating to true in my case (simple GenerateFlowFile -> Funnel).

I think I would actually recommend just adding a block of code to the 
beginning of this method like:
```
if (connectable.getConnectableType() == ConnectableType.FUNNEL) {
  return !connectable.getConnections().isEmpty() && 
connectable.hasIncomingConnection() && hasNonLoopConnection;
} else {
  // do what we already do
}
```

I recommend this because Funnels are a special case, since they are really 
intended to be 'notional' and never stopped or started. They are always 
running. And for Funnels, in particular, it only really makes sense to run if 
there is in fact an incoming connection (rather than processors where we want 
to run even if there isn't an incoming connection), AND If there is at least 
one outgoing connection (funnels don't support auto-terminating relationships).


---


[GitHub] nifi pull request #2634: NIFI-5075: Do not execute Funnels with no outgoing ...

2018-04-16 Thread markap14
Github user markap14 commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2634#discussion_r181775911
  
--- Diff: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/tasks/ConnectableTask.java
 ---
@@ -103,8 +104,24 @@ private boolean isYielded() {
 return connectable.getYieldExpiration() > 
System.currentTimeMillis();
 }
 
+/**
+ * Make sure processor has work to do. This means that it meets one of 
these criteria:
+ * 
+ * It is annotated with @TriggerWhenEmpty
+ * It has no incoming connections
+ * All incoming connections are self-loops
+ * It has data in an incoming Connection
+ * AND It is not a Funnel without outgoing connections
+ * 
+ * 
+ * @return true if there is work to do, otherwise false
+ */
 private boolean isWorkToDo() {
-return connectable.isTriggerWhenEmpty() || 
!connectable.hasIncomingConnection() || !hasNonLoopConnection || 
Connectables.flowFilesQueued(connectable);
+return connectable.isTriggerWhenEmpty()
+|| !connectable.hasIncomingConnection()
--- End diff --

If connectable.hasIncomingConnection() is false, then that indicates that 
the component is a 'source' component, and doesn't depend on incoming data to 
be triggered, so it is said to have work to do. Similarly, if all incoming 
connections are self-looping connections, then it is a source component and is 
said to have work to do.


---


[GitHub] nifi pull request #2634: NIFI-5075: Do not execute Funnels with no outgoing ...

2018-04-16 Thread markobean
Github user markobean commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2634#discussion_r181735366
  
--- Diff: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/tasks/ConnectableTask.java
 ---
@@ -103,8 +104,24 @@ private boolean isYielded() {
 return connectable.getYieldExpiration() > 
System.currentTimeMillis();
 }
 
+/**
+ * Make sure processor has work to do. This means that it meets one of 
these criteria:
+ * 
+ * It is annotated with @TriggerWhenEmpty
+ * It has no incoming connections
+ * All incoming connections are self-loops
+ * It has data in an incoming Connection
+ * AND It is not a Funnel without outgoing connections
+ * 
+ * 
+ * @return true if there is work to do, otherwise false
+ */
 private boolean isWorkToDo() {
-return connectable.isTriggerWhenEmpty() || 
!connectable.hasIncomingConnection() || !hasNonLoopConnection || 
Connectables.flowFilesQueued(connectable);
+return connectable.isTriggerWhenEmpty()
+|| !connectable.hasIncomingConnection()
--- End diff --

This logic seems inverted unnecessarily. Why is 
'connectable.hasIncomingConnection()' negated? This leads to the method 
returning true when there are no incoming connections. Similarly, is it the 
intent to indicate no work to do if the only incoming connections are looped 
connections?


---


[GitHub] nifi pull request #2634: NIFI-5075: Do not execute Funnels with no outgoing ...

2018-04-12 Thread ijokarumawak
GitHub user ijokarumawak opened a pull request:

https://github.com/apache/nifi/pull/2634

NIFI-5075: Do not execute Funnels with no outgoing connections

Thank you for submitting a contribution to Apache NiFi.

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

### For all changes:
- [x] Is there a JIRA ticket associated with this PR? Is it referenced 
 in the commit message?

- [x] Does your PR title start with NIFI- where  is the JIRA number 
you are trying to resolve? Pay particular attention to the hyphen "-" character.

- [x] Has your PR been rebased against the latest commit within the target 
branch (typically master)?

- [x] Is your initial contribution a single, squashed commit?

### For code changes:
- [ ] Have you ensured that the full suite of tests is executed via mvn 
-Pcontrib-check clean install at the root nifi folder?
- [ ] Have you written or updated unit tests to verify your changes?
- [ ] If adding new dependencies to the code, are these dependencies 
licensed in a way that is compatible for inclusion under [ASF 
2.0](http://www.apache.org/legal/resolved.html#category-a)? 
- [ ] If applicable, have you updated the LICENSE file, including the main 
LICENSE file under nifi-assembly?
- [ ] If applicable, have you updated the NOTICE file, including the main 
NOTICE file found under nifi-assembly?
- [ ] If adding new Properties, have you added .displayName in addition to 
.name (programmatic access) for each of the new properties?

### For documentation related changes:
- [ ] Have you ensured that format looks appropriate for the output in 
which it is rendered?

### Note:
Please ensure that once the PR is submitted, you check travis-ci for build 
issues and submit an update to your PR as soon as possible.


You can merge this pull request into a Git repository by running:

$ git pull https://github.com/ijokarumawak/nifi nifi-5075

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/nifi/pull/2634.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #2634


commit c60e294432e154eb6b5b3339c40138b13c246ae5
Author: Koji Kawamura 
Date:   2018-04-13T02:18:24Z

NIFI-5075: Do not execute Funnels with no outgoing connections




---