Source:
protected void process(ComplexEventChunk<StreamEvent> streamEventChunk, Processor nextProcessor, StreamEventCloner streamEventCloner) { String key; SessionComplexEventChunk<StreamEvent> currentSession; synchronized (this) { while (streamEventChunk.hasNext()) { StreamEvent streamEvent = streamEventChunk.next(); long eventTimestamp = streamEvent.getTimestamp(); long maxTimestamp = eventTimestamp + sessionGap; long aliveTimestamp = maxTimestamp + allowedLatency; if (streamEvent.getType() == StreamEvent.Type.CURRENT) { if (sessionKeyExecutor != null) { key = (String) sessionKeyExecutor.execute(streamEvent); } else { key = DEFAULT_KEY; } if (sessionMap.get(key) == null) { sessionContainer = new SessionContainer(key); sessionMap.put(key, sessionContainer); } else { sessionContainer = sessionMap.get(key); } StreamEvent clonedStreamEvent = streamEventCloner.copyStreamEvent(streamEvent); clonedStreamEvent.setType(StreamEvent.Type.EXPIRED); currentSession = sessionContainer.getCurrentSession(); if (sessionContainer.getCurrentSession().getFirst() == null) { currentSession.add(clonedStreamEvent); currentSession.setTimestamps(eventTimestamp, maxTimestamp, aliveTimestamp); scheduler.notifyAt(maxTimestamp); } else { if (eventTimestamp >= currentSession.getStartTimestamp()) { if (eventTimestamp <= currentSession.getEndTimestamp()) { currentSession.setTimestamps(currentSession.getStartTimestamp(), maxTimestamp, aliveTimestamp); currentSession.add(clonedStreamEvent); scheduler.notifyAt(maxTimestamp); } else { if (allowedLatency > 0) { moveCurrentSessionToPreviousSession(); currentSession.clear(); currentSession.setTimestamps(eventTimestamp, maxTimestamp, aliveTimestamp); currentSession.add(clonedStreamEvent); scheduler.notifyAt(maxTimestamp); } } } else { addLateEvent(streamEventChunk, eventTimestamp, clonedStreamEvent); } } } else { currentSessionTimeout(eventTimestamp); if (allowedLatency > 0) { previousSessionTimeout(eventTimestamp); } } } } nextProcessor.process(streamEventChunk); if (expiredEventChunk != null && expiredEventChunk.getFirst() != null) { nextProcessor.process(expiredEventChunk); expiredEventChunk.clear(); } }

Target:
protected void process(ComplexEventChunk<StreamEvent> streamEventChunk, Processor nextProcessor, StreamEventCloner streamEventCloner) { String key = DEFAULT_KEY; SessionComplexEventChunk<StreamEvent> currentSession; synchronized (this) { while (streamEventChunk.hasNext()) { StreamEvent streamEvent = streamEventChunk.next(); long eventTimestamp = streamEvent.getTimestamp(); long maxTimestamp = eventTimestamp + sessionGap; long aliveTimestamp = maxTimestamp + allowedLatency; if (streamEvent.getType() == StreamEvent.Type.CURRENT) { if (sessionKeyExecutor != null) { key = (String) sessionKeyExecutor.execute(streamEvent); } if ((sessionContainer = sessionMap.get(key)) == null) { sessionContainer = new SessionContainer(key); } sessionMap.put(key, sessionContainer); StreamEvent clonedStreamEvent = streamEventCloner.copyStreamEvent(streamEvent); clonedStreamEvent.setType(StreamEvent.Type.EXPIRED); currentSession = sessionContainer.getCurrentSession(); if (sessionContainer.getCurrentSession().getFirst() == null) { currentSession.add(clonedStreamEvent); currentSession.setTimestamps(eventTimestamp, maxTimestamp, aliveTimestamp); scheduler.notifyAt(maxTimestamp); } else { if (eventTimestamp >= currentSession.getStartTimestamp()) { if (eventTimestamp <= currentSession.getEndTimestamp()) { currentSession.setTimestamps(currentSession.getStartTimestamp(), maxTimestamp, aliveTimestamp); currentSession.add(clonedStreamEvent); scheduler.notifyAt(maxTimestamp); } else { if (allowedLatency > 0) { moveCurrentSessionToPreviousSession(); currentSession.clear(); currentSession.setTimestamps(eventTimestamp, maxTimestamp, aliveTimestamp); currentSession.add(clonedStreamEvent); scheduler.notifyAt(maxTimestamp); } } } else { addLateEvent(streamEventChunk, eventTimestamp, clonedStreamEvent); } } } else { currentSessionTimeout(eventTimestamp); if (allowedLatency > 0) { previousSessionTimeout(eventTimestamp); } } } } nextProcessor.process(streamEventChunk); if (expiredEventChunk != null && expiredEventChunk.getFirst() != null) { nextProcessor.process(expiredEventChunk); expiredEventChunk.clear(); } }