static <SERVER extends RaftServer> void blockQueueAndSetDelay( Collection<SERVER> servers, DelayLocalExecutionInjection injection, String leaderId, int delayMs, long maxTimeout) throws InterruptedException { // block reqeusts sent to leader if delayMs > 0 final boolean block = delayMs > 0; LOG.debug("{} requests sent to leader {} and set {}ms delay for the others", block? "Block": "Unblock", leaderId, delayMs); if (block) { BlockRequestHandlingInjection.getInstance().blockReplier(leaderId); } else { BlockRequestHandlingInjection.getInstance().unblockReplier(leaderId); } // delay RaftServerRequest for other servers servers.stream().filter(s -> !s.getId().toString().equals(leaderId)) .forEach(s -> { if (block) { injection.setDelayMs(s.getId().toString(), delayMs); } else { injection.removeDelay(s.getId().toString()); } }); Thread.sleep(3 * maxTimeout); }
static <SERVER extends RaftServer> void blockQueueAndSetDelay( Collection<SERVER> servers, DelayLocalExecutionInjection injection, String leaderId, int delayMs, long maxTimeout) throws InterruptedException { // block reqeusts sent to leader if delayMs > 0 final boolean block = delayMs > 0; LOG.debug("{} requests sent to leader {} and set {}ms delay for the others", block? "Block": "Unblock", leaderId, delayMs); if (block) { BlockRequestHandlingInjection.getInstance().blockReplier(leaderId); } else { BlockRequestHandlingInjection.getInstance().unblockReplier(leaderId); } // delay RaftServerRequest for other servers servers.stream().filter(s -> !s.getId().toString().equals(leaderId)) .forEach(s -> { if (block) { injection.setDelayMs(s.getId().toString(), delayMs); } else { injection.removeDelay(s.getId().toString()); } }); Thread.sleep(3 * maxTimeout); }
BlockRequestHandlingInjection.getInstance().unblockReplier(leaderId.toString()); cluster.setBlockRequestsFrom(leaderId.toString(), false);
BlockRequestHandlingInjection.getInstance().unblockReplier(leaderId.toString()); cluster.setBlockRequestsFrom(leaderId.toString(), false);