124 lines
5.7 KiB
Java
124 lines
5.7 KiB
Java
|
package io.grpc.internal;
|
||
|
|
||
|
import com.google.common.base.Preconditions;
|
||
|
import io.grpc.CallOptions;
|
||
|
import io.grpc.Channel;
|
||
|
import io.grpc.ClientCall;
|
||
|
import io.grpc.ClientStreamTracer;
|
||
|
import io.grpc.Context;
|
||
|
import io.grpc.InternalConfigSelector;
|
||
|
import io.grpc.Metadata;
|
||
|
import io.grpc.MethodDescriptor;
|
||
|
import io.grpc.Status;
|
||
|
import io.grpc.internal.ClientCallImpl;
|
||
|
import io.grpc.internal.ClientStreamListener;
|
||
|
import java.util.concurrent.Executor;
|
||
|
import java.util.concurrent.ScheduledExecutorService;
|
||
|
import java.util.concurrent.atomic.AtomicReference;
|
||
|
|
||
|
/* loaded from: classes6.dex */
|
||
|
final class SubchannelChannel extends Channel {
|
||
|
static final Status NOT_READY_ERROR;
|
||
|
static final Status WAIT_FOR_READY_ERROR;
|
||
|
private static final FailingClientTransport notReadyTransport;
|
||
|
private final CallTracer callsTracer;
|
||
|
private final AtomicReference<InternalConfigSelector> configSelector;
|
||
|
private final ScheduledExecutorService deadlineCancellationExecutor;
|
||
|
private final Executor executor;
|
||
|
private final InternalSubchannel subchannel;
|
||
|
private final ClientCallImpl.ClientStreamProvider transportProvider = new ClientCallImpl.ClientStreamProvider(this) { // from class: io.grpc.internal.SubchannelChannel.1
|
||
|
final SubchannelChannel this$0;
|
||
|
|
||
|
{
|
||
|
this.this$0 = this;
|
||
|
}
|
||
|
|
||
|
@Override // io.grpc.internal.ClientCallImpl.ClientStreamProvider
|
||
|
public ClientStream newStream(MethodDescriptor<?, ?> methodDescriptor, CallOptions callOptions, Metadata metadata, Context context) {
|
||
|
ClientTransport transport = this.this$0.subchannel.getTransport();
|
||
|
if (transport == null) {
|
||
|
transport = SubchannelChannel.notReadyTransport;
|
||
|
}
|
||
|
ClientStreamTracer[] clientStreamTracers = GrpcUtil.getClientStreamTracers(callOptions, metadata, 0, false);
|
||
|
Context attach = context.attach();
|
||
|
try {
|
||
|
return transport.newStream(methodDescriptor, metadata, callOptions, clientStreamTracers);
|
||
|
} finally {
|
||
|
context.detach(attach);
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
static {
|
||
|
Status withDescription = Status.UNAVAILABLE.withDescription("Subchannel is NOT READY");
|
||
|
NOT_READY_ERROR = withDescription;
|
||
|
WAIT_FOR_READY_ERROR = Status.UNAVAILABLE.withDescription("wait-for-ready RPC is not supported on Subchannel.asChannel()");
|
||
|
notReadyTransport = new FailingClientTransport(withDescription, ClientStreamListener.RpcProgress.REFUSED);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public SubchannelChannel(InternalSubchannel internalSubchannel, Executor executor, ScheduledExecutorService scheduledExecutorService, CallTracer callTracer, AtomicReference<InternalConfigSelector> atomicReference) {
|
||
|
this.subchannel = (InternalSubchannel) Preconditions.checkNotNull(internalSubchannel, "subchannel");
|
||
|
this.executor = (Executor) Preconditions.checkNotNull(executor, "executor");
|
||
|
this.deadlineCancellationExecutor = (ScheduledExecutorService) Preconditions.checkNotNull(scheduledExecutorService, "deadlineCancellationExecutor");
|
||
|
this.callsTracer = (CallTracer) Preconditions.checkNotNull(callTracer, "callsTracer");
|
||
|
this.configSelector = (AtomicReference) Preconditions.checkNotNull(atomicReference, "configSelector");
|
||
|
}
|
||
|
|
||
|
@Override // io.grpc.Channel
|
||
|
public final <RequestT, ResponseT> ClientCall<RequestT, ResponseT> newCall(MethodDescriptor<RequestT, ResponseT> methodDescriptor, CallOptions callOptions) {
|
||
|
Executor executor = callOptions.getExecutor() == null ? this.executor : callOptions.getExecutor();
|
||
|
if (callOptions.isWaitForReady()) {
|
||
|
return new ClientCall<RequestT, ResponseT>(this, executor) { // from class: io.grpc.internal.SubchannelChannel.2
|
||
|
final SubchannelChannel this$0;
|
||
|
final Executor val$effectiveExecutor;
|
||
|
|
||
|
@Override // io.grpc.ClientCall
|
||
|
public void cancel(String str, Throwable th) {
|
||
|
}
|
||
|
|
||
|
@Override // io.grpc.ClientCall
|
||
|
public void halfClose() {
|
||
|
}
|
||
|
|
||
|
@Override // io.grpc.ClientCall
|
||
|
public void request(int i) {
|
||
|
}
|
||
|
|
||
|
@Override // io.grpc.ClientCall
|
||
|
public void sendMessage(RequestT requestt) {
|
||
|
}
|
||
|
|
||
|
{
|
||
|
this.this$0 = this;
|
||
|
this.val$effectiveExecutor = executor;
|
||
|
}
|
||
|
|
||
|
@Override // io.grpc.ClientCall
|
||
|
public void start(ClientCall.Listener<ResponseT> listener, Metadata metadata) {
|
||
|
this.val$effectiveExecutor.execute(new Runnable(this, listener) { // from class: io.grpc.internal.SubchannelChannel.2.1
|
||
|
final AnonymousClass2 this$1;
|
||
|
final ClientCall.Listener val$listener;
|
||
|
|
||
|
{
|
||
|
this.this$1 = this;
|
||
|
this.val$listener = listener;
|
||
|
}
|
||
|
|
||
|
@Override // java.lang.Runnable
|
||
|
public void run() {
|
||
|
this.val$listener.onClose(SubchannelChannel.WAIT_FOR_READY_ERROR, new Metadata());
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
return new ClientCallImpl(methodDescriptor, executor, callOptions.withOption(GrpcUtil.CALL_OPTIONS_RPC_OWNED_BY_BALANCER, Boolean.TRUE), this.transportProvider, this.deadlineCancellationExecutor, this.callsTracer, this.configSelector.get());
|
||
|
}
|
||
|
|
||
|
@Override // io.grpc.Channel
|
||
|
public final String authority() {
|
||
|
return this.subchannel.getAuthority();
|
||
|
}
|
||
|
}
|