@Override public void fragmentStatusUpdate(FragmentStatus update) throws RpcException { throw new RpcException("This daemon doesn't support coordination operations."); }
@Override public void nodeQueryStatusUpdate(NodeQueryStatus update) throws RpcException { throw new RpcException("This daemon doesn't support coordination operations."); }
public static RpcException mapException(String message, Throwable t) { while (t instanceof ExecutionException) { t = ((ExecutionException)t).getCause(); } return new RpcException(message, t); }
public static RpcException mapException(Throwable t) { while (t instanceof ExecutionException) { t = ((ExecutionException)t).getCause(); } if (t instanceof RpcException) { return ((RpcException) t); } return new RpcException(t); }
public static <T> T get(byte[] pBody, Parser<T> parser) throws RpcException { try { return parser.parseFrom(pBody); } catch (InvalidProtocolBufferException e) { throw new RpcException(String.format("Failure while decoding message with parser of type. %s", parser.getClass().getCanonicalName()), e); } }
@Override public void interrupted(final InterruptedException e) { // AttemptManager shouldn't get interrupted while waiting for the RPC outcome of fragment submission. // Consider the interrupt as failure. final String errMsg = "Interrupted while waiting for the RPC outcome of fragment submission."; logger.error(errMsg, e); failed(new RpcException(errMsg, e)); } }
public static <T> T get(ByteBuf pBody, Parser<T> parser) throws RpcException { try { ByteBufInputStream is = new ByteBufInputStream(pBody); return parser.parseFrom(is); } catch (InvalidProtocolBufferException e) { throw new RpcException(String.format("Failure while decoding message with parser of type. %s", parser.getClass().getCanonicalName()), e); } }
@Override protected void validateHandshake(FabricHandshake handshake) throws RpcException { if (handshake.getRpcVersion() != FabricRpcConfig.RPC_VERSION) { throw new RpcException(String.format("Invalid rpc version. Expected %d, actual %d.", handshake.getRpcVersion(), FabricRpcConfig.RPC_VERSION)); } }
private <Req extends MessageLite, Resp extends MessageLite, T extends SendEndpointCreator<Req, Resp>> SendEndpoint<Req, Resp> newEndpoint(T creator) throws RpcException { NodeEndpoint masterNode = master.get(); if (masterNode == null) { throw new RpcException("master node is down"); } return creator.getEndpoint(masterNode.getAddress(), masterNode.getFabricPort()); }
private SendEndpoint<DLFindRequest, DLFindResponse> newFindEndpoint() throws RpcException { final NodeEndpoint master = masterEndpoint.get(); if (master == null) { throw new RpcException("master node is down"); } // TODO(DX-10861): separate server-side and client-side code, when the ticket is resolved return findEndpointCreator.getEndpoint(master.getAddress(), master.getFabricPort()); }
private SendEndpoint<DLGetSourceRequest, DLGetSourceResponse> newGetSourceEndpoint() throws RpcException { final NodeEndpoint master = masterEndpoint.get(); if (master == null) { throw new RpcException("master node is down"); } // TODO(DX-10861): separate server-side and client-side code, when the ticket is resolved return getSourceEndpointCreator.getEndpoint(master.getAddress(), master.getFabricPort()); }
@Override public void failed(final RpcException ex) { if (latch != null) { // this block only applies to intermediate fragments fragmentSubmitFailures.addFailure(endpoint, ex); latch.countDown(); } else { // this block only applies to leaf fragments // since this won't be waited on, we can wait to deliver this event once the AttemptManager is ready exception.addException(new RpcException(String.format("Failure sending leaf fragment to %s:%d.", endpoint.getAddress(), endpoint.getFabricPort()), ex)); } }
public static void assertEqualsRpc(byte[] expected, ArrowBuf actual) throws RpcException{ try{ assertEqualsBytes(expected, actual); }catch(AssertionError e){ throw new RpcException(e); } }
@Test public void testNonRemoteException() throws Exception { RpcException e = new RpcException("Test message", new Exception()); RpcException.propagateIfPossible(e, Exception.class); }
@Override public SentResponseMessage<QueryId> handle(NodeEndpoint request, ArrowBuf dBody) throws RpcException { if (!request.equals(expectedD)) { throw new RpcException("Objects not same."); } return new SentResponseMessage<>(expectedQ); } });
private void connect(NodeEndpoint endpoint) throws RpcException { final FutureHandler f = new FutureHandler(); client.connect(f, endpoint, props, getUserCredentials()); try { f.checkedGet(30, TimeUnit.SECONDS); } catch (TimeoutException e) { throw new RpcException("Timed out after 30s waiting to connect to "+endpoint.getAddress() +":"+endpoint.getUserPort()); } }
@Override public SentResponseMessage<QueryId> handle(NodeEndpoint request, ArrowBuf dBody) throws RpcException { if (!request.equals(expectedD)) { throw new RpcException("Objects not same."); } assertEqualsRpc(r1B, dBody); random2.retain(); return new SentResponseMessage<>(expectedQ, random2); } });
private static final RpcException newRPCException(NodeEndpoint endpoint, IOException ioe) { UserRemoteException ure = UserRemoteException.create(UserException .ioExceptionError(ioe) .addIdentity(endpoint) .build(logger).getOrCreatePBError(false)); return new RpcException(ure); } @Test
@Test public void testRemoteRuntimeException() throws Exception { UserRemoteException ure = UserRemoteException.create(UserException .unsupportedError(new UserRpcException(null, "user rpc exception", new RuntimeException("test message"))) .build(logger).getOrCreatePBError(false)); exception.expect(RuntimeException.class); exception.expectMessage("test message"); RpcException.propagateIfPossible(new RpcException(ure), TestException.class); } }
@Test public void testRemoteTestException() throws Exception { UserRemoteException ure = UserRemoteException.create(UserException .unsupportedError(new UserRpcException(null, "user rpc exception", new TestException("test message"))) .build(logger).getOrCreatePBError(false)); exception.expect(TestException.class); exception.expectMessage("test message"); RpcException.propagateIfPossible(new RpcException(ure), TestException.class); }