Search in sources :

Example 11 with StreamInfo

use of io.grpc.ClientStreamTracer.StreamInfo in project grpc-java by grpc.

the class GrpcUtil method getClientStreamTracers.

/**
 * Gets stream tracers based on CallOptions.
 */
public static ClientStreamTracer[] getClientStreamTracers(CallOptions callOptions, Metadata headers, int previousAttempts, boolean isTransparentRetry) {
    List<ClientStreamTracer.Factory> factories = callOptions.getStreamTracerFactories();
    ClientStreamTracer[] tracers = new ClientStreamTracer[factories.size() + 1];
    StreamInfo streamInfo = StreamInfo.newBuilder().setCallOptions(callOptions).setPreviousAttempts(previousAttempts).setIsTransparentRetry(isTransparentRetry).build();
    for (int i = 0; i < factories.size(); i++) {
        tracers[i] = factories.get(i).newClientStreamTracer(streamInfo, headers);
    }
    // Reserved to be set later by the lb as per the API contract of ClientTransport.newStream().
    // See also GrpcUtil.getTransportFromPickResult()
    tracers[tracers.length - 1] = NOOP_TRACER;
    return tracers;
}
Also used : ClientStreamTracer(io.grpc.ClientStreamTracer) StreamInfo(io.grpc.ClientStreamTracer.StreamInfo) ThreadFactory(java.util.concurrent.ThreadFactory)

Aggregations

StreamInfo (io.grpc.ClientStreamTracer.StreamInfo)11 Test (org.junit.Test)9 ClientStreamTracer (io.grpc.ClientStreamTracer)7 Metadata (io.grpc.Metadata)6 CallOptions (io.grpc.CallOptions)5 Subchannel (io.grpc.LoadBalancer.Subchannel)3 MethodDescriptor (io.grpc.MethodDescriptor)3 Status (io.grpc.Status)3 PickSubchannelArgs (io.grpc.LoadBalancer.PickSubchannelArgs)2 MockClientTransportInfo (io.grpc.internal.TestUtils.MockClientTransportInfo)2 ForwardingSubchannel (io.grpc.util.ForwardingSubchannel)2 Attributes (io.grpc.Attributes)1 Ticker (io.grpc.Deadline.Ticker)1 SocketStats (io.grpc.InternalChannelz.SocketStats)1 InternalMetadata (io.grpc.InternalMetadata)1 MetricsRecord (io.grpc.internal.testing.StatsTestUtils.MetricsRecord)1 TagValue (io.opencensus.tags.TagValue)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Executor (java.util.concurrent.Executor)1 ThreadFactory (java.util.concurrent.ThreadFactory)1