@Override public int compare(final AbstractSession<?> o1, final AbstractSession<?> o2) { final long endTimestamp1 = o1.getEndTimestamp(); final long endTimestamp2 = o2.getEndTimestamp(); if (endTimestamp1 == endTimestamp2) { return 0; } else if (endTimestamp1 < endTimestamp2) { return -1; } else { return 1; } }
private <T extends AbstractSession<?>> void processTimeouts(final long currentTime, final String outputPortName, final PriorityQueue<T> timeoutQueue, final Map<String, T> openSessions) { while (!timeoutQueue.isEmpty()) { final T session = timeoutQueue.peek(); final long currentThinkTime = (currentTime - session.getEndTimestamp()); // The current session timed out if (currentThinkTime > this.maxThinkTime) { timeoutQueue.remove(); openSessions.remove(session.getSessionId()); this.dispatchCompletedSession(session, outputPortName); } else { // If the current session has not timed out, we are done due to the ordering of the queue break; } } }