@Override @Test public void testWithLoad() throws Exception { super.testWithLoad(); BlockRequestHandlingInjection.getInstance().unblockAll(); } }
@Override public void setBlockRequestsFrom(String src, boolean block) { if (block) { BlockRequestHandlingInjection.getInstance().blockRequestor(src); } else { BlockRequestHandlingInjection.getInstance().unblockRequestor(src); } }
@Override public boolean execute(Object localId, Object remoteId, Object... args) { if (!shouldBlock(localId, remoteId)) { return false; } LOG.info(localId + ": Block request from " + remoteId); try { RaftTestUtil.block(() -> shouldBlock(localId, remoteId)); } catch (InterruptedException e) { LOG.debug("Interrupted while blocking request from " + remoteId + " to " + localId, e); } LOG.info(localId + ": unBlock request from " + remoteId); return true; }
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); }
@Override @Test public void testWithLoad() throws Exception { super.testWithLoad(); BlockRequestHandlingInjection.getInstance().unblockAll(); }
BlockRequestHandlingInjection.getInstance().blockReplier(leaderId.toString()); cluster.setBlockRequestsFrom(leaderId.toString(), true); BlockRequestHandlingInjection.getInstance().unblockReplier(leaderId.toString()); cluster.setBlockRequestsFrom(leaderId.toString(), false);
@Override public void setBlockRequestsFrom(String src, boolean block) { if (block) { BlockRequestHandlingInjection.getInstance().blockRequestor(src); } else { BlockRequestHandlingInjection.getInstance().unblockRequestor(src); } }
@Override public boolean execute(Object localId, Object remoteId, Object... args) { if (!shouldBlock(localId, remoteId)) { return false; } LOG.info(localId + ": Block request from " + remoteId); try { RaftTestUtil.block(() -> shouldBlock(localId, remoteId)); } catch (InterruptedException e) { LOG.debug("Interrupted while blocking request from " + remoteId + " to " + localId, e); } LOG.info(localId + ": unBlock request from " + remoteId); return true; }
@Override @Test public void testWithLoad() throws Exception { super.testWithLoad(); BlockRequestHandlingInjection.getInstance().unblockAll(); }
BlockRequestHandlingInjection.getInstance().blockReplier(leaderId.toString()); cluster.setBlockRequestsFrom(leaderId.toString(), true); BlockRequestHandlingInjection.getInstance().unblockReplier(leaderId.toString()); cluster.setBlockRequestsFrom(leaderId.toString(), false);
@Override @Test public void testWithLoad() throws Exception { super.testWithLoad(); BlockRequestHandlingInjection.getInstance().unblockAll(); } }
@Override @Test public void testWithLoad() throws Exception { super.testWithLoad(); BlockRequestHandlingInjection.getInstance().unblockAll(); }
@Override @Test public void testEnforceLeader() throws Exception { super.testEnforceLeader(); MiniRaftClusterWithHadoopRpc.sendServerRequest.clear(); BlockRequestHandlingInjection.getInstance().unblockAll(); } }
@Override @Test public void testEnforceLeader() throws Exception { super.testEnforceLeader(); MiniRaftClusterWithHadoopRpc.sendServerRequest.clear(); BlockRequestHandlingInjection.getInstance().unblockAll(); } }
@Override @Test public void testEnforceLeader() throws Exception { super.testEnforceLeader(); MiniRaftClusterWithGRpc.sendServerRequestInjection.clear(); BlockRequestHandlingInjection.getInstance().unblockAll(); } }
@Override @Test public void testEnforceLeader() throws Exception { super.testEnforceLeader(); MiniRaftClusterWithGrpc.sendServerRequestInjection.clear(); BlockRequestHandlingInjection.getInstance().unblockAll(); } }
@Override @Test public void testEnforceLeader() throws Exception { super.testEnforceLeader(); MiniRaftClusterWithNetty.sendServerRequest.clear(); BlockRequestHandlingInjection.getInstance().unblockAll(); } }