Top Description Inners Fields Constructors Methods
io.grpc

public final Class ManagedChannelRegistry

extends Object
Class Inheritance
Annotations
@Internal
@ThreadSafe
Imports
com.google.common.annotations.VisibleForTesting, com.google.common.base.Preconditions, java.net.SocketAddress, .URI, .URISyntaxException, java.util.ArrayList, .Arrays, .Collection, .Collections, .Comparator, .LinkedHashSet, .List, java.util.logging.Level, .Logger, javax.annotation.concurrent.GuardedBy, .ThreadSafe

Registry of ManagedChannelProviders. The default instance loads providers at runtime through the Java service provider mechanism.
Since
1.32.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
public static class
ManagedChannelRegistry.ProviderNotFoundException

Thrown when no suitable ManagedChannelProvider objects can be found.

Field Summary

Modifier and TypeField and Description
private final LinkedHashSet<ManagedChannelProvider>
private List<ManagedChannelProvider>
effectiveProviders

Immutable, sorted version of allProviders.

private static ManagedChannelRegistry
private static final Logger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private synchronized void
public synchronized void
deregister(ManagedChannelProvider
the provider that was added to the register via register.
provider
)

Deregisters a provider.

public static synchronized ManagedChannelRegistry
getDefaultRegistry()

Returns the default registry that loads providers via the Java service loader mechanism.

pack-priv static List<Class<?>>
pack-priv ManagedChannelBuilder<?>
pack-priv ManagedChannelBuilder<?>
newChannelBuilder(NameResolverRegistry nameResolverRegistry, String target, ChannelCredentials creds)

pack-priv ManagedChannelProvider
pack-priv synchronized List<ManagedChannelProvider>
providers()

Returns effective providers, in priority order.

private synchronized void
public synchronized void
register(ManagedChannelProvider provider)

Register a provider.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allProvidersback to summary
private final LinkedHashSet<ManagedChannelProvider> allProviders
Annotations
@GuardedBy:this
effectiveProvidersback to summary
private List<ManagedChannelProvider> effectiveProviders

Immutable, sorted version of allProviders. Is replaced instead of mutating.

Annotations
@GuardedBy:this
instanceback to summary
private static ManagedChannelRegistry instance
loggerback to summary
private static final Logger logger

Constructor Detail

ManagedChannelRegistryback to summary
public ManagedChannelRegistry()

Method Detail

addProviderback to summary
private synchronized void addProvider(ManagedChannelProvider provider)
deregisterback to summary
public synchronized void deregister(ManagedChannelProvider provider)

Deregisters a provider. No-op if the provider is not in the registry.

Parameters
provider:ManagedChannelProvider

the provider that was added to the register via register.

getDefaultRegistryback to summary
public static synchronized ManagedChannelRegistry getDefaultRegistry()

Returns the default registry that loads providers via the Java service loader mechanism.

getHardCodedClassesback to summary
pack-priv static List<Class<?>> getHardCodedClasses()
Annotations
@VisibleForTesting
newChannelBuilderback to summary
pack-priv ManagedChannelBuilder<?> newChannelBuilder(String target, ChannelCredentials creds)
newChannelBuilderback to summary
pack-priv ManagedChannelBuilder<?> newChannelBuilder(NameResolverRegistry nameResolverRegistry, String target, ChannelCredentials creds)
Annotations
@VisibleForTesting
providerback to summary
pack-priv ManagedChannelProvider provider()
providersback to summary
pack-priv synchronized List<ManagedChannelProvider> providers()

Returns effective providers, in priority order.

Annotations
@VisibleForTesting
refreshProvidersback to summary
private synchronized void refreshProviders()
registerback to summary
public synchronized void register(ManagedChannelProvider provider)

Register a provider.

If the provider's isAvailable() returns false, this method will throw IllegalArgumentException.

Providers will be used in priority order. In case of ties, providers are used in registration order.

io.grpc back to summary

private final Class ManagedChannelRegistry.ManagedChannelPriorityAccessor

extends Object
implements ServiceProviders.PriorityAccessor<ManagedChannelProvider>
Class Inheritance
  • java.lang.Object
  • io.grpc.ManagedChannelRegistry.ManagedChannelPriorityAccessor
All Implemented Interfaces
io.grpc.ServiceProviders.PriorityAccessor

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public int
getPriority(ManagedChannelProvider provider)

Implements io.grpc.ServiceProviders.PriorityAccessor.getPriority.

A priority, from 0 to 10 that this provider should be used, taking the current environment into consideration.
public boolean
isAvailable(ManagedChannelProvider provider)

Implements io.grpc.ServiceProviders.PriorityAccessor.isAvailable.

Checks this provider is available for use, taking the current environment into consideration.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ManagedChannelPriorityAccessorback to summary
private ManagedChannelPriorityAccessor()

Method Detail

getPriorityback to summary
public int getPriority(ManagedChannelProvider provider)

Implements io.grpc.ServiceProviders.PriorityAccessor.getPriority.

Doc from io.grpc.ServiceProviders.PriorityAccessor.getPriority.

A priority, from 0 to 10 that this provider should be used, taking the current environment into consideration. 5 should be considered the default, and then tweaked based on environment detection. A priority of 0 does not imply that the provider wouldn't work; just that it should be last in line.

Annotations
@Override
isAvailableback to summary
public boolean isAvailable(ManagedChannelProvider provider)

Implements io.grpc.ServiceProviders.PriorityAccessor.isAvailable.

Doc from io.grpc.ServiceProviders.PriorityAccessor.isAvailable.

Checks this provider is available for use, taking the current environment into consideration. If false, no other methods are safe to be called.

Annotations
@Override
io.grpc back to summary

public final Class ManagedChannelRegistry.ProviderNotFoundException

extends RuntimeException
Class Inheritance

Thrown when no suitable ManagedChannelProvider objects can be found.

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
public

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.lang.RuntimeException.serialVersionUID.

Constructor Detail

ProviderNotFoundExceptionback to summary
public ProviderNotFoundException(String msg)