Github user mattyb149 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/642#discussion_r71249117
  
    --- Diff: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ListDatabaseTables.java
 ---
    @@ -211,17 +213,37 @@ public void onTrigger(ProcessContext context, 
ProcessSession session) throws Pro
                     ? 
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);
     
             final StateManager stateManager = context.getStateManager();
             final StateMap stateMap;
             final Map<String, String> stateMapProperties;
             try {
    -            stateMap = stateManager.getState(Scope.LOCAL);
    +            stateMap = stateManager.getState(Scope.CLUSTER);
                 stateMapProperties = new HashMap<>(stateMap.toMap());
             } catch (IOException ioe) {
                 throw new ProcessException(ioe);
             }
     
    +        try {
    +            // Refresh state if the interval has elapsed
    +            long lastRefreshed = -1;
    +            final long currentTime = System.currentTimeMillis();
    +            String lastTimestamp = 
stateMapProperties.get(this.getIdentifier());
    +            if (!StringUtils.isEmpty(lastTimestamp)) {
    +                lastRefreshed = Long.parseLong(lastTimestamp);
    +            }
    +            if (lastRefreshed > 0 && refreshInterval > 0 && currentTime >= 
(lastRefreshed + refreshInterval)) {
    +                stateManager.clear(Scope.CLUSTER);
    +                stateMapProperties.clear();
    --- End diff --
    
    Good point, will add.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to