Github user arunmahadevan commented on a diff in the pull request:
https://github.com/apache/storm/pull/2218#discussion_r130273957
--- 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 --
The locks are required in `onTrigger` due to `compactEvents`. Here its not
required since compact is not invoked. I am refactoring this into sub class.
---
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.
---