Search in sources :

Example 1 with ThriftResponse

use of com.uber.tchannel.messages.ThriftResponse in project jaeger-client-java by jaegertracing.

the class TraceBehavior method callDownstreamTChannel.

public TraceResponse callDownstreamTChannel(Downstream downstream) throws Exception {
    com.uber.jaeger.crossdock.thrift.JoinTraceRequest joinTraceRequest = new com.uber.jaeger.crossdock.thrift.JoinTraceRequest(downstream.getServerRole());
    joinTraceRequest.setDownstream(Downstream.toThrift(downstream.getDownstream()));
    SubChannel subChannel = TChannelServer.server.makeSubChannel(downstream.getServiceName());
    log.info("Calling downstream tchannel {}", joinTraceRequest);
    ThriftRequest<TracedService.joinTrace_args> thriftRequest = new ThriftRequest.Builder<TracedService.joinTrace_args>(downstream.getServiceName(), "TracedService::joinTrace").setTimeout(2000).setBody(new TracedService.joinTrace_args(joinTraceRequest)).build();
    TFuture<ThriftResponse<TracedService.joinTrace_result>> future = subChannel.send(thriftRequest, host(downstream), port(downstream));
    try (ThriftResponse<TracedService.joinTrace_result> thriftResponse = future.get()) {
        log.info("Received tchannel response {}", thriftResponse);
        if (thriftResponse.isError()) {
            throw new Exception(thriftResponse.getError().getMessage());
        }
        return TraceResponse.fromThrift(thriftResponse.getBody(TracedService.joinTrace_result.class).getSuccess());
    }
}
Also used : ThriftRequest(com.uber.tchannel.messages.ThriftRequest) JoinTraceRequest(com.uber.jaeger.crossdock.api.JoinTraceRequest) SubChannel(com.uber.tchannel.api.SubChannel) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) TracedService(com.uber.jaeger.crossdock.thrift.TracedService) ThriftResponse(com.uber.tchannel.messages.ThriftResponse)

Aggregations

JoinTraceRequest (com.uber.jaeger.crossdock.api.JoinTraceRequest)1 TracedService (com.uber.jaeger.crossdock.thrift.TracedService)1 SubChannel (com.uber.tchannel.api.SubChannel)1 ThriftRequest (com.uber.tchannel.messages.ThriftRequest)1 ThriftResponse (com.uber.tchannel.messages.ThriftResponse)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1