jrsteinebrey commented on code in PR #8639:
URL: https://github.com/apache/nifi/pull/8639#discussion_r1574853643


##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ListDatabaseTables.java:
##########
@@ -270,24 +297,40 @@ public Set<Relationship> getRelationships() {
         return relationships;
     }
 
+    @OnScheduled
+    public void onScheduled(final ProcessContext context) {
+        if (!context.hasNonLoopConnection() && 
context.hasConnection(REL_FAILURE)) {
+            getLogger().error("The failure relationship can be used only if 
there is a non-loop incoming connection to this processor.");
+        }
+        if (!context.hasNonLoopConnection() && 
!context.getExecutionNode().equals(ExecutionNode.PRIMARY)) {
+            getLogger().error("If this processor has no incoming connection, 
then it should be run on Primary Node only.");
+        }
+    }
+
     @Override
     public void onTrigger(final ProcessContext context, final ProcessSession 
session) throws ProcessException {
+        FlowFile fileToProcess = null;
+        if (context.hasIncomingConnection()) {
+            fileToProcess = session.get();
+
+            if (context.hasNonLoopConnection() && fileToProcess == null) {
+                // Incoming non-loop connection has no FlowFile available, do 
no work (see capability description)
+                // hasNonLoopConnection() protects from blocked execution when 
failure loops back to self and there is no other incoming connection.
+                return;
+            }
+        }
+
         final ComponentLog logger = getLogger();
         final DBCPService dbcpService = 
context.getProperty(DBCP_SERVICE).asControllerService(DBCPService.class);
-        final String catalog = context.getProperty(CATALOG).getValue();
-        final String schemaPattern = 
context.getProperty(SCHEMA_PATTERN).getValue();
-        final String tableNamePattern = 
context.getProperty(TABLE_NAME_PATTERN).getValue();
-        final String[] tableTypes = context.getProperty(TABLE_TYPES).isSet()
-                ? 
context.getProperty(TABLE_TYPES).getValue().split("\\s*,\\s*")
-                : null;
-        final boolean includeCount = 
context.getProperty(INCLUDE_COUNT).asBoolean();
-        final long refreshInterval = 
context.getProperty(REFRESH_INTERVAL).asTimePeriod(TimeUnit.MILLISECONDS);
+        // Do not track refresh times if incoming flow file is non-null since 
FF causes relisting table names every time
+        final boolean isRefreshTracked = fileToProcess == null;
+        final long refreshInterval = !isRefreshTracked ? 0 : 
context.getProperty(REFRESH_INTERVAL).asTimePeriod(TimeUnit.MILLISECONDS);
 
         final StateMap stateMap;
         final Map<String, String> stateMapProperties;
         try {
-            stateMap = session.getState(Scope.CLUSTER);
-            stateMapProperties = new HashMap<>(stateMap.toMap());
+            stateMap = !isRefreshTracked ? null : 
session.getState(Scope.CLUSTER);
+            stateMapProperties = !isRefreshTracked ? null : new 
HashMap<>(stateMap.toMap());

Review Comment:
   I make the change



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to