@Test public void testOnReceiveAppendEntriesResult() throws InterruptedException, ExecutionException { NewNodeCatchUpTaskGroup group = new NewNodeCatchUpTaskGroup(); WaitableNewNodeCatchUpTaskContext taskContext = new WaitableNewNodeCatchUpTaskContext(); NewNodeCatchUpTask task = new NewNodeCatchUpTask( taskContext, new NodeEndpoint("D", "localhost", 2336), new NodeConfig() ); group.add(task); TaskExecutor taskExecutor = new SingleThreadTaskExecutor(); Future<NewNodeCatchUpTaskResult> future = taskExecutor.submit(task); taskContext.awaitReplicateLog(); AppendEntriesRpc rpc = new AppendEntriesRpc(); rpc.setPrevLogIndex(1); Assert.assertTrue(group.onReceiveAppendEntriesResult( new AppendEntriesResultMessage( new AppendEntriesResult("", 1, true), NodeId.of("D"), rpc ), 2 )); future.get(); taskExecutor.shutdown(); }
public boolean onReceiveAppendEntriesResult(AppendEntriesResultMessage resultMessage, int nextLogIndex) { NewNodeCatchUpTask task = taskMap.get(resultMessage.getSourceNodeId()); if (task == null) { return false; } task.onReceiveAppendEntriesResult(resultMessage, nextLogIndex); return true; }
NewNodeCatchUpTaskGroup { public boolean onReceiveAppendEntriesResult(AppendEntriesResultMessage resultMessage, int nextLogIndex) { NewNodeCatchUpTask task = taskMap.get(resultMessage.getSourceNodeId()); if (task == null) { return false; } task.onReceiveAppendEntriesResult(resultMessage, nextLogIndex); return true; } }
NewNodeCatchUpTaskGroup { public boolean onReceiveAppendEntriesResult(AppendEntriesResultMessage resultMessage, int nextLogIndex) { NewNodeCatchUpTask task = taskMap.get(resultMessage.getSourceNodeId()); if (task == null) { return false; } task.onReceiveAppendEntriesResult(resultMessage, nextLogIndex); return true; }  }
NewNodeCatchUpTaskGroup { public boolean onReceiveAppendEntriesResult(AppendEntriesResultMessage resultMessage, int nextLogIndex) { NewNodeCatchUpTask task = taskMap.get(resultMessage.getSourceNodeId()); if (task == null) { return false; } task.onReceiveAppendEntriesResult(resultMessage, nextLogIndex); return true; }  boolean add(NewNodeCatchUpTask task); boolean onReceiveAppendEntriesResult(AppendEntriesResultMessage resultMessage, int nextLogIndex); boolean onReceiveInstallSnapshotResult(InstallSnapshotResultMessage resultMessage, int nextLogIndex); boolean remove(NewNodeCatchUpTask task); }
NewNodeCatchUpTaskGroup { public boolean onReceiveAppendEntriesResult(AppendEntriesResultMessage resultMessage, int nextLogIndex) { NewNodeCatchUpTask task = taskMap.get(resultMessage.getSourceNodeId()); if (task == null) { return false; } task.onReceiveAppendEntriesResult(resultMessage, nextLogIndex); return true; }  boolean add(NewNodeCatchUpTask task); boolean onReceiveAppendEntriesResult(AppendEntriesResultMessage resultMessage, int nextLogIndex); boolean onReceiveInstallSnapshotResult(InstallSnapshotResultMessage resultMessage, int nextLogIndex); boolean remove(NewNodeCatchUpTask task);  }