@Override public void setContext(EvictionContext context) { this.context = context; if (context.getCurrentCount() != null) { currentCount.set(context.getCurrentCount()); } else { currentCount.set(processed + context.getSlidingCount()); } processed = 0; }
@Override public void setContext(EvictionContext context) { EvictionContext prevContext = evictionContext; evictionContext = context; // compute window length adjustment (delta) to account for time drift if (context.getSlidingInterval() != null) { if (prevContext == null) { delta = Integer.MAX_VALUE; // consider all events for the initial window } else { delta = context.getReferenceTime() - prevContext.getReferenceTime() - context.getSlidingInterval(); if (Math.abs(delta) > 100) { LOG.warn("Possible clock drift or long running computation in window; " + "Previous eviction time: {}, current eviction time: {}", prevContext.getReferenceTime(), context.getReferenceTime()); } } } }
@Override public void setContext(EvictionContext context) { this.context = context; referenceTime = context.getReferenceTime(); if (context.getCurrentCount() != null) { currentCount.set(context.getCurrentCount()); } else { currentCount.set(processed + context.getSlidingCount()); } processed = 0; }
/** * {@inheritDoc} */ @Override public Action evict(Event<T> event) { long now = evictionContext == null ? System.currentTimeMillis() : evictionContext.getReferenceTime(); long diff = now - event.getTimestamp(); if (diff >= (windowLength + delta)) { return Action.EXPIRE; } else if (diff < 0) { // do not process events beyond current ts return Action.KEEP; } return Action.PROCESS; }
/** * {@inheritDoc} * <p/> * Keeps events with future ts in the queue for processing in the next window. If the ts difference is more than the lag, stops scanning * the queue for the current window. */ @Override public Action evict(Event<T> event) { if (evictionContext == null) { //It is possible to get asked about eviction before we have a context, due to WindowManager.compactWindow. //In this case we should hold on to all the events. When the first watermark is received, the context will be set, //and the events will be reevaluated for eviction return Action.STOP; } long referenceTime = evictionContext.getReferenceTime(); long diff = referenceTime - event.getTimestamp(); if (diff < -lag) { return Action.STOP; } else if (diff < 0) { return Action.KEEP; } else { return super.evict(event); } }
@Override public void setContext(EvictionContext context) { referenceTime = context.getReferenceTime(); EvictionContext prevContext = evictionContext; evictionContext = context; // compute window length adjustment (delta) to account for time drift if (context.getSlidingInterval() != null) { if (prevContext == null) { delta = Integer.MAX_VALUE; // consider all events for the initial window } else { delta = context.getReferenceTime() - prevContext.getReferenceTime() - context.getSlidingInterval(); if (Math.abs(delta) > 100) { LOG.warn("Possible clock drift or long running computation in window; " + "Previous eviction time: {}, current eviction time: {}", prevContext.getReferenceTime(), context.getReferenceTime()); } } } }
prevWindowEvents.addAll(windowEvents); LOG.debug("invoking windowLifecycleListener onActivation, [{}] events in window.", events.size()); windowLifecycleListener.onActivation(events, newEvents, expired, evictionPolicy.getContext().getReferenceTime()); } else { LOG.debug("No events in the window, skipping onActivation");
public Action evict(Event<T> event) { if (getContext() == null) { //It is possible to get asked about eviction before we have a context, due to WindowManager.compactWindow. //In this case we should hold on to all the events. When the first watermark is received, the context will be set, //and the events will be reevaluated for eviction return Action.STOP; } Action action; if (event.getTimestamp() <= getContext().getReferenceTime() && processed < currentCount.get()) { action = doEvict(event); if (action == Action.PROCESS) { ++processed; } } else { action = Action.KEEP; } return action; }
windowLifecycleListener.onActivation(wrapper, null, null, evictionPolicy.getContext().getReferenceTime());
/** * {@inheritDoc} * <p/> * Keeps events with future ts in the queue for processing in the next * window. If the ts difference is more than the lag, stops scanning * the queue for the current window. */ @Override public Action evict(Event<T> event) { if(evictionContext == null) { //It is possible to get asked about eviction before we have a context, due to WindowManager.compactWindow. //In this case we should hold on to all the events. When the first watermark is received, the context will be set, //and the events will be reevaluated for eviction return Action.STOP; } long referenceTime = evictionContext.getReferenceTime(); long diff = referenceTime - event.getTimestamp(); if (diff < -lag) { return Action.STOP; } else if (diff < 0) { return Action.KEEP; } else { return super.evict(event); } }