@Override public IOException unwrapRemoteException() { Class<?> realClass; try { // try to load a exception class from where the HBase classes are loaded or from Dynamic // classloader. realClass = Class.forName(getClassName(), false, ClassLoaderHolder.CLASS_LOADER); } catch (ClassNotFoundException cnfe) { try { // cause could be a hadoop exception, try to load from hadoop classpath realClass = Class.forName(getClassName(), false, super.getClass().getClassLoader()); } catch (ClassNotFoundException e) { return new DoNotRetryIOException( "Unable to load exception received from server:" + e.getMessage(), this); } } try { return instantiateException(realClass.asSubclass(IOException.class)); } catch (Exception e) { return new DoNotRetryIOException( "Unable to instantiate exception received from server:" + e.getMessage(), this); } }
/** * @param e exception to be wrapped * @return RemoteException made from passed <code>e</code> */ static RemoteException createRemoteException(final ExceptionResponse e) { String innerExceptionClassName = e.getExceptionClassName(); boolean doNotRetry = e.getDoNotRetry(); return e.hasHostname() ? // If a hostname then add it to the RemoteWithExtrasException new RemoteWithExtrasException(innerExceptionClassName, e.getStackTrace(), e.getHostname(), e.getPort(), doNotRetry) : new RemoteWithExtrasException(innerExceptionClassName, e.getStackTrace(), doNotRetry); }
private IOException instantiateException(Class<? extends IOException> cls) throws Exception { Constructor<? extends IOException> cn = cls.getConstructor(String.class); cn.setAccessible(true); IOException ex = cn.newInstance(this.getMessage()); ex.initCause(this); return ex; }
@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()); }
@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()); }
@Override public IOException unwrapRemoteException() { Class<?> realClass; try { // try to load a exception class from where the HBase classes are loaded or from Dynamic // classloader. realClass = Class.forName(getClassName(), false, ClassLoaderHolder.CLASS_LOADER); } catch (ClassNotFoundException cnfe) { try { // cause could be a hadoop exception, try to load from hadoop classpath realClass = Class.forName(getClassName(), false, super.getClass().getClassLoader()); } catch (ClassNotFoundException e) { return new DoNotRetryIOException( "Unable to load exception received from server:" + e.getMessage(), this); } } try { return instantiateException(realClass.asSubclass(IOException.class)); } catch (Exception e) { return new DoNotRetryIOException( "Unable to instantiate exception received from server:" + e.getMessage(), this); } }
@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()); }
/** * @param e exception to be wrapped * @return RemoteException made from passed <code>e</code> */ static RemoteException createRemoteException(final ExceptionResponse e) { String innerExceptionClassName = e.getExceptionClassName(); boolean doNotRetry = e.getDoNotRetry(); return e.hasHostname() ? // If a hostname then add it to the RemoteWithExtrasException new RemoteWithExtrasException(innerExceptionClassName, e.getStackTrace(), e.getHostname(), e.getPort(), doNotRetry) : new RemoteWithExtrasException(innerExceptionClassName, e.getStackTrace(), doNotRetry); }
private IOException instantiateException(Class<? extends IOException> cls) throws Exception { Constructor<? extends IOException> cn = cls.getConstructor(String.class); cn.setAccessible(true); IOException ex = cn.newInstance(this.getMessage()); ex.initCause(this); return ex; }
@Override public IOException unwrapRemoteException() { Class<?> realClass; try { // try to load a exception class from where the HBase classes are loaded or from Dynamic // classloader. realClass = Class.forName(getClassName(), false, ClassLoaderHolder.CLASS_LOADER); } catch (ClassNotFoundException cnfe) { try { // cause could be a hadoop exception, try to load from hadoop classpath realClass = Class.forName(getClassName(), false, super.getClass().getClassLoader()); } catch (ClassNotFoundException e) { return new DoNotRetryIOException( "Unable to load exception received from server:" + e.getMessage(), this); } } try { return instantiateException(realClass.asSubclass(IOException.class)); } catch (Exception e) { return new DoNotRetryIOException( "Unable to instantiate exception received from server:" + e.getMessage(), this); } }
/** * @param e exception to be wrapped * @return RemoteException made from passed <code>e</code> */ static RemoteException createRemoteException(final ExceptionResponse e) { String innerExceptionClassName = e.getExceptionClassName(); boolean doNotRetry = e.getDoNotRetry(); return e.hasHostname() ? // If a hostname then add it to the RemoteWithExtrasException new RemoteWithExtrasException(innerExceptionClassName, e.getStackTrace(), e.getHostname(), e.getPort(), doNotRetry) : new RemoteWithExtrasException(innerExceptionClassName, e.getStackTrace(), doNotRetry); }
private IOException instantiateException(Class<? extends IOException> cls) throws Exception { Constructor<? extends IOException> cn = cls.getConstructor(String.class); cn.setAccessible(true); IOException ex = cn.newInstance(this.getMessage()); ex.initCause(this); return ex; }
/** * @param e exception to be wrapped * @return RemoteException made from passed <code>e</code> */ private RemoteException createRemoteException(final ExceptionResponse e) { String innerExceptionClassName = e.getExceptionClassName(); boolean doNotRetry = e.getDoNotRetry(); return e.hasHostname()? // If a hostname then add it to the RemoteWithExtrasException new RemoteWithExtrasException(innerExceptionClassName, e.getStackTrace(), e.getHostname(), e.getPort(), doNotRetry): new RemoteWithExtrasException(innerExceptionClassName, e.getStackTrace(), doNotRetry); }
/** * @param e Proto exception * @return RemoteException made from passed <code>e</code> */ private RemoteException createRemoteException(final RPCProtos.ExceptionResponse e) { String innerExceptionClassName = e.getExceptionClassName(); boolean doNotRetry = e.getDoNotRetry(); return e.hasHostname() ? // If a hostname then add it to the RemoteWithExtrasException new RemoteWithExtrasException(innerExceptionClassName, e.getStackTrace(), e.getHostname(), e.getPort(), doNotRetry) : new RemoteWithExtrasException(innerExceptionClassName, e.getStackTrace(), doNotRetry); } }