@Test public void testEndpointExceptions() throws Exception { final ServerName serverName = TEST_UTIL.getHBaseCluster().getRegionServer(0).getServerName(); final ServerRpcController controller = new ServerRpcController(); final BlockingRpcCallback<DummyRegionServerEndpointProtos.DummyResponse> rpcCallback = new BlockingRpcCallback<DummyRegionServerEndpointProtos.DummyResponse>(); DummyRegionServerEndpointProtos.DummyService service = ProtobufUtil.newServiceStub(DummyRegionServerEndpointProtos.DummyService.class, TEST_UTIL.getHBaseAdmin().coprocessorService(serverName)); service.dummyThrow(controller, DummyRegionServerEndpointProtos.DummyRequest.getDefaultInstance(), rpcCallback); assertEquals(null, rpcCallback.get()); assertTrue(controller.failedOnException()); assertEquals(WHAT_TO_THROW.getClass().getName().trim(), ((RemoteWithExtrasException) controller.getFailedOn().getCause()).getClassName().trim()); }
@Test public void testEndpointExceptions() throws Exception { final ServerName serverName = TEST_UTIL.getHBaseCluster().getRegionServer(0).getServerName(); final ServerRpcController controller = new ServerRpcController(); final CoprocessorRpcUtils.BlockingRpcCallback<DummyRegionServerEndpointProtos.DummyResponse> rpcCallback = new CoprocessorRpcUtils.BlockingRpcCallback<>(); DummyRegionServerEndpointProtos.DummyService service = ProtobufUtil.newServiceStub(DummyRegionServerEndpointProtos.DummyService.class, TEST_UTIL.getAdmin().coprocessorService(serverName)); service.dummyThrow(controller, DummyRegionServerEndpointProtos.DummyRequest.getDefaultInstance(), rpcCallback); assertEquals(null, rpcCallback.get()); assertTrue(controller.failedOnException()); assertEquals(WHAT_TO_THROW.getClass().getName().trim(), ((RemoteWithExtrasException) controller.getFailedOn().getCause()).getClassName().trim()); }
private boolean shouldRethrowException(Exception e) { // recreate region scanners if the exception was throw due to a region split. In that case, the // root cause could be an DoNotRetryException or an RemoteWithExtrasException with class name of // DoNotRetryException Throwable rootCause = Throwables.getRootCause(e); boolean rethrow = true; if (rootCause instanceof DoNotRetryIOException) rethrow = false; else if (rootCause instanceof RemoteWithExtrasException) { String className = ((RemoteWithExtrasException) rootCause).getClassName(); if (className.compareTo(DoNotRetryIOException.class.getName()) == 0) { rethrow = false; } } if (!rethrow) { if (LOG.isDebugEnabled()) SpliceLogUtils.debug(LOG, "exception logged creating split region scanner %s", StringUtils.stringifyException(e)); try { clock.sleep(200l, TimeUnit.MILLISECONDS); } catch (InterruptedException ignored) { } } return rethrow; }