@Override public void unableToBuildQuery(Exception e) { if (e instanceof UserRpcException) { sender.sendFailure((UserRpcException) e); } else { final UserRpcException genericException = new UserRpcException(NodeEndpoint.getDefaultInstance(), "Remote message leaked.", e); sender.sendFailure(genericException); } }
private void startFragment(final QueryTicket queryTicket, final PlanFragment fragment, final SchedulingInfo schedulingInfo) throws UserRpcException { logger.info("Received remote fragment start instruction for {}", QueryIdHelper.getQueryIdentifier(fragment.getHandle())); try { final EventProvider eventProvider = getEventProvider(fragment.getHandle()); startFragment(builder.build(queryTicket, fragment, eventProvider, schedulingInfo, fragments.getSharedDataList())); } catch (final Exception e) { throw new UserRpcException(identity, "Failure while trying to start remote fragment", e); } catch (final OutOfMemoryError t) { if (t.getMessage().startsWith("Direct buffer")) { throw new UserRpcException(identity, "Out of direct memory while trying to start remote fragment", t); } else { throw t; } } }
@Override public void handle(PhysicalConnection connection, int rpcType, ByteString pBody, ByteBuf dBody, ResponseSender sender) throws RpcException { MessageLite defaultInstance = defaultRequestInstances[rpcType]; try{ MessageLite value = defaultInstance.getParserForType().parseFrom(pBody); SentResponseMessage<MessageLite> response = handlers[rpcType].handle(value, (ArrowBuf) dBody); sender.send(new Response(new PseudoEnum(rpcType), response.getBody(), response.getBuffers())); } catch(Exception e){ final String fail = String.format("Failure consuming message for protocol[%d], request[%d] in the %s rpc layer.", getProtocolId(), rpcType, getConfig().getName()); throw new UserRpcException(NodeEndpoint.getDefaultInstance(), fail, e); } } }
@Override public void buildAndStartQuery(final QueryTicket queryTicket) { try { for (int i = 0; i < fragments.getFragmentCount(); i++) { startFragment(queryTicket, fragments.getFragment(i), schedulingInfo); } sender.send(OK); } catch (UserRpcException e) { sender.sendFailure(e); } catch (Exception e) { final UserRpcException genericException = new UserRpcException(NodeEndpoint.getDefaultInstance(), "Remote message leaked.", e); sender.sendFailure(genericException); } finally { if (queryTicket != null) { queryTicket.release(); } } }
@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); } }
builder.withRecordBatchFormat(chooseDremioRecordBatchFormat(inbound)); } catch(IllegalArgumentException e) { throw new UserRpcException(dbContext.get().getEndpoint(), e.getMessage(), e);
@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); }