Package io.grpc.xds.client
Class XdsClientImpl
java.lang.Object
io.grpc.xds.client.XdsClient
io.grpc.xds.client.XdsClientImpl
- All Implemented Interfaces:
XdsClient.ResourceStore,XdsClient.XdsResponseHandler
@Internal
public final class XdsClientImpl
extends XdsClient
implements XdsClient.XdsResponseHandler, XdsClient.ResourceStore
XdsClient implementation.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate final classTracks a single subscribed resource.Nested classes/interfaces inherited from class io.grpc.xds.client.XdsClient
XdsClient.ProcessingTracker, XdsClient.ResourceMetadata, XdsClient.ResourceStore, XdsClient.ResourceUpdate, XdsClient.ResourceWatcher<T extends XdsClient.ResourceUpdate>, XdsClient.XdsResponseHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final io.grpc.internal.BackoffPolicy.Providerprivate final Bootstrapper.BootstrapInfostatic final intprivate booleanprivate final Map<Bootstrapper.ServerInfo, LoadStatsManager2> private final XdsLoggerprivate final io.grpc.InternalLogIdprivate final MessagePrettyPrinterprivate final Map<XdsResourceType<? extends XdsClient.ResourceUpdate>, Map<String, XdsClientImpl.ResourceSubscriber<? extends XdsClient.ResourceUpdate>>> private final Objectprivate final Map<Bootstrapper.ServerInfo, ControlPlaneClient> (package private) final Map<Bootstrapper.ServerInfo, LoadReportClient> private final com.google.common.base.Supplier<com.google.common.base.Stopwatch> private final Map<String, XdsResourceType<?>> private final io.grpc.SynchronizationContextprivate final io.grpc.internal.TimeProviderprivate final ScheduledExecutorServiceprivate final XdsTransportFactory -
Constructor Summary
ConstructorsConstructorDescriptionXdsClientImpl(XdsTransportFactory xdsTransportFactory, Bootstrapper.BootstrapInfo bootstrapInfo, ScheduledExecutorService timeService, io.grpc.internal.BackoffPolicy.Provider backoffPolicyProvider, com.google.common.base.Supplier<com.google.common.base.Stopwatch> stopwatchSupplier, io.grpc.internal.TimeProvider timeProvider, MessagePrettyPrinter messagePrinter, Object securityConfig) -
Method Summary
Modifier and TypeMethodDescriptionaddClusterDropStats(Bootstrapper.ServerInfo serverInfo, String clusterName, String edsServiceName) Adds drop stats for the specified cluster with edsServiceName by using the returned object to record dropped requests.addClusterLocalityStats(Bootstrapper.ServerInfo serverInfo, String clusterName, String edsServiceName, Locality locality) Adds load stats for the specified locality (in the specified cluster with edsServiceName) by using the returned object to record RPCs.<T extends XdsClient.ResourceUpdate>
voidcancelXdsResourceWatch(XdsResourceType<T> type, String resourceName, XdsClient.ResourceWatcher<T> watcher) Unregisters the given resource watcher.private voidReturns the config used to bootstrap this XdsClientBootstrapper.BootstrapInfo.getOrCreateControlPlaneClient(Bootstrapper.ServerInfo serverInfo) getResourceKeys(XdsResourceType<?> xdsResourceType) Returns the implementation specific security configuration used in this XdsClient.private Bootstrapper.ServerInfogetServerInfo(String resource) Returns a map of control plane server info objects to the LoadReportClients that are responsible for sending load reports to the control plane servers.getSubscribedResources(Bootstrapper.ServerInfo serverInfo, XdsResourceType<? extends XdsClient.ResourceUpdate> type) Returns the collection of resources currently subscribing to ornullif not subscribing to any resources for the given type.com.google.common.util.concurrent.ListenableFuture<Map<XdsResourceType<?>, Map<String, XdsClient.ResourceMetadata>>> Returns aListenableFutureto the snapshot of the subscribed resources as they are at the moment of the call.Map<String, XdsResourceType<?>> voidhandleResourceResponse(XdsResourceType<?> xdsResourceType, Bootstrapper.ServerInfo serverInfo, String versionInfo, List<com.google.protobuf.Any> resources, String nonce, XdsClient.ProcessingTracker processingTracker) Called when a xds response is received.private <T extends XdsClient.ResourceUpdate>
voidhandleResourceUpdate(XdsResourceType.Args args, List<com.google.protobuf.Any> resources, XdsResourceType<T> xdsResourceType, XdsClient.ProcessingTracker processingTracker) voidhandleStreamClosed(io.grpc.Status error) Called when the ADS stream is closed passively.voidhandleStreamRestarted(Bootstrapper.ServerInfo serverInfo) Called when the ADS stream has been recreated.booleanReturnstrueifXdsClient.shutdown()has been called.voidshutdown()Shutdown thisXdsClientand release resources.protected voidstartSubscriberTimersIfNeeded(Bootstrapper.ServerInfo serverInfo) For all subscriber's for the specified server, if the resource hasn't yet been resolved then start a timer for it.toString()<T extends XdsClient.ResourceUpdate>
voidwatchXdsResource(XdsResourceType<T> type, String resourceName, XdsClient.ResourceWatcher<T> watcher, Executor watcherExecutor) Registers a data watcher for the given Xds resource.Methods inherited from class io.grpc.xds.client.XdsClient
canonifyResourceName, isResourceNameValid, percentEncodePath, watchXdsResource
-
Field Details
-
INITIAL_RESOURCE_FETCH_TIMEOUT_SEC
public static final int INITIAL_RESOURCE_FETCH_TIMEOUT_SEC- See Also:
-
syncContext
private final io.grpc.SynchronizationContext syncContext -
loadStatsManagerMap
-
serverLrsClientMap
-
serverCpClientMap
-
resourceSubscribers
private final Map<XdsResourceType<? extends XdsClient.ResourceUpdate>,Map<String, resourceSubscribersXdsClientImpl.ResourceSubscriber<? extends XdsClient.ResourceUpdate>>> -
subscribedResourceTypeUrls
-
xdsTransportFactory
-
bootstrapInfo
-
timeService
-
backoffPolicyProvider
private final io.grpc.internal.BackoffPolicy.Provider backoffPolicyProvider -
stopwatchSupplier
private final com.google.common.base.Supplier<com.google.common.base.Stopwatch> stopwatchSupplier -
timeProvider
private final io.grpc.internal.TimeProvider timeProvider -
securityConfig
-
logId
private final io.grpc.InternalLogId logId -
logger
-
isShutdown
private volatile boolean isShutdown -
messagePrinter
-
-
Constructor Details
-
XdsClientImpl
public XdsClientImpl(XdsTransportFactory xdsTransportFactory, Bootstrapper.BootstrapInfo bootstrapInfo, ScheduledExecutorService timeService, io.grpc.internal.BackoffPolicy.Provider backoffPolicyProvider, com.google.common.base.Supplier<com.google.common.base.Stopwatch> stopwatchSupplier, io.grpc.internal.TimeProvider timeProvider, MessagePrettyPrinter messagePrinter, Object securityConfig)
-
-
Method Details
-
handleResourceResponse
public void handleResourceResponse(XdsResourceType<?> xdsResourceType, Bootstrapper.ServerInfo serverInfo, String versionInfo, List<com.google.protobuf.Any> resources, String nonce, XdsClient.ProcessingTracker processingTracker) Description copied from interface:XdsClient.XdsResponseHandlerCalled when a xds response is received.- Specified by:
handleResourceResponsein interfaceXdsClient.XdsResponseHandler
-
handleStreamClosed
public void handleStreamClosed(io.grpc.Status error) Description copied from interface:XdsClient.XdsResponseHandlerCalled when the ADS stream is closed passively.- Specified by:
handleStreamClosedin interfaceXdsClient.XdsResponseHandler
-
handleStreamRestarted
Description copied from interface:XdsClient.XdsResponseHandlerCalled when the ADS stream has been recreated.- Specified by:
handleStreamRestartedin interfaceXdsClient.XdsResponseHandler
-
shutdown
public void shutdown()Description copied from class:XdsClientShutdown thisXdsClientand release resources. -
isShutDown
public boolean isShutDown()Description copied from class:XdsClientReturnstrueifXdsClient.shutdown()has been called.- Overrides:
isShutDownin classXdsClient
-
getSubscribedResourceTypesWithTypeUrl
- Specified by:
getSubscribedResourceTypesWithTypeUrlin interfaceXdsClient.ResourceStore
-
getSubscribedResources
@Nullable public Collection<String> getSubscribedResources(Bootstrapper.ServerInfo serverInfo, XdsResourceType<? extends XdsClient.ResourceUpdate> type) Description copied from interface:XdsClient.ResourceStoreReturns the collection of resources currently subscribing to ornullif not subscribing to any resources for the given type.Note an empty collection indicates subscribing to resources of the given type with wildcard mode.
- Specified by:
getSubscribedResourcesin interfaceXdsClient.ResourceStore
-
getSubscribedResourcesMetadataSnapshot
public com.google.common.util.concurrent.ListenableFuture<Map<XdsResourceType<?>,Map<String, getSubscribedResourcesMetadataSnapshot()XdsClient.ResourceMetadata>>> Description copied from class:XdsClientReturns aListenableFutureto the snapshot of the subscribed resources as they are at the moment of the call.The snapshot is a map from the "resource type" to a map ("resource name": "resource metadata").
- Overrides:
getSubscribedResourcesMetadataSnapshotin classXdsClient
-
getSecurityConfig
Description copied from class:XdsClientReturns the implementation specific security configuration used in this XdsClient.- Overrides:
getSecurityConfigin classXdsClient
-
watchXdsResource
public <T extends XdsClient.ResourceUpdate> void watchXdsResource(XdsResourceType<T> type, String resourceName, XdsClient.ResourceWatcher<T> watcher, Executor watcherExecutor) Description copied from class:XdsClientRegisters a data watcher for the given Xds resource.- Overrides:
watchXdsResourcein classXdsClient
-
cancelXdsResourceWatch
public <T extends XdsClient.ResourceUpdate> void cancelXdsResourceWatch(XdsResourceType<T> type, String resourceName, XdsClient.ResourceWatcher<T> watcher) Description copied from class:XdsClientUnregisters the given resource watcher.- Overrides:
cancelXdsResourceWatchin classXdsClient
-
addClusterDropStats
public LoadStatsManager2.ClusterDropStats addClusterDropStats(Bootstrapper.ServerInfo serverInfo, String clusterName, @Nullable String edsServiceName) Description copied from class:XdsClientAdds drop stats for the specified cluster with edsServiceName by using the returned object to record dropped requests. Drop stats recorded with the returned object will be reported to the load reporting server. The returned object is reference counted and the caller should useLoadStatsManager2.ClusterDropStats.release()to release its hard reference when it is safe to stop reporting dropped RPCs for the specified cluster in the future.- Overrides:
addClusterDropStatsin classXdsClient
-
addClusterLocalityStats
public LoadStatsManager2.ClusterLocalityStats addClusterLocalityStats(Bootstrapper.ServerInfo serverInfo, String clusterName, @Nullable String edsServiceName, Locality locality) Description copied from class:XdsClientAdds load stats for the specified locality (in the specified cluster with edsServiceName) by using the returned object to record RPCs. Load stats recorded with the returned object will be reported to the load reporting server. The returned object is reference counted and the caller should useLoadStatsManager2.ClusterLocalityStats.release()to release its hard reference when it is safe to stop reporting RPC loads for the specified locality in the future.- Overrides:
addClusterLocalityStatsin classXdsClient
-
getBootstrapInfo
Description copied from class:XdsClientReturns the config used to bootstrap this XdsClientBootstrapper.BootstrapInfo.- Overrides:
getBootstrapInfoin classXdsClient
-
toString
-
startSubscriberTimersIfNeeded
Description copied from class:XdsClientFor all subscriber's for the specified server, if the resource hasn't yet been resolved then start a timer for it.- Overrides:
startSubscriberTimersIfNeededin classXdsClient
-
getResourceKeys
-
cleanUpResourceTimers
private void cleanUpResourceTimers() -
getOrCreateControlPlaneClient
-
getServerLrsClientMap
Description copied from class:XdsClientReturns a map of control plane server info objects to the LoadReportClients that are responsible for sending load reports to the control plane servers.- Overrides:
getServerLrsClientMapin classXdsClient
-
getServerInfo
-
handleResourceUpdate
private <T extends XdsClient.ResourceUpdate> void handleResourceUpdate(XdsResourceType.Args args, List<com.google.protobuf.Any> resources, XdsResourceType<T> xdsResourceType, XdsClient.ProcessingTracker processingTracker)
-