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

    https://github.com/apache/nifi/pull/642#discussion_r71242383
  
    --- 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 --
    
    Why clear all the properties at once and not just have an expiration time 
that applies to each table? Where if you have it set to 5 minutes, the 
processor will end up reporting the count of the table every minutes (while it 
still exists). You already store the timestamp under the FQN.


---
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