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:
    +     * <ol>
    +     * <li>It is annotated with @TriggerWhenEmpty</li>
    +     * <li>It has no incoming connections</li>
    +     * <li>All incoming connections are self-loops</li>
    +     * <li>It has data in an incoming Connection
    +     *     AND It is not a Funnel without outgoing connections
    +     * </li>
    +     * </ol>
    +     * @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).


---

Reply via email to