Class ManagedChannelImplBuilder
- java.lang.Object
-
- io.grpc.ManagedChannelBuilder<ManagedChannelImplBuilder>
-
- io.grpc.internal.ManagedChannelImplBuilder
-
public final class ManagedChannelImplBuilder extends ManagedChannelBuilder<ManagedChannelImplBuilder>
Default managed channel builder, for usage in Transport implementations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceManagedChannelImplBuilder.ChannelBuilderDefaultPortProviderAn interface for Transport implementors to provide a default port toNameResolverfor use in cases where the target string doesn't include a port.static interfaceManagedChannelImplBuilder.ClientTransportFactoryBuilderAn interface for Transport implementors to provide theClientTransportFactoryappropriate for the channel.private static classManagedChannelImplBuilder.DirectAddressNameResolverProviderstatic classManagedChannelImplBuilder.FixedPortProviderDefault implementation ofManagedChannelImplBuilder.ChannelBuilderDefaultPortProviderthat returns a fixed port.private static classManagedChannelImplBuilder.InterceptorFactoryWrapperprivate static classManagedChannelImplBuilder.ManagedChannelDefaultPortProvider(package private) static classManagedChannelImplBuilder.ResolvedNameResolverstatic classManagedChannelImplBuilder.UnsupportedClientTransportFactoryBuilderConvenience ClientTransportFactoryBuilder, throws UnsupportedOperationException().-
Nested classes/interfaces inherited from class io.grpc.ManagedChannelBuilder
ManagedChannelBuilder.InterceptorFactory
-
-
Field Summary
Fields Modifier and Type Field Description private booleanauthorityCheckerDisabled(package private) java.lang.StringauthorityOverride(package private) BinaryLogbinlog(package private) CallCredentialscallCredentialsprivate ManagedChannelImplBuilder.ChannelBuilderDefaultPortProviderchannelBuilderDefaultPortProvider(package private) ChannelCredentialschannelCredentials(package private) InternalChannelzchannelzprivate ManagedChannelImplBuilder.ClientTransportFactoryBuilderclientTransportFactoryBuilder(package private) CompressorRegistrycompressorRegistry(package private) DecompressorRegistrydecompressorRegistryprivate static CompressorRegistryDEFAULT_COMPRESSOR_REGISTRYprivate static DecompressorRegistryDEFAULT_DECOMPRESSOR_REGISTRYprivate static ObjectPool<? extends java.util.concurrent.Executor>DEFAULT_EXECUTOR_POOLprivate static longDEFAULT_PER_RPC_BUFFER_LIMIT_IN_BYTESprivate static longDEFAULT_RETRY_BUFFER_SIZE_IN_BYTES(package private) java.lang.StringdefaultLbPolicy(package private) java.util.Map<java.lang.String,?>defaultServiceConfigprivate static java.lang.StringDIRECT_ADDRESS_SCHEMEprivate java.net.SocketAddressdirectServerAddress(package private) ObjectPool<? extends java.util.concurrent.Executor>executorPool(package private) booleanfullStreamDecompressionprivate static java.lang.reflect.MethodGET_CLIENT_INTERCEPTOR_METHOD(package private) static longIDLE_MODE_DEFAULT_TIMEOUT_MILLISThe default idle timeout.(package private) static longIDLE_MODE_MAX_TIMEOUT_DAYSAn idle timeout larger than this would disable idle mode.(package private) static longIDLE_MODE_MIN_TIMEOUT_MILLISAn idle timeout smaller than this would be capped to it.(package private) longidleTimeoutMillisprivate java.util.List<ClientInterceptor>interceptorsprivate static java.util.logging.Loggerlog(package private) booleanlookUpServiceConfig(package private) intmaxHedgedAttempts(package private) intmaxRetryAttempts(package private) intmaxTraceEvents(package private) java.util.List<MetricSink>metricSinks(package private) NameResolverRegistrynameResolverRegistry(package private) ObjectPool<? extends java.util.concurrent.Executor>offloadExecutorPool(package private) longperRpcBufferLimit(package private) ProxyDetectorproxyDetectorprivate booleanrecordFinishedRpcsprivate booleanrecordRealTimeMetricsprivate booleanrecordRetryMetricsprivate booleanrecordStartedRpcs(package private) longretryBufferSize(package private) booleanretryEnabledprivate booleanstatsEnabled(package private) java.lang.Stringtargetprivate booleantracingEnabled(package private) java.util.List<ClientTransportFilter>transportFilters(package private) static java.util.regex.PatternURI_PATTERN(package private) java.lang.StringuserAgent
-
Constructor Summary
Constructors Constructor Description ManagedChannelImplBuilder(java.lang.String target, ChannelCredentials channelCreds, CallCredentials callCreds, ManagedChannelImplBuilder.ClientTransportFactoryBuilder clientTransportFactoryBuilder, ManagedChannelImplBuilder.ChannelBuilderDefaultPortProvider channelBuilderDefaultPortProvider)Creates a new managed channel builder with a target string, which can be either a validNameResolver-compliant URI, or an authority string.ManagedChannelImplBuilder(java.lang.String target, ManagedChannelImplBuilder.ClientTransportFactoryBuilder clientTransportFactoryBuilder, ManagedChannelImplBuilder.ChannelBuilderDefaultPortProvider channelBuilderDefaultPortProvider)Creates a new managed channel builder with a target string, which can be either a validNameResolver-compliant URI, or an authority string.ManagedChannelImplBuilder(java.net.SocketAddress directServerAddress, java.lang.String authority, ChannelCredentials channelCreds, CallCredentials callCreds, ManagedChannelImplBuilder.ClientTransportFactoryBuilder clientTransportFactoryBuilder, ManagedChannelImplBuilder.ChannelBuilderDefaultPortProvider channelBuilderDefaultPortProvider)Creates a new managed channel builder with the given server address, authority string of the channel.ManagedChannelImplBuilder(java.net.SocketAddress directServerAddress, java.lang.String authority, ManagedChannelImplBuilder.ClientTransportFactoryBuilder clientTransportFactoryBuilder, ManagedChannelImplBuilder.ChannelBuilderDefaultPortProvider channelBuilderDefaultPortProvider)Creates a new managed channel builder with the given server address, authority string of the channel.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected ManagedChannelImplBuilderaddMetricSink(MetricSink metricSink)Adds aMetricSinkfor channel to use for configuring and recording metrics.ManagedChannelImplBuilderaddTransportFilter(ClientTransportFilter hook)Adds aClientTransportFilter.ManagedChannelbuild()Builds a channel using the given parameters.(package private) java.lang.StringcheckAuthority(java.lang.String authority)Verifies the authority is valid.private static java.util.List<?>checkListEntryTypes(java.util.List<?> list)private static java.util.Map<java.lang.String,?>checkMapEntryTypes(java.util.Map<?,?> map)ManagedChannelImplBuildercompressorRegistry(CompressorRegistry registry)Set the compression registry for use in the channel.ManagedChannelImplBuilderdecompressorRegistry(DecompressorRegistry registry)Set the decompression registry for use in the channel.ManagedChannelImplBuilderdefaultLoadBalancingPolicy(java.lang.String policy)Sets the default load-balancing policy that will be used if the service config doesn't specify one.ManagedChannelImplBuilderdefaultServiceConfig(java.util.Map<java.lang.String,?> serviceConfig)Provides a service config to the channel.ManagedChannelImplBuilderdirectExecutor()Execute application code directly in the transport thread.ManagedChannelImplBuilderdisableCheckAuthority()Disable the check whether the authority is valid.ManagedChannelImplBuilderdisableRetry()Disables the retry and hedging subsystem provided by the gRPC library.ManagedChannelImplBuilderdisableServiceConfigLookUp()Disables service config look-up from the naming system, which is enabled by default.ManagedChannelImplBuilderenableCheckAuthority()Enable previously disabled authority check.ManagedChannelImplBuilderenableRetry()Enables the retry and hedging subsystem which will use per-method configuration.ManagedChannelImplBuilderexecutor(java.util.concurrent.Executor executor)Provides a custom executor.static ManagedChannelBuilder<?>forAddress(java.lang.String name, int port)static ManagedChannelBuilder<?>forTarget(java.lang.String target)(package private) intgetDefaultPort()Returns a default port toNameResolverfor use in cases where the target string doesn't include a port.(package private) java.util.List<ClientInterceptor>getEffectiveInterceptors(java.lang.String computedTarget)(package private) static ManagedChannelImplBuilder.ResolvedNameResolvergetNameResolverProvider(java.lang.String target, NameResolverRegistry nameResolverRegistry, java.util.Collection<java.lang.Class<? extends java.net.SocketAddress>> channelTransportSocketAddressTypes)ObjectPool<? extends java.util.concurrent.Executor>getOffloadExecutorPool()Returns the internal offload executor pool for offloading tasks.ManagedChannelImplBuilderidleTimeout(long value, java.util.concurrent.TimeUnit unit)Set the duration without ongoing RPCs before going to idle mode.ManagedChannelImplBuilderintercept(ClientInterceptor... interceptors)Adds interceptors that will be called before the channel performs its real work.ManagedChannelImplBuilderintercept(java.util.List<ClientInterceptor> interceptors)Adds interceptors that will be called before the channel performs its real work.protected ManagedChannelImplBuilderinterceptWithTarget(ManagedChannelBuilder.InterceptorFactory factory)Internal-only: Adds a factory that will construct an interceptor based on the channel's target.(package private) static java.lang.StringmakeTargetStringForDirectAddress(java.net.SocketAddress address)Returns a target string for the SocketAddress.ManagedChannelImplBuildermaxHedgedAttempts(int maxHedgedAttempts)Sets the maximum number of hedged attempts that may be configured by the service config.ManagedChannelImplBuildermaxRetryAttempts(int maxRetryAttempts)Sets the maximum number of retry attempts that may be configured by the service config.ManagedChannelImplBuildermaxTraceEvents(int maxTraceEvents)Sets the maximum number of channel trace events to keep in the tracer for each channel or subchannel.ManagedChannelImplBuildernameResolverFactory(NameResolver.Factory resolverFactory)Deprecated.(package private) ManagedChannelImplBuildernameResolverRegistry(NameResolverRegistry resolverRegistry)ManagedChannelImplBuilderoffloadExecutor(java.util.concurrent.Executor executor)Provides a custom executor that will be used for operations that block or are expensive, to avoid blocking asynchronous code paths.ManagedChannelImplBuilderoverrideAuthority(java.lang.String authority)Overrides the authority used with TLS and HTTP virtual hosting.ManagedChannelImplBuilderperRpcBufferLimit(long bytes)Sets the per RPC buffer limit in bytes used for retry.ManagedChannelImplBuilderproxyDetector(ProxyDetector proxyDetector)Sets the proxy detector to be used in addresses name resolution.ManagedChannelImplBuilderretryBufferSize(long bytes)Sets the retry buffer size in bytes.ManagedChannelImplBuildersetBinaryLog(BinaryLog binlog)Sets the BinaryLog object that this channel should log to.voidsetStatsEnabled(boolean value)Disable or enable stats features.voidsetStatsRecordFinishedRpcs(boolean value)Disable or enable stats recording for RPC completions.voidsetStatsRecordRealTimeMetrics(boolean value)Disable or enable real-time metrics recording.voidsetStatsRecordRetryMetrics(boolean value)voidsetStatsRecordStartedRpcs(boolean value)Disable or enable stats recording for RPC upstarts.voidsetTracingEnabled(boolean value)Disable or enable tracing features.ManagedChannelImplBuilderuserAgent(java.lang.String userAgent)Provides a customUser-Agentfor the application.-
Methods inherited from class io.grpc.ManagedChannelBuilder
keepAliveTime, keepAliveTimeout, keepAliveWithoutCalls, maxInboundMessageSize, maxInboundMetadataSize, usePlaintext, useTransportSecurity
-
-
-
-
Field Detail
-
DIRECT_ADDRESS_SCHEME
private static final java.lang.String DIRECT_ADDRESS_SCHEME
- See Also:
- Constant Field Values
-
log
private static final java.util.logging.Logger log
-
IDLE_MODE_MAX_TIMEOUT_DAYS
static final long IDLE_MODE_MAX_TIMEOUT_DAYS
An idle timeout larger than this would disable idle mode.- See Also:
- Constant Field Values
-
IDLE_MODE_DEFAULT_TIMEOUT_MILLIS
static final long IDLE_MODE_DEFAULT_TIMEOUT_MILLIS
The default idle timeout.
-
IDLE_MODE_MIN_TIMEOUT_MILLIS
static final long IDLE_MODE_MIN_TIMEOUT_MILLIS
An idle timeout smaller than this would be capped to it.
-
DEFAULT_EXECUTOR_POOL
private static final ObjectPool<? extends java.util.concurrent.Executor> DEFAULT_EXECUTOR_POOL
-
DEFAULT_DECOMPRESSOR_REGISTRY
private static final DecompressorRegistry DEFAULT_DECOMPRESSOR_REGISTRY
-
DEFAULT_COMPRESSOR_REGISTRY
private static final CompressorRegistry DEFAULT_COMPRESSOR_REGISTRY
-
DEFAULT_RETRY_BUFFER_SIZE_IN_BYTES
private static final long DEFAULT_RETRY_BUFFER_SIZE_IN_BYTES
- See Also:
- Constant Field Values
-
DEFAULT_PER_RPC_BUFFER_LIMIT_IN_BYTES
private static final long DEFAULT_PER_RPC_BUFFER_LIMIT_IN_BYTES
- See Also:
- Constant Field Values
-
URI_PATTERN
static final java.util.regex.Pattern URI_PATTERN
-
GET_CLIENT_INTERCEPTOR_METHOD
private static final java.lang.reflect.Method GET_CLIENT_INTERCEPTOR_METHOD
-
executorPool
ObjectPool<? extends java.util.concurrent.Executor> executorPool
-
offloadExecutorPool
ObjectPool<? extends java.util.concurrent.Executor> offloadExecutorPool
-
interceptors
private final java.util.List<ClientInterceptor> interceptors
-
nameResolverRegistry
NameResolverRegistry nameResolverRegistry
-
transportFilters
final java.util.List<ClientTransportFilter> transportFilters
-
target
final java.lang.String target
-
channelCredentials
@Nullable final ChannelCredentials channelCredentials
-
callCredentials
@Nullable final CallCredentials callCredentials
-
directServerAddress
@Nullable private final java.net.SocketAddress directServerAddress
-
userAgent
@Nullable java.lang.String userAgent
-
authorityOverride
@Nullable java.lang.String authorityOverride
-
defaultLbPolicy
java.lang.String defaultLbPolicy
-
fullStreamDecompression
boolean fullStreamDecompression
-
decompressorRegistry
DecompressorRegistry decompressorRegistry
-
compressorRegistry
CompressorRegistry compressorRegistry
-
idleTimeoutMillis
long idleTimeoutMillis
-
maxRetryAttempts
int maxRetryAttempts
-
maxHedgedAttempts
int maxHedgedAttempts
-
retryBufferSize
long retryBufferSize
-
perRpcBufferLimit
long perRpcBufferLimit
-
retryEnabled
boolean retryEnabled
-
channelz
InternalChannelz channelz
-
maxTraceEvents
int maxTraceEvents
-
defaultServiceConfig
@Nullable java.util.Map<java.lang.String,?> defaultServiceConfig
-
lookUpServiceConfig
boolean lookUpServiceConfig
-
binlog
@Nullable BinaryLog binlog
-
proxyDetector
@Nullable ProxyDetector proxyDetector
-
authorityCheckerDisabled
private boolean authorityCheckerDisabled
-
statsEnabled
private boolean statsEnabled
-
recordStartedRpcs
private boolean recordStartedRpcs
-
recordFinishedRpcs
private boolean recordFinishedRpcs
-
recordRealTimeMetrics
private boolean recordRealTimeMetrics
-
recordRetryMetrics
private boolean recordRetryMetrics
-
tracingEnabled
private boolean tracingEnabled
-
metricSinks
java.util.List<MetricSink> metricSinks
-
clientTransportFactoryBuilder
private final ManagedChannelImplBuilder.ClientTransportFactoryBuilder clientTransportFactoryBuilder
-
channelBuilderDefaultPortProvider
private final ManagedChannelImplBuilder.ChannelBuilderDefaultPortProvider channelBuilderDefaultPortProvider
-
-
Constructor Detail
-
ManagedChannelImplBuilder
public ManagedChannelImplBuilder(java.lang.String target, ManagedChannelImplBuilder.ClientTransportFactoryBuilder clientTransportFactoryBuilder, @Nullable ManagedChannelImplBuilder.ChannelBuilderDefaultPortProvider channelBuilderDefaultPortProvider)Creates a new managed channel builder with a target string, which can be either a validNameResolver-compliant URI, or an authority string. Transport implementors must provide client transport factory builder, and may set custom channel default port provider.
-
ManagedChannelImplBuilder
public ManagedChannelImplBuilder(java.lang.String target, @Nullable ChannelCredentials channelCreds, @Nullable CallCredentials callCreds, ManagedChannelImplBuilder.ClientTransportFactoryBuilder clientTransportFactoryBuilder, @Nullable ManagedChannelImplBuilder.ChannelBuilderDefaultPortProvider channelBuilderDefaultPortProvider)Creates a new managed channel builder with a target string, which can be either a validNameResolver-compliant URI, or an authority string. Transport implementors must provide client transport factory builder, and may set custom channel default port provider.- Parameters:
channelCreds- The ChannelCredentials provided by the user. These may be used when creating derivative channels.
-
ManagedChannelImplBuilder
public ManagedChannelImplBuilder(java.net.SocketAddress directServerAddress, java.lang.String authority, ManagedChannelImplBuilder.ClientTransportFactoryBuilder clientTransportFactoryBuilder, @Nullable ManagedChannelImplBuilder.ChannelBuilderDefaultPortProvider channelBuilderDefaultPortProvider)Creates a new managed channel builder with the given server address, authority string of the channel. Transport implementors must provide client transport factory builder, and may set custom channel default port provider.
-
ManagedChannelImplBuilder
public ManagedChannelImplBuilder(java.net.SocketAddress directServerAddress, java.lang.String authority, @Nullable ChannelCredentials channelCreds, @Nullable CallCredentials callCreds, ManagedChannelImplBuilder.ClientTransportFactoryBuilder clientTransportFactoryBuilder, @Nullable ManagedChannelImplBuilder.ChannelBuilderDefaultPortProvider channelBuilderDefaultPortProvider)Creates a new managed channel builder with the given server address, authority string of the channel. Transport implementors must provide client transport factory builder, and may set custom channel default port provider.- Parameters:
channelCreds- The ChannelCredentials provided by the user. These may be used when creating derivative channels.
-
-
Method Detail
-
forAddress
public static ManagedChannelBuilder<?> forAddress(java.lang.String name, int port)
-
forTarget
public static ManagedChannelBuilder<?> forTarget(java.lang.String target)
-
makeTargetStringForDirectAddress
static java.lang.String makeTargetStringForDirectAddress(java.net.SocketAddress address)
Returns a target string for the SocketAddress. It is only used as a placeholder, because DirectAddressNameResolverProvider will not actually try to use it. However, it must be a valid URI.
-
directExecutor
public ManagedChannelImplBuilder directExecutor()
Description copied from class:ManagedChannelBuilderExecute application code directly in the transport thread.Depending on the underlying transport, using a direct executor may lead to substantial performance improvements. However, it also requires the application to not block under any circumstances.
Calling this method is semantically equivalent to calling
ManagedChannelBuilder.executor(Executor)and passing in a direct executor. However, this is the preferred way as it may allow the transport to perform special optimizations.- Specified by:
directExecutorin classManagedChannelBuilder<ManagedChannelImplBuilder>- Returns:
- this
-
executor
public ManagedChannelImplBuilder executor(java.util.concurrent.Executor executor)
Description copied from class:ManagedChannelBuilderProvides a custom executor.It's an optional parameter. If the user has not provided an executor when the channel is built, the builder will use a static cached thread pool.
The channel won't take ownership of the given executor. It's caller's responsibility to shut down the executor when it's desired.
- Specified by:
executorin classManagedChannelBuilder<ManagedChannelImplBuilder>- Returns:
- this
-
offloadExecutor
public ManagedChannelImplBuilder offloadExecutor(java.util.concurrent.Executor executor)
Description copied from class:ManagedChannelBuilderProvides a custom executor that will be used for operations that block or are expensive, to avoid blocking asynchronous code paths. For example, DNS queries and OAuth token fetching over HTTP could use this executor.It's an optional parameter. If the user has not provided an executor when the channel is built, the builder will use a static cached thread pool.
The channel won't take ownership of the given executor. It's caller's responsibility to shut down the executor when it's desired.
- Overrides:
offloadExecutorin classManagedChannelBuilder<ManagedChannelImplBuilder>- Returns:
- this
-
intercept
public ManagedChannelImplBuilder intercept(java.util.List<ClientInterceptor> interceptors)
Description copied from class:ManagedChannelBuilderAdds interceptors that will be called before the channel performs its real work. This is functionally equivalent to usingClientInterceptors.intercept(Channel, List), but while still having access to the originalManagedChannel. Interceptors run in the reverse order in which they are added, just as with consecutive calls toClientInterceptors.intercept().- Specified by:
interceptin classManagedChannelBuilder<ManagedChannelImplBuilder>- Returns:
- this
-
intercept
public ManagedChannelImplBuilder intercept(ClientInterceptor... interceptors)
Description copied from class:ManagedChannelBuilderAdds interceptors that will be called before the channel performs its real work. This is functionally equivalent to usingClientInterceptors.intercept(Channel, ClientInterceptor...), but while still having access to the originalManagedChannel. Interceptors run in the reverse order in which they are added, just as with consecutive calls toClientInterceptors.intercept().- Specified by:
interceptin classManagedChannelBuilder<ManagedChannelImplBuilder>- Returns:
- this
-
interceptWithTarget
protected ManagedChannelImplBuilder interceptWithTarget(ManagedChannelBuilder.InterceptorFactory factory)
Description copied from class:ManagedChannelBuilderInternal-only: Adds a factory that will construct an interceptor based on the channel's target. This can be used to work around nameResolverFactory() changing the target string.- Overrides:
interceptWithTargetin classManagedChannelBuilder<ManagedChannelImplBuilder>
-
addTransportFilter
public ManagedChannelImplBuilder addTransportFilter(ClientTransportFilter hook)
Description copied from class:ManagedChannelBuilderAdds aClientTransportFilter. The order of filters being added is the order they will be executed- Overrides:
addTransportFilterin classManagedChannelBuilder<ManagedChannelImplBuilder>- Returns:
- this
-
nameResolverFactory
@Deprecated public ManagedChannelImplBuilder nameResolverFactory(NameResolver.Factory resolverFactory)
Deprecated.Description copied from class:ManagedChannelBuilderProvides a customNameResolver.Factoryfor the channel. If this method is not called, the builder will try the providers registered in the defaultNameResolverRegistryfor the given target.This method should rarely be used, as name resolvers should provide a
NameResolverProviderand users rely on service loading to find implementations in the class path. That allows application's configuration to easily choose the name resolver via the 'target' string passed toManagedChannelBuilder.forTarget(String).- Specified by:
nameResolverFactoryin classManagedChannelBuilder<ManagedChannelImplBuilder>- Returns:
- this
-
nameResolverRegistry
ManagedChannelImplBuilder nameResolverRegistry(NameResolverRegistry resolverRegistry)
-
defaultLoadBalancingPolicy
public ManagedChannelImplBuilder defaultLoadBalancingPolicy(java.lang.String policy)
Description copied from class:ManagedChannelBuilderSets the default load-balancing policy that will be used if the service config doesn't specify one. If not set, the default will be the "pick_first" policy.Policy implementations are looked up in the
default LoadBalancerRegistry.This method is implemented by all stock channel builders that are shipped with gRPC, but may not be implemented by custom channel builders, in which case this method will throw.
- Overrides:
defaultLoadBalancingPolicyin classManagedChannelBuilder<ManagedChannelImplBuilder>- Returns:
- this
-
decompressorRegistry
public ManagedChannelImplBuilder decompressorRegistry(DecompressorRegistry registry)
Description copied from class:ManagedChannelBuilderSet the decompression registry for use in the channel. This is an advanced API call and shouldn't be used unless you are using custom message encoding. The default supported decompressors are inDecompressorRegistry.getDefaultInstance().- Specified by:
decompressorRegistryin classManagedChannelBuilder<ManagedChannelImplBuilder>- Returns:
- this
-
compressorRegistry
public ManagedChannelImplBuilder compressorRegistry(CompressorRegistry registry)
Description copied from class:ManagedChannelBuilderSet the compression registry for use in the channel. This is an advanced API call and shouldn't be used unless you are using custom message encoding. The default supported compressors are inCompressorRegistry.getDefaultInstance().- Specified by:
compressorRegistryin classManagedChannelBuilder<ManagedChannelImplBuilder>- Returns:
- this
-
userAgent
public ManagedChannelImplBuilder userAgent(@Nullable java.lang.String userAgent)
Description copied from class:ManagedChannelBuilderProvides a customUser-Agentfor the application.It's an optional parameter. The library will provide a user agent independent of this option. If provided, the given agent will prepend the library's user agent information.
- Specified by:
userAgentin classManagedChannelBuilder<ManagedChannelImplBuilder>- Returns:
- this
-
overrideAuthority
public ManagedChannelImplBuilder overrideAuthority(java.lang.String authority)
Description copied from class:ManagedChannelBuilderOverrides the authority used with TLS and HTTP virtual hosting. It does not change what host is actually connected to. Is commonly in the formhost:port.If the channel builder overrides authority, any authority override from name resolution result (via
EquivalentAddressGroup.ATTR_AUTHORITY_OVERRIDE) will be discarded.This method is intended for testing, but may safely be used outside of tests as an alternative to DNS overrides.
- Specified by:
overrideAuthorityin classManagedChannelBuilder<ManagedChannelImplBuilder>- Returns:
- this
-
idleTimeout
public ManagedChannelImplBuilder idleTimeout(long value, java.util.concurrent.TimeUnit unit)
Description copied from class:ManagedChannelBuilderSet the duration without ongoing RPCs before going to idle mode.In idle mode the channel shuts down all connections, the NameResolver and the LoadBalancer. A new RPC would take the channel out of idle mode. A channel starts in idle mode. Defaults to 30 minutes.
This is an advisory option. Do not rely on any specific behavior related to this option.
- Specified by:
idleTimeoutin classManagedChannelBuilder<ManagedChannelImplBuilder>- Returns:
- this
-
maxRetryAttempts
public ManagedChannelImplBuilder maxRetryAttempts(int maxRetryAttempts)
Description copied from class:ManagedChannelBuilderSets the maximum number of retry attempts that may be configured by the service config. If the service config specifies a larger value it will be reduced to this value. Setting this number to zero is not effectively the same asdisableRetry()because the former does not disable transparent retry.This method may not work as expected for the current release because retry is not fully implemented yet.
- Overrides:
maxRetryAttemptsin classManagedChannelBuilder<ManagedChannelImplBuilder>- Returns:
- this
-
maxHedgedAttempts
public ManagedChannelImplBuilder maxHedgedAttempts(int maxHedgedAttempts)
Description copied from class:ManagedChannelBuilderSets the maximum number of hedged attempts that may be configured by the service config. If the service config specifies a larger value it will be reduced to this value.This method may not work as expected for the current release because retry is not fully implemented yet.
- Overrides:
maxHedgedAttemptsin classManagedChannelBuilder<ManagedChannelImplBuilder>- Returns:
- this
-
retryBufferSize
public ManagedChannelImplBuilder retryBufferSize(long bytes)
Description copied from class:ManagedChannelBuilderSets the retry buffer size in bytes. If the buffer limit is exceeded, no RPC could retry at the moment, and in hedging case all hedges but one of the same RPC will cancel. The implementation may only estimate the buffer size being used rather than count the exact physical memory allocated. The method does not have any effect if retry is disabled by the client.This method may not work as expected for the current release because retry is not fully implemented yet.
- Overrides:
retryBufferSizein classManagedChannelBuilder<ManagedChannelImplBuilder>- Returns:
- this
-
perRpcBufferLimit
public ManagedChannelImplBuilder perRpcBufferLimit(long bytes)
Description copied from class:ManagedChannelBuilderSets the per RPC buffer limit in bytes used for retry. The RPC is not retriable if its buffer limit is exceeded. The implementation may only estimate the buffer size being used rather than count the exact physical memory allocated. It does not have any effect if retry is disabled by the client.This method may not work as expected for the current release because retry is not fully implemented yet.
- Overrides:
perRpcBufferLimitin classManagedChannelBuilder<ManagedChannelImplBuilder>- Returns:
- this
-
disableRetry
public ManagedChannelImplBuilder disableRetry()
Description copied from class:ManagedChannelBuilderDisables the retry and hedging subsystem provided by the gRPC library. This is designed for the case when users have their own retry implementation and want to avoid their own retry taking place simultaneously with the gRPC library layer retry.- Overrides:
disableRetryin classManagedChannelBuilder<ManagedChannelImplBuilder>- Returns:
- this
-
enableRetry
public ManagedChannelImplBuilder enableRetry()
Description copied from class:ManagedChannelBuilderEnables the retry and hedging subsystem which will use per-method configuration. If a method is unconfigured, it will be limited to transparent retries, which are safe for non-idempotent RPCs. Service config is ideally provided by the name resolver, but may also be specified viaManagedChannelBuilder.defaultServiceConfig(java.util.Map<java.lang.String, ?>).- Overrides:
enableRetryin classManagedChannelBuilder<ManagedChannelImplBuilder>- Returns:
- this
-
setBinaryLog
public ManagedChannelImplBuilder setBinaryLog(BinaryLog binlog)
Description copied from class:ManagedChannelBuilderSets the BinaryLog object that this channel should log to. The channel does not take ownership of the object, and users are responsible for callingCloseable.close().- Overrides:
setBinaryLogin classManagedChannelBuilder<ManagedChannelImplBuilder>- Parameters:
binlog- the object to provide logging.- Returns:
- this
-
maxTraceEvents
public ManagedChannelImplBuilder maxTraceEvents(int maxTraceEvents)
Description copied from class:ManagedChannelBuilderSets the maximum number of channel trace events to keep in the tracer for each channel or subchannel. If set to 0, channel tracing is effectively disabled.- Overrides:
maxTraceEventsin classManagedChannelBuilder<ManagedChannelImplBuilder>- Returns:
- this
-
proxyDetector
public ManagedChannelImplBuilder proxyDetector(@Nullable ProxyDetector proxyDetector)
Description copied from class:ManagedChannelBuilderSets the proxy detector to be used in addresses name resolution. Ifnullis passed the default proxy detector will be used. For how proxies work in gRPC, please refer to the documentation onProxyDetector.- Overrides:
proxyDetectorin classManagedChannelBuilder<ManagedChannelImplBuilder>- Returns:
- this
-
defaultServiceConfig
public ManagedChannelImplBuilder defaultServiceConfig(@Nullable java.util.Map<java.lang.String,?> serviceConfig)
Description copied from class:ManagedChannelBuilderProvides a service config to the channel. The channel will use the default service config when the name resolver provides no service config or if the channel disables lookup service config from name resolver (seeManagedChannelBuilder.disableServiceConfigLookUp()). The argumentserviceConfigis a nested map representing a Json object in the most natural way:Json entry Java Type object Maparray Liststring Stringnumber Doubleboolean Booleannull nullIf null is passed, then there will be no default service config.
Your preferred JSON parser may not produce results in the format expected. For such cases, you can convert its output. For example, if your parser produces Integers and other Numbers in addition to Double:
@SuppressWarnings("unchecked") private static Object convertNumbers(Object o) { if (o instanceof Map) { ((Map) o).replaceAll((k,v) -> convertNumbers(v)); } else if (o instanceof List) { ((List) o).replaceAll(YourClass::convertNumbers); } else if (o instanceof Number && !(o instanceof Double)) { o = ((Number) o).doubleValue(); } return o; }- Overrides:
defaultServiceConfigin classManagedChannelBuilder<ManagedChannelImplBuilder>- Returns:
- this
-
checkMapEntryTypes
@Nullable private static java.util.Map<java.lang.String,?> checkMapEntryTypes(@Nullable java.util.Map<?,?> map)
-
checkListEntryTypes
private static java.util.List<?> checkListEntryTypes(java.util.List<?> list)
-
disableServiceConfigLookUp
public ManagedChannelImplBuilder disableServiceConfigLookUp()
Description copied from class:ManagedChannelBuilderDisables service config look-up from the naming system, which is enabled by default.- Overrides:
disableServiceConfigLookUpin classManagedChannelBuilder<ManagedChannelImplBuilder>- Returns:
- this
-
setStatsEnabled
public void setStatsEnabled(boolean value)
Disable or enable stats features. Enabled by default.For the current release, calling
setStatsEnabled(true)may have a side effect that disables retry.
-
setStatsRecordStartedRpcs
public void setStatsRecordStartedRpcs(boolean value)
Disable or enable stats recording for RPC upstarts. Effective only ifsetStatsEnabled(boolean)is set to true. Enabled by default.
-
setStatsRecordFinishedRpcs
public void setStatsRecordFinishedRpcs(boolean value)
Disable or enable stats recording for RPC completions. Effective only ifsetStatsEnabled(boolean)is set to true. Enabled by default.
-
setStatsRecordRealTimeMetrics
public void setStatsRecordRealTimeMetrics(boolean value)
Disable or enable real-time metrics recording. Effective only ifsetStatsEnabled(boolean)is set to true. Disabled by default.
-
setStatsRecordRetryMetrics
public void setStatsRecordRetryMetrics(boolean value)
-
setTracingEnabled
public void setTracingEnabled(boolean value)
Disable or enable tracing features. Enabled by default.
-
checkAuthority
java.lang.String checkAuthority(java.lang.String authority)
Verifies the authority is valid.
-
disableCheckAuthority
public ManagedChannelImplBuilder disableCheckAuthority()
Disable the check whether the authority is valid.
-
enableCheckAuthority
public ManagedChannelImplBuilder enableCheckAuthority()
Enable previously disabled authority check.
-
addMetricSink
protected ManagedChannelImplBuilder addMetricSink(MetricSink metricSink)
Description copied from class:ManagedChannelBuilderAdds aMetricSinkfor channel to use for configuring and recording metrics.- Overrides:
addMetricSinkin classManagedChannelBuilder<ManagedChannelImplBuilder>- Returns:
- this
-
build
public ManagedChannel build()
Description copied from class:ManagedChannelBuilderBuilds a channel using the given parameters.- Specified by:
buildin classManagedChannelBuilder<ManagedChannelImplBuilder>
-
getEffectiveInterceptors
java.util.List<ClientInterceptor> getEffectiveInterceptors(java.lang.String computedTarget)
-
getDefaultPort
int getDefaultPort()
Returns a default port toNameResolverfor use in cases where the target string doesn't include a port. The default implementation returnsGrpcUtil.DEFAULT_PORT_SSL.
-
getNameResolverProvider
static ManagedChannelImplBuilder.ResolvedNameResolver getNameResolverProvider(java.lang.String target, NameResolverRegistry nameResolverRegistry, java.util.Collection<java.lang.Class<? extends java.net.SocketAddress>> channelTransportSocketAddressTypes)
-
getOffloadExecutorPool
public ObjectPool<? extends java.util.concurrent.Executor> getOffloadExecutorPool()
Returns the internal offload executor pool for offloading tasks.
-
-