Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: Inline AbstractManagedChannelImplBuilder #7424

Merged
merged 2 commits into from Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view

This file was deleted.

46 changes: 23 additions & 23 deletions core/src/main/java/io/grpc/internal/ManagedChannelImpl.java
Expand Up @@ -44,6 +44,7 @@
import io.grpc.Context;
import io.grpc.DecompressorRegistry;
import io.grpc.EquivalentAddressGroup;
import io.grpc.ForwardingChannelBuilder;
import io.grpc.InternalChannelz;
import io.grpc.InternalChannelz.ChannelStats;
import io.grpc.InternalChannelz.ChannelTrace;
Expand Down Expand Up @@ -72,6 +73,8 @@
import io.grpc.SynchronizationContext.ScheduledHandle;
import io.grpc.internal.AutoConfiguredLoadBalancerFactory.AutoConfiguredLoadBalancer;
import io.grpc.internal.ClientCallImpl.ClientStreamProvider;
import io.grpc.internal.ManagedChannelImplBuilder.FixedPortProvider;
import io.grpc.internal.ManagedChannelImplBuilder.UnsupportedClientTransportFactoryBuilder;
import io.grpc.internal.ManagedChannelServiceConfig.MethodInfo;
import io.grpc.internal.RetriableStream.ChannelBufferMeter;
import io.grpc.internal.RetriableStream.Throttle;
Expand Down Expand Up @@ -574,7 +577,7 @@ ClientStream newSubstream(ClientStreamTracer.Factory tracerFactory, Metadata new
private final Rescheduler idleTimer;

ManagedChannelImpl(
AbstractManagedChannelImplBuilder<?> builder,
ManagedChannelImplBuilder builder,
ClientTransportFactory clientTransportFactory,
BackoffPolicy.Provider backoffPolicyProvider,
ObjectPool<? extends Executor> balancerRpcExecutorPool,
Expand Down Expand Up @@ -661,7 +664,7 @@ public void execute(Runnable command) {
} else {
checkArgument(
builder.idleTimeoutMillis
>= AbstractManagedChannelImplBuilder.IDLE_MODE_MIN_TIMEOUT_MILLIS,
>= ManagedChannelImplBuilder.IDLE_MODE_MIN_TIMEOUT_MILLIS,
"invalid idleTimeoutMillis %s", builder.idleTimeoutMillis);
this.idleTimeoutMillis = builder.idleTimeoutMillis;
}
Expand Down Expand Up @@ -1446,28 +1449,27 @@ public void run() {
@Override
public ManagedChannelBuilder<?> createResolvingOobChannelBuilder(String target) {
final class ResolvingOobChannelBuilder
extends AbstractManagedChannelImplBuilder<ResolvingOobChannelBuilder> {
int defaultPort = -1;
extends ForwardingChannelBuilder<ResolvingOobChannelBuilder> {
private final ManagedChannelImplBuilder managedChannelImplBuilder;

ResolvingOobChannelBuilder(String target) {
super(target);
managedChannelImplBuilder = new ManagedChannelImplBuilder(target,
new UnsupportedClientTransportFactoryBuilder(),
new FixedPortProvider(nameResolverArgs.getDefaultPort()));
managedChannelImplBuilder.executorPool = executorPool;
managedChannelImplBuilder.offloadExecutorPool = offloadExecutorHolder.pool;
}

@Override
public int getDefaultPort() {
return defaultPort;
}

@Override
protected ClientTransportFactory buildTransportFactory() {
throw new UnsupportedOperationException();
protected ManagedChannelBuilder<?> delegate() {
return managedChannelImplBuilder;
}

@Override
public ManagedChannel build() {
// TODO(creamsoup) prevent main channel to shutdown if oob channel is not terminated
return new ManagedChannelImpl(
this,
managedChannelImplBuilder,
transportFactory,
backoffPolicyProvider,
balancerRpcExecutorPool,
Expand All @@ -1479,17 +1481,15 @@ public ManagedChannel build() {

checkState(!terminated, "Channel is terminated");

ResolvingOobChannelBuilder builder = new ResolvingOobChannelBuilder(target);
builder.offloadExecutorPool = offloadExecutorHolder.pool;
builder.overrideAuthority(getAuthority());
@SuppressWarnings("deprecation")
ResolvingOobChannelBuilder unused = builder.nameResolverFactory(nameResolverFactory);
builder.executorPool = executorPool;
builder.maxTraceEvents = maxTraceEvents;
builder.proxyDetector = nameResolverArgs.getProxyDetector();
builder.defaultPort = nameResolverArgs.getDefaultPort();
builder.userAgent = userAgent;
return builder;
ResolvingOobChannelBuilder builder = new ResolvingOobChannelBuilder(target)
.nameResolverFactory(nameResolverFactory);

return builder
.overrideAuthority(getAuthority())
.maxTraceEvents(maxTraceEvents)
.proxyDetector(nameResolverArgs.getProxyDetector())
.userAgent(userAgent);
}

@Override
Expand Down