DelayAction extends AbstractHealthCheckAction<DelayActionContext> { @Override protected void doTask() { reportDelay(); RedisSession session = instance.getRedisSession(); doSubscribe(session, CHECK_CHANNEL, callback); RedisInstanceInfo info = instance.getRedisInstanceInfo(); if (currentDcId.equalsIgnoreCase(info.getDcId()) && info.isMaster()) { doPublish(session, CHECK_CHANNEL, Long.toHexString(System.nanoTime())); } } DelayAction(ScheduledExecutorService scheduled, RedisHealthCheckInstance instance,
                       ExecutorService executors, PingService pingService); @Override void doStop(); static final String CHECK_CHANNEL; static final long SAMPLE_LOST_AND_NO_PONG; static final long SAMPLE_LOST_BUT_PONG; }
@Test public void testConnectTimeoutSinceBeginning() { AtomicBoolean result = new AtomicBoolean(false); action.addListener(new DelayActionListener() { @Override public void onAction(DelayActionContext actionContext) { if (null == actionContext.instance()) { instanceNull.set(true); Assert.fail(); } result.set(true); } @Override public boolean worksfor(ActionContext t) { return true; } @Override public void stopWatch(HealthCheckAction action) { } }); action.doTask(); action.doTask(); action.doTask(); sleep(2 * CHECK_INTERVAL); action.doTask(); Assert.assertTrue(result.get()); }