@SuppressWarnings("unchecked") <EventType> List<TimerPushEventContext<EventType>> pollEvents( final TimerPushNode<EventType> node) { final PushNodeState<EventType> state = (PushNodeState<EventType>)_nodeStates.get(node); if (state == null) { LOG.debug("Reconnecting push node {}...", node); _onConnect(node); return EMPTY_LIST; } synchronized (state) { state.lastPolledAt = Time.now(); if (state.queuedEvents.size() == 0) return EMPTY_LIST; final List<TimerPushEventContext<EventType>> events = state.queuedEvents; state.queuedEvents = new ArrayList<TimerPushEventContext<EventType>>(2); return events; } }
@SuppressWarnings("unchecked") <EventType> List<TimerPushEventContext<EventType>> pollEvents( final TimerPushNode<EventType> node) { final PushNodeState<EventType> state = (PushNodeState<EventType>)_nodeStates.get(node); if (state == null) { LOG.debug("Reconnecting push node {}...", node); _onConnect(node); return Collections.EMPTY_LIST; } state.lastPolledAt = Time.now(); if (state.queuedEvents.size() == 0) return Collections.EMPTY_LIST; synchronized (state.queuedEventsLock) { final List<TimerPushEventContext<EventType>> events = state.queuedEvents; state.queuedEvents = new ArrayList<TimerPushEventContext<EventType>>(2); return events; } }
public <EventType> TimerPushNode<EventType> installNode(final Component component, final IPushEventHandler<EventType> handler, final Duration pollingInterval) { TimerPushBehavior behavior = _findPushBehaviour(component); if (behavior == null) { behavior = new TimerPushBehavior(pollingInterval); component.add(behavior); } final TimerPushNode<EventType> node = behavior.addNode(handler, pollingInterval); _onConnect(node); return node; }
public <EventType> TimerPushNode<EventType> installNode(final Component component, final IPushEventHandler<EventType> handler, final Duration pollingInterval) { Args.notNull(component, "component"); Args.notNull(handler, "handler"); Args.notNull(pollingInterval, "pollingInterval"); TimerPushBehavior behavior = _findPushBehaviour(component); if (behavior != null && behavior.isStopped()) { component.remove(behavior); behavior = null; } if (behavior == null) { behavior = new TimerPushBehavior(pollingInterval); component.add(behavior); } final TimerPushNode<EventType> node = behavior.addNode(handler, pollingInterval); _onConnect(node); return node; }