@Test public void testSetTimer() throws Exception { ListenableScheduledFuture future = mock(ListenableScheduledFuture.class); when(future.isDone()).thenReturn(false); when(worker.scheduleTask(any(Callable.class), anyInt(), any(TimeUnit.class))).thenReturn(future); sxpConnection.setTimer(TimerType.DeleteHoldDownTimer, 0); assertNull(sxpConnection.getTimer(TimerType.DeleteHoldDownTimer)); sxpConnection.setTimer(TimerType.KeepAliveTimer, 50); assertNotNull(sxpConnection.getTimer(TimerType.KeepAliveTimer)); sxpConnection.setTimer(TimerType.ReconciliationTimer, 50); assertNotNull(sxpConnection.getTimer(TimerType.ReconciliationTimer)); exception.expect(UnknownTimerTypeException.class); sxpConnection.setTimer(TimerType.RetryOpenTimer, 50); }
public synchronized ListenableScheduledFuture<?> setTimer(TimerType timerType, int period) { SxpTimerTask timer; switch (timerType) { case DeleteHoldDownTimer: timer = new DeleteHoldDownTimerTask(this, period); break; case HoldTimer: timer = new HoldTimerTask(this, period); break; case KeepAliveTimer: timer = new KeepAliveTimerTask(this, period); break; case ReconciliationTimer: timer = new ReconcilationTimerTask(this, period); break; default: throw new UnknownTimerTypeException(timerType); } ListenableScheduledFuture<?> oldTimer = getTimer(timerType); if (period > 0 && (oldTimer == null || !oldTimer.isCancelled())) { return this.setTimer(timerType, owner.getWorker().scheduleTask(timer, period, TimeUnit.SECONDS)); } else { return this.setTimer(timerType, null); } }
SxpConnection { public synchronized ListenableScheduledFuture<?> setTimer(TimerType timerType, int period) { SxpTimerTask timer; switch (timerType) { case DeleteHoldDownTimer: timer = new DeleteHoldDownTimerTask(this, period); break; case HoldTimer: timer = new HoldTimerTask(this, period); break; case KeepAliveTimer: timer = new KeepAliveTimerTask(this, period); break; case ReconciliationTimer: timer = new ReconcilationTimerTask(this, period); break; default: throw new UnknownTimerTypeException(timerType); } ListenableScheduledFuture<?> oldTimer = getTimer(timerType); if (period > 0 && (oldTimer == null || !oldTimer.isCancelled())) { return this.setTimer(timerType, owner.getWorker().scheduleTask(timer, period, TimeUnit.SECONDS)); } else { return this.setTimer(timerType, null); } } }
SxpConnection { public synchronized ListenableScheduledFuture<?> setTimer(TimerType timerType, int period) { SxpTimerTask timer; switch (timerType) { case DeleteHoldDownTimer: timer = new DeleteHoldDownTimerTask(this, period); break; case HoldTimer: timer = new HoldTimerTask(this, period); break; case KeepAliveTimer: timer = new KeepAliveTimerTask(this, period); break; case ReconciliationTimer: timer = new ReconcilationTimerTask(this, period); break; default: throw new UnknownTimerTypeException(timerType); } ListenableScheduledFuture<?> oldTimer = getTimer(timerType); if (period > 0 && (oldTimer == null || !oldTimer.isCancelled())) { return this.setTimer(timerType, owner.getWorker().scheduleTask(timer, period, TimeUnit.SECONDS)); } else { return this.setTimer(timerType, null); } } protected  SxpConnection(SxpNode owner, Connection connection, String domain); }
SxpConnection { public synchronized ListenableScheduledFuture<?> setTimer(TimerType timerType, int period) { SxpTimerTask timer; switch (timerType) { case DeleteHoldDownTimer: timer = new DeleteHoldDownTimerTask(this, period); break; case HoldTimer: timer = new HoldTimerTask(this, period); break; case KeepAliveTimer: timer = new KeepAliveTimerTask(this, period); break; case ReconciliationTimer: timer = new ReconcilationTimerTask(this, period); break; default: throw new UnknownTimerTypeException(timerType); } ListenableScheduledFuture<?> oldTimer = getTimer(timerType); if (period > 0 && (oldTimer == null || !oldTimer.isCancelled())) { return this.setTimer(timerType, owner.getWorker().scheduleTask(timer, period, TimeUnit.SECONDS)); } else { return this.setTimer(timerType, null); } } protected  SxpConnection(SxpNode owner, Connection connection, String domain); static SxpConnection create(SxpNode owner, Connection connection, String domain); synchronized Future<Void> openConnection(); SxpBindingFilter<?, ? extends SxpFilterFields> getFilter(FilterType filterType); void putFilter(SxpBindingFilter<?, ? extends SxpFilterFields> filter); String getGroupName(FilterType filterType); List<SxpBindingFilter<?, ? extends SxpFilterFields>> removeFilter(FilterType filterType,
            FilterSpecific specific); void setUpdateOrKeepaliveMessageTimestamp(); void setNodeIdRemote(NodeId nodeId); void processUpdateMessage(UpdateMessage message); void processUpdateMessage(UpdateMessageLegacy message); void propagateUpdate(List<T> deleteBindings, List<T> addBindings,
            List<SxpConnection> connections); void addChannelHandlerContext(ChannelHandlerContext ctx); void cleanUpBindings(); synchronized ChannelHandlerContextType closeChannelHandlerContext(ChannelHandlerContext ctx); void closeChannelHandlerContextComplements(ChannelHandlerContext ctx); void closeChannelHandlerContexts(); List<CapabilityType> getCapabilities(); List<CapabilityType> getCapabilitiesRemote(); void setCapabilitiesRemote(List<CapabilityType> capabilityTypeList); ChannelHandlerContext getChannelHandlerContext(ChannelHandlerContextType channelHandlerContextType); boolean hasChannelHandlerContext(ChannelHandlerContextType channelHandlerContextType); Context getContext(); InetSocketAddress getDestination(); InetSocketAddress getLocalAddress(); int getHoldTime(); int getHoldTimeMax(); int getHoldTimeMin(); int getHoldTimeMinAcceptable(); int getKeepaliveTime(); ConnectionMode getMode(); ConnectionMode getModeRemote(); static ConnectionMode invertMode(ConnectionMode mode); NodeId getNodeIdRemote(); NodeId getId(); SxpNode getOwner(); NodeId getOwnerId(); String getPassword(); SecurityType getSecurityType(); int getReconciliationTime(); ConnectionState getState(); String getDomainName(); ListenableScheduledFuture<?> getTimer(TimerType timerType); long getTimestampUpdateOrKeepAliveMessage(); Version getVersion(); boolean isBidirectionalBoth(); boolean isModeBoth(); boolean isModeListener(); boolean isModeSpeaker(); boolean isStateDeleteHoldDown(); boolean isStateOff(); boolean isStateOn(); boolean isStateOn(ChannelHandlerContextType type); boolean isStatePendingOn(); boolean isVersion4(); synchronized void markChannelHandlerContext(ChannelHandlerContext ctx,
            ChannelHandlerContextType channelHandlerContextType); void markChannelHandlerContext(ChannelHandlerContext ctx); void purgeBindings(); void setBehaviorContexts(Version version); void setConnection(OpenMessage message); void setConnectionListenerPart(OpenMessage message); void setConnectionSpeakerPart(OpenMessage message); void setDeleteHoldDownTimer(); void setHoldTime(int value); void setHoldTimeMin(int value); void setHoldTimeMinAcceptable(int value); void setInetSocketAddresses(SocketAddress localAddress); void setKeepaliveTime(int value); void setReconciliationTimer(); void setStateDeleteHoldDown(); synchronized void setStateOff(); ChannelHandlerContextType getContextType(ChannelHandlerContext ctx); synchronized void setStateOff(ChannelHandlerContext ctx); void stopRetryOpenTimer(); void setStateOn(); void setStatePendingOn(); synchronized ListenableScheduledFuture<?> setTimer(TimerType timerType, int period); void scheduleRetryOpen(); synchronized void shutdown(); boolean hasNonEmptyPassword(); List<ChannelHandlerContext> getInitCtxs(); void closeInitContextWithRemote(InetSocketAddress remoteAddress); @Override String toString(); }
SxpConnection { public synchronized ListenableScheduledFuture<?> setTimer(TimerType timerType, int period) { SxpTimerTask timer; switch (timerType) { case DeleteHoldDownTimer: timer = new DeleteHoldDownTimerTask(this, period); break; case HoldTimer: timer = new HoldTimerTask(this, period); break; case KeepAliveTimer: timer = new KeepAliveTimerTask(this, period); break; case ReconciliationTimer: timer = new ReconcilationTimerTask(this, period); break; default: throw new UnknownTimerTypeException(timerType); } ListenableScheduledFuture<?> oldTimer = getTimer(timerType); if (period > 0 && (oldTimer == null || !oldTimer.isCancelled())) { return this.setTimer(timerType, owner.getWorker().scheduleTask(timer, period, TimeUnit.SECONDS)); } else { return this.setTimer(timerType, null); } } protected  SxpConnection(SxpNode owner, Connection connection, String domain); static SxpConnection create(SxpNode owner, Connection connection, String domain); synchronized Future<Void> openConnection(); SxpBindingFilter<?, ? extends SxpFilterFields> getFilter(FilterType filterType); void putFilter(SxpBindingFilter<?, ? extends SxpFilterFields> filter); String getGroupName(FilterType filterType); List<SxpBindingFilter<?, ? extends SxpFilterFields>> removeFilter(FilterType filterType,
            FilterSpecific specific); void setUpdateOrKeepaliveMessageTimestamp(); void setNodeIdRemote(NodeId nodeId); void processUpdateMessage(UpdateMessage message); void processUpdateMessage(UpdateMessageLegacy message); void propagateUpdate(List<T> deleteBindings, List<T> addBindings,
            List<SxpConnection> connections); void addChannelHandlerContext(ChannelHandlerContext ctx); void cleanUpBindings(); synchronized ChannelHandlerContextType closeChannelHandlerContext(ChannelHandlerContext ctx); void closeChannelHandlerContextComplements(ChannelHandlerContext ctx); void closeChannelHandlerContexts(); List<CapabilityType> getCapabilities(); List<CapabilityType> getCapabilitiesRemote(); void setCapabilitiesRemote(List<CapabilityType> capabilityTypeList); ChannelHandlerContext getChannelHandlerContext(ChannelHandlerContextType channelHandlerContextType); boolean hasChannelHandlerContext(ChannelHandlerContextType channelHandlerContextType); Context getContext(); InetSocketAddress getDestination(); InetSocketAddress getLocalAddress(); int getHoldTime(); int getHoldTimeMax(); int getHoldTimeMin(); int getHoldTimeMinAcceptable(); int getKeepaliveTime(); ConnectionMode getMode(); ConnectionMode getModeRemote(); static ConnectionMode invertMode(ConnectionMode mode); NodeId getNodeIdRemote(); NodeId getId(); SxpNode getOwner(); NodeId getOwnerId(); String getPassword(); SecurityType getSecurityType(); int getReconciliationTime(); ConnectionState getState(); String getDomainName(); ListenableScheduledFuture<?> getTimer(TimerType timerType); long getTimestampUpdateOrKeepAliveMessage(); Version getVersion(); boolean isBidirectionalBoth(); boolean isModeBoth(); boolean isModeListener(); boolean isModeSpeaker(); boolean isStateDeleteHoldDown(); boolean isStateOff(); boolean isStateOn(); boolean isStateOn(ChannelHandlerContextType type); boolean isStatePendingOn(); boolean isVersion4(); synchronized void markChannelHandlerContext(ChannelHandlerContext ctx,
            ChannelHandlerContextType channelHandlerContextType); void markChannelHandlerContext(ChannelHandlerContext ctx); void purgeBindings(); void setBehaviorContexts(Version version); void setConnection(OpenMessage message); void setConnectionListenerPart(OpenMessage message); void setConnectionSpeakerPart(OpenMessage message); void setDeleteHoldDownTimer(); void setHoldTime(int value); void setHoldTimeMin(int value); void setHoldTimeMinAcceptable(int value); void setInetSocketAddresses(SocketAddress localAddress); void setKeepaliveTime(int value); void setReconciliationTimer(); void setStateDeleteHoldDown(); synchronized void setStateOff(); ChannelHandlerContextType getContextType(ChannelHandlerContext ctx); synchronized void setStateOff(ChannelHandlerContext ctx); void stopRetryOpenTimer(); void setStateOn(); void setStatePendingOn(); synchronized ListenableScheduledFuture<?> setTimer(TimerType timerType, int period); void scheduleRetryOpen(); synchronized void shutdown(); boolean hasNonEmptyPassword(); List<ChannelHandlerContext> getInitCtxs(); void closeInitContextWithRemote(InetSocketAddress remoteAddress); @Override String toString();  }