@Test public void testNoResponseWithinTimeout() throws Exception { NodeConfig config = new NodeConfig(); config.setNewNodeReadTimeout(1); NewNodeCatchUpTask task = new NewNodeCatchUpTask( new WaitableNewNodeCatchUpTaskContext(), new NodeEndpoint("D", "localhost", 2336), config ); NewNodeCatchUpTaskResult result = task.call(); Assert.assertEquals(NewNodeCatchUpTaskResult.State.TIMEOUT, result.getState()); }
@Override public synchronized NewNodeCatchUpTaskResult call() throws Exception { logger.debug("task start"); setState(State.START); context.replicateLog(endpoint); lastReplicateAt = System.currentTimeMillis(); lastAdvanceAt = lastReplicateAt; setState(State.REPLICATING); while (!done) { wait(config.getNewNodeReadTimeout()); if (System.currentTimeMillis() - lastReplicateAt >= config.getNewNodeReadTimeout()) { logger.debug("node {} not response within read timeout", endpoint.getId()); state = State.TIMEOUT; break; } } logger.debug("task done"); context.done(this); return mapResult(state); }
NewNodeCatchUpTask implements Callable<NewNodeCatchUpTaskResult> { @Override public synchronized NewNodeCatchUpTaskResult call() throws Exception { logger.debug("task start"); setState(State.START); context.replicateLog(endpoint); lastReplicateAt = System.currentTimeMillis(); lastAdvanceAt = lastReplicateAt; setState(State.REPLICATING); while (!done) { wait(config.getNewNodeReadTimeout()); if (System.currentTimeMillis() - lastReplicateAt >= config.getNewNodeReadTimeout()) { logger.debug("node {} not response within read timeout", endpoint.getId()); state = State.TIMEOUT; break; } } logger.debug("task done"); context.done(this); return mapResult(state); } }
NewNodeCatchUpTask implements Callable<NewNodeCatchUpTaskResult> { @Override public synchronized NewNodeCatchUpTaskResult call() throws Exception { logger.debug("task start"); setState(State.START); context.replicateLog(endpoint); lastReplicateAt = System.currentTimeMillis(); lastAdvanceAt = lastReplicateAt; setState(State.REPLICATING); while (!done) { wait(config.getNewNodeReadTimeout()); if (System.currentTimeMillis() - lastReplicateAt >= config.getNewNodeReadTimeout()) { logger.debug("node {} not response within read timeout", endpoint.getId()); state = State.TIMEOUT; break; } } logger.debug("task done"); context.done(this); return mapResult(state); } NewNodeCatchUpTask(NewNodeCatchUpTaskContext context, NodeEndpoint endpoint, NodeConfig config); }
NewNodeCatchUpTask implements Callable<NewNodeCatchUpTaskResult> { @Override public synchronized NewNodeCatchUpTaskResult call() throws Exception { logger.debug("task start"); setState(State.START); context.replicateLog(endpoint); lastReplicateAt = System.currentTimeMillis(); lastAdvanceAt = lastReplicateAt; setState(State.REPLICATING); while (!done) { wait(config.getNewNodeReadTimeout()); if (System.currentTimeMillis() - lastReplicateAt >= config.getNewNodeReadTimeout()) { logger.debug("node {} not response within read timeout", endpoint.getId()); state = State.TIMEOUT; break; } } logger.debug("task done"); context.done(this); return mapResult(state); } NewNodeCatchUpTask(NewNodeCatchUpTaskContext context, NodeEndpoint endpoint, NodeConfig config); NodeId getNodeId(); @Override synchronized NewNodeCatchUpTaskResult call(); @Override String toString(); }
NewNodeCatchUpTask implements Callable<NewNodeCatchUpTaskResult> { @Override public synchronized NewNodeCatchUpTaskResult call() throws Exception { logger.debug("task start"); setState(State.START); context.replicateLog(endpoint); lastReplicateAt = System.currentTimeMillis(); lastAdvanceAt = lastReplicateAt; setState(State.REPLICATING); while (!done) { wait(config.getNewNodeReadTimeout()); if (System.currentTimeMillis() - lastReplicateAt >= config.getNewNodeReadTimeout()) { logger.debug("node {} not response within read timeout", endpoint.getId()); state = State.TIMEOUT; break; } } logger.debug("task done"); context.done(this); return mapResult(state); } NewNodeCatchUpTask(NewNodeCatchUpTaskContext context, NodeEndpoint endpoint, NodeConfig config); NodeId getNodeId(); @Override synchronized NewNodeCatchUpTaskResult call(); @Override String toString();  }