status = TransportStatus.setCompress(status); threadPool.getThreadContext().writeTo(stream); stream.setVersion(nodeVersion); stream.setFeatures(features);
threadPool.getThreadContext().writeTo(stream); if (version.onOrAfter(Version.V_6_3_0)) { stream.writeStringArray(features);
RemoteTransportException tx = new RemoteTransportException( nodeName, new TransportAddress(channel.getLocalAddress()), action, error); threadPool.getThreadContext().writeTo(stream); stream.writeException(tx); byte status = 0;
private void writeResponseExceptionHeader(BytesStreamOutput stream) throws IOException { stream.writeLong(requestId); byte status = 0; status = TransportStatus.setResponse(status); status = TransportStatus.setError(status); stream.writeByte(status); threadContext.writeTo(stream); } }
@Override public void sendResponse(TransportResponse response, TransportResponseOptions options) throws IOException { try (BytesStreamOutput stream = new BytesStreamOutput()) { stream.setVersion(version); stream.writeLong(requestId); byte status = 0; status = TransportStatus.setResponse(status); stream.writeByte(status); // 0 for request, 1 for response. threadContext.writeTo(stream); response.writeTo(stream); sendResponseData(BytesReference.toBytes(stream.bytes())); sourceTransportServiceAdapter.onResponseSent(requestId, action, response, options); } }
protected void sendRequest(LocalTransport targetTransport, final DiscoveryNode node, final long requestId, final String action, final TransportRequest request, TransportRequestOptions options) throws IOException, TransportException { final Version version = Version.min(node.getVersion(), getVersion()); try (BytesStreamOutput stream = new BytesStreamOutput()) { stream.setVersion(version); stream.writeLong(requestId); byte status = 0; status = TransportStatus.setRequest(status); stream.writeByte(status); // 0 for request, 1 for response. threadPool.getThreadContext().writeTo(stream); stream.writeString(action); request.writeTo(stream); stream.close(); final byte[] data = BytesReference.toBytes(stream.bytes()); transportServiceAdapter.addBytesSent(data.length); transportServiceAdapter.onRequestSent(node, requestId, action, request, options); targetTransport.receiveMessage(version, data, action, requestId, this); } }
/** * Sends back an error response to the caller via the given channel * @param nodeVersion the caller node version * @param channel the channel to send the response to * @param error the error to return * @param requestId the request ID this response replies to * @param action the action this response replies to */ public void sendErrorResponse(Version nodeVersion, Channel channel, final Exception error, final long requestId, final String action) throws IOException { try (BytesStreamOutput stream = new BytesStreamOutput()) { stream.setVersion(nodeVersion); RemoteTransportException tx = new RemoteTransportException( nodeName(), new InetSocketTransportAddress(getLocalAddress(channel)), action, error); threadPool.getThreadContext().writeTo(stream); stream.writeException(tx); byte status = 0; status = TransportStatus.setResponse(status); status = TransportStatus.setError(status); final BytesReference bytes = stream.bytes(); final BytesReference header = buildHeader(requestId, status, nodeVersion, bytes.length()); Runnable onRequestSent = () -> transportServiceAdapter.onResponseSent(requestId, action, error); sendMessage(channel, new CompositeBytesReference(header, bytes), onRequestSent); } }
stream = CompressorFactory.COMPRESSOR.streamOutput(stream); threadPool.getThreadContext().writeTo(stream); stream.setVersion(nodeVersion); BytesReference reference = buildMessage(requestId, status, nodeVersion, response, stream, bStream);
status = TransportStatus.setCompress(status); threadPool.getThreadContext().writeTo(stream); stream.setVersion(nodeVersion); stream.setFeatures(features);
RemoteTransportException tx = new RemoteTransportException( nodeName(), new TransportAddress(channel.getLocalAddress()), action, error); threadPool.getThreadContext().writeTo(stream); stream.writeException(tx); byte status = 0;
threadPool.getThreadContext().writeTo(stream); stream.writeString(action); BytesReference message = buildMessage(requestId, status, node.getVersion(), request, stream, bStream);
threadPool.getThreadContext().writeTo(stream); if (version.onOrAfter(Version.V_6_3_0)) { stream.writeStringArray(features);