@Override public void sendFailure(UserRpcException e) { innerSender.sendFailure(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(); } } }
private void ackit(){ // No matter what, we ack back to the original node. Since we manage // execution, we can cancel on failure from here. We don't ack until we've // passed data through, ensuring that we have full backpressure. sender.send(new Response(RpcType.ACK, Acks.OK)); } }
@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); } }
protected void handle(C connection, int rpcType, byte[] pBody, ByteBuf dBody, ResponseSender sender) throws RpcException { sender.send(handle(connection, rpcType, pBody, dBody)); }
protected abstract Response handle(PhysicalConnection connection, int rpcType, ByteString pBody, ByteBuf dBody) throws RpcException;
public void handle(PhysicalConnection connection, int rpcType, ByteString pBody, ByteBuf body, ResponseSender sender) throws RpcException { switch(rpcType){ case RpcType.REQ_RECORD_BATCH_VALUE: { final FragmentRecordBatch fragmentBatch = RpcBus.get(pBody, FragmentRecordBatch.PARSER); handleFragmentRecordBatch(fragmentBatch, body, sender); return; } case RpcType.REQ_STREAM_COMPLETE_VALUE: { final FragmentStreamComplete completion = RpcBus.get(pBody, FragmentStreamComplete.PARSER); handleFragmentStreamCompletion(completion); sender.send(OK); return; } case RpcType.REQ_RECEIVER_FINISHED_VALUE: { final FinishedReceiver completion = RpcBus.get(pBody, FinishedReceiver.PARSER); handleReceiverFinished(completion); sender.send(OK); return; } case RpcType.REQ_OOB_MESSAGE_VALUE: { final OOBMessage oobMessage = RpcBus.get(pBody, OOBMessage.PARSER); handleOobMessage(oobMessage); sender.send(OK); return; } default: throw new UnsupportedOperationException(); } }
final FragmentHandle handle = get(pBody, FragmentHandle.PARSER); coordToExec.get().cancelFragment(handle); sender.send(OK); break; FragmentStatus status = get(pBody, FragmentStatus.PARSER); execToCoord.get().fragmentStatusUpdate(status); sender.send(OK); break; NodeQueryStatus nodeQueryStatus = get(pBody, NodeQueryStatus.PARSER); execToCoord.get().nodeQueryStatusUpdate(nodeQueryStatus); sender.send(OK); break;
@Override public void run() { try { SourceConfig config = new SourceConfig(); ProtobufIOUtil.mergeFrom(wrapper.getBytes().toByteArray(), config, SourceConfig.getSchema()); if(update) { listener.sourceUpdate(config); } else { listener.sourceDelete(config); } } finally { sender.send(OK); } }
sender.send(new Response(ReflectionRPC.RpcType.RESP_REFLECTION_INFO, response)); break; ReflectionRPC.RefreshInfoResp response = ReflectionRPC.RefreshInfoResp.newBuilder() .addAllRefreshInfo(refreshInfos).build(); sender.send(new Response(ReflectionRPC.RpcType.RESP_REFRESH_INFO, response)); break; sender.send(new Response(ReflectionRPC.RpcType.RESP_DEPENDENCY_INFO, response)); break;
@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 send(Response r) { FabricMessage message = FabricMessage.newBuilder() .setProtocolId(protocolId) .setInnerRpcType(r.rpcType.getNumber()) .setMessage(r.pBody.toByteString()) .build(); innerSender.send(new Response(RpcType.MESSAGE, message, r.dBodies)); }
private void handleFragmentRecordBatch(FragmentRecordBatch fragmentBatch, ByteBuf body, ResponseSender sender) throws RpcException { final AckSender ack = new AckSender(sender); // increment so we don't get false returns. ack.increment(); try { final IncomingDataBatch batch = new IncomingDataBatch(fragmentBatch, (ArrowBuf) body, ack); final int targetCount = fragmentBatch.getReceivingMinorFragmentIdCount(); // randomize who gets first transfer (and thus ownership) so memory usage // is balanced when we're sharing amongst // multiple fragments. final int firstOwner = ThreadLocalRandom.current().nextInt(targetCount); submit(batch, firstOwner, targetCount); submit(batch, 0, firstOwner); // decrement the extra reference we grabbed at the top. ack.sendOk(); } catch (IOException | FragmentSetupException e) { logger.error("Failure while getting fragment manager. {}", QueryIdHelper.getQueryIdentifiers(fragmentBatch.getQueryId(), fragmentBatch.getReceivingMajorFragmentId(), fragmentBatch.getReceivingMinorFragmentIdList()), e); ack.clear(); sender.send(new Response(RpcType.ACK, Acks.FAIL)); } }
final QueryId queryId = ExternalIdHelper.toQueryId(worker.submitWork(connection.getSession(), new UserConnectionResponseHandler(connection), request, registry)); responseSender.send(new Response(RpcType.QUERY_HANDLE, queryId)); break; } catch (InvalidProtocolBufferException e) { final Ack ack = worker.cancelQuery(ExternalIdHelper.toExternal(queryId), connection.getSession().getCredentials().getUserName()); responseSender.send(new Response(RpcType.ACK, ack)); break; } catch (InvalidProtocolBufferException e) { final QueryId queryId = QueryId.PARSER.parseFrom(pBody); final Ack ack = worker.resumeQuery(ExternalIdHelper.toExternal(queryId)); responseSender.send(new Response(RpcType.ACK, ack)); break; } catch (InvalidProtocolBufferException e) {
@Override public void handle(final PhysicalConnection connection, int rpcType, ByteString pBody, ByteBuf dBody, ResponseSender sender) throws RpcException { switch(rpcType){ case 1: sender.send(new Response(new FakeEnum(1), expectedD)); new Thread(){ @Override public void run() { try { closeLatch.await(); ((RemoteConnection)connection).getChannel().close(); } catch (InterruptedException e) { } } }.start(); return; case 2: ((RemoteConnection)connection).getChannel().close(); return; default: throw new UnsupportedOperationException(); } }