Package io.grpc.xds

Class XdsNameResolver


  • final class XdsNameResolver
    extends io.grpc.NameResolver
    A NameResolver for resolving gRPC target names with "xds:" scheme.

    Resolving a gRPC target involves contacting the control plane management server via xDS protocol to retrieve service information and produce a service config to the caller.

    See Also:
    XdsNameResolverProvider
    • Field Detail

      • CLUSTER_SELECTION_KEY

        static final io.grpc.CallOptions.Key<java.lang.String> CLUSTER_SELECTION_KEY
      • RPC_HASH_KEY

        static final io.grpc.CallOptions.Key<java.lang.Long> RPC_HASH_KEY
      • enableTimeout

        static boolean enableTimeout
      • logId

        private final io.grpc.InternalLogId logId
      • targetAuthority

        @Nullable
        private final java.lang.String targetAuthority
      • target

        private final java.lang.String target
      • serviceAuthority

        private final java.lang.String serviceAuthority
      • encodedServiceAuthority

        private final java.lang.String encodedServiceAuthority
      • overrideAuthority

        private final java.lang.String overrideAuthority
      • serviceConfigParser

        private final io.grpc.NameResolver.ServiceConfigParser serviceConfigParser
      • syncContext

        private final io.grpc.SynchronizationContext syncContext
      • scheduler

        private final java.util.concurrent.ScheduledExecutorService scheduler
      • hashFunc

        private final XxHash64 hashFunc
      • randomChannelId

        private final long randomChannelId
      • listener

        private io.grpc.NameResolver.Listener2 listener
      • xdsClientPool

        private io.grpc.internal.ObjectPool<XdsClient> xdsClientPool
      • receivedConfig

        private boolean receivedConfig
    • Constructor Detail

      • XdsNameResolver

        XdsNameResolver​(java.net.URI targetUri,
                        java.lang.String name,
                        @Nullable
                        java.lang.String overrideAuthority,
                        io.grpc.NameResolver.ServiceConfigParser serviceConfigParser,
                        io.grpc.SynchronizationContext syncContext,
                        java.util.concurrent.ScheduledExecutorService scheduler,
                        @Nullable
                        java.util.Map<java.lang.String,​?> bootstrapOverride)
      • XdsNameResolver

        XdsNameResolver​(java.net.URI targetUri,
                        @Nullable
                        java.lang.String targetAuthority,
                        java.lang.String name,
                        @Nullable
                        java.lang.String overrideAuthority,
                        io.grpc.NameResolver.ServiceConfigParser serviceConfigParser,
                        io.grpc.SynchronizationContext syncContext,
                        java.util.concurrent.ScheduledExecutorService scheduler,
                        XdsClientPoolFactory xdsClientPoolFactory,
                        ThreadSafeRandom random,
                        FilterRegistry filterRegistry,
                        @Nullable
                        java.util.Map<java.lang.String,​?> bootstrapOverride)
    • Method Detail

      • getServiceAuthority

        public java.lang.String getServiceAuthority()
        Specified by:
        getServiceAuthority in class io.grpc.NameResolver
      • start

        public void start​(io.grpc.NameResolver.Listener2 listener)
        Overrides:
        start in class io.grpc.NameResolver
      • expandPercentS

        private static java.lang.String expandPercentS​(java.lang.String template,
                                                       java.lang.String replacement)
      • shutdown

        public void shutdown()
        Specified by:
        shutdown in class io.grpc.NameResolver
      • generateServiceConfigWithMethodConfig

        static java.util.Map<java.lang.String,​?> generateServiceConfigWithMethodConfig​(@Nullable
                                                                                             java.lang.Long timeoutNano,
                                                                                             @Nullable
                                                                                             VirtualHost.Route.RouteAction.RetryPolicy retryPolicy)
      • updateResolutionResult

        private void updateResolutionResult()
      • matchHostName

        static boolean matchHostName​(java.lang.String hostName,
                                     java.lang.String pattern)
        Returns true iff hostName matches the domain name pattern with case-insensitive.

        Wildcard pattern rules:

        1. A single asterisk (*) matches any domain.
        2. Asterisk (*) is only permitted in the left-most or the right-most part of the pattern, but not both.
      • combineInterceptors

        private static io.grpc.ClientInterceptor combineInterceptors​(java.util.List<io.grpc.ClientInterceptor> interceptors)
      • getHeaderValue

        @Nullable
        private static java.lang.String getHeaderValue​(io.grpc.Metadata headers,
                                                       java.lang.String headerName)
      • prefixedClusterName

        private static java.lang.String prefixedClusterName​(java.lang.String name)
      • prefixedClusterSpecifierPluginName

        private static java.lang.String prefixedClusterSpecifierPluginName​(java.lang.String pluginName)