@Test public void testOnLogCommittedRemoveNodeTask() throws ExecutionException, InterruptedException { WaitableGroupConfigChangeTaskContext taskContext = new WaitableGroupConfigChangeTaskContext(); RemoveNodeTask task = new RemoveNodeTask(taskContext, NodeId.of("B")); Future<GroupConfigChangeTaskResult> future = taskExecutor.submit(task); GroupConfigChangeTaskHolder taskHolder = new GroupConfigChangeTaskHolder( task, new FixedResultGroupConfigTaskReference(GroupConfigChangeTaskResult.OK) ); taskContext.awaitLogAppended(); RemoveNodeEntry entry = new RemoveNodeEntry(1, 1, Collections.emptySet(), NodeId.of("B")); Assert.assertTrue(taskHolder.onLogCommitted(entry)); future.get(); }
public boolean onLogCommitted(GroupConfigEntry entry) { if (isEmpty()) { return false; } logger.debug("log {} committed, current task {}", entry, task); if (entry instanceof AddNodeEntry && task instanceof AddNodeTask && task.isTargetNode(((AddNodeEntry) entry).getNewNodeEndpoint().getId())) { task.onLogCommitted(); return true; } if (entry instanceof RemoveNodeEntry && task instanceof RemoveNodeTask && task.isTargetNode(((RemoveNodeEntry) entry).getNodeToRemove())) { task.onLogCommitted(); return true; } return false; }
GroupConfigChangeTaskHolder { public boolean onLogCommitted(GroupConfigEntry entry) { if (isEmpty()) { return false; } logger.debug("log {} committed, current task {}", entry, task); if (entry instanceof AddNodeEntry && task instanceof AddNodeTask && task.isTargetNode(((AddNodeEntry) entry).getNewNodeEndpoint().getId())) { task.onLogCommitted(); return true; } if (entry instanceof RemoveNodeEntry && task instanceof RemoveNodeTask && task.isTargetNode(((RemoveNodeEntry) entry).getNodeToRemove())) { task.onLogCommitted(); return true; } return false; } }
GroupConfigChangeTaskHolder { public boolean onLogCommitted(GroupConfigEntry entry) { if (isEmpty()) { return false; } logger.debug("log {} committed, current task {}", entry, task); if (entry instanceof AddNodeEntry && task instanceof AddNodeTask && task.isTargetNode(((AddNodeEntry) entry).getNewNodeEndpoint().getId())) { task.onLogCommitted(); return true; } if (entry instanceof RemoveNodeEntry && task instanceof RemoveNodeTask && task.isTargetNode(((RemoveNodeEntry) entry).getNodeToRemove())) { task.onLogCommitted(); return true; } return false; } GroupConfigChangeTaskHolder();  GroupConfigChangeTaskHolder(GroupConfigChangeTask task, GroupConfigChangeTaskReference reference); }
GroupConfigChangeTaskHolder { public boolean onLogCommitted(GroupConfigEntry entry) { if (isEmpty()) { return false; } logger.debug("log {} committed, current task {}", entry, task); if (entry instanceof AddNodeEntry && task instanceof AddNodeTask && task.isTargetNode(((AddNodeEntry) entry).getNewNodeEndpoint().getId())) { task.onLogCommitted(); return true; } if (entry instanceof RemoveNodeEntry && task instanceof RemoveNodeTask && task.isTargetNode(((RemoveNodeEntry) entry).getNodeToRemove())) { task.onLogCommitted(); return true; } return false; } GroupConfigChangeTaskHolder();  GroupConfigChangeTaskHolder(GroupConfigChangeTask task, GroupConfigChangeTaskReference reference); void awaitDone(long timeout); void cancel(); boolean isEmpty(); boolean onLogCommitted(GroupConfigEntry entry); }
GroupConfigChangeTaskHolder { public boolean onLogCommitted(GroupConfigEntry entry) { if (isEmpty()) { return false; } logger.debug("log {} committed, current task {}", entry, task); if (entry instanceof AddNodeEntry && task instanceof AddNodeTask && task.isTargetNode(((AddNodeEntry) entry).getNewNodeEndpoint().getId())) { task.onLogCommitted(); return true; } if (entry instanceof RemoveNodeEntry && task instanceof RemoveNodeTask && task.isTargetNode(((RemoveNodeEntry) entry).getNodeToRemove())) { task.onLogCommitted(); return true; } return false; } GroupConfigChangeTaskHolder();  GroupConfigChangeTaskHolder(GroupConfigChangeTask task, GroupConfigChangeTaskReference reference); void awaitDone(long timeout); void cancel(); boolean isEmpty(); boolean onLogCommitted(GroupConfigEntry entry);  }