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

    https://github.com/apache/storm/pull/2218#discussion_r130228532
  
    --- Diff: 
storm-client/src/jvm/org/apache/storm/windowing/WindowManager.java ---
    @@ -111,14 +125,86 @@ public void add(Event<T> windowEvent) {
                 LOG.debug("Got watermark event with ts {}", 
windowEvent.getTimestamp());
             }
             track(windowEvent);
    -        compactWindow();
    +        if (!stateful) {
    +            compactWindow();
    +        }
         }
     
         /**
          * The callback invoked by the trigger policy.
          */
         @Override
         public boolean onTrigger() {
    +        return stateful ? doOnTriggerStateful() : doOnTrigger();
    +    }
    +
    +    private static class IteratorStatus {
    +        private boolean valid = true;
    +
    +        void invalidate() {
    +            valid = false;
    +        }
    +
    +        boolean isValid() {
    +            return valid;
    +        }
    +    }
    +
    +    private static<T> Iterator<T> expiringIterator(Iterator<T> inner, 
IteratorStatus status) {
    +        return new Iterator<T>() {
    +            @Override
    +            public boolean hasNext() {
    +                if (status.isValid()) {
    +                    return inner.hasNext();
    +                }
    +                throw new IllegalStateException("Stale iterator");
    +            }
    +
    +            @Override
    +            public T next() {
    +                if (status.isValid()) {
    +                    return inner.next();
    +                }
    +                throw new IllegalStateException("Stale iterator");
    +            }
    +        };
    +    }
    +
    +    private boolean doOnTriggerStateful() {
    +        Supplier<Iterator<T>> scanEventsStateful = 
this::scanEventsStateful;
    +        Iterator<T> it = scanEventsStateful.get();
    --- End diff --
    
    Why isn't it necessary to lock while accessing this iterator?


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to