Package io.grpc.xds.client
Class XdsClient
- java.lang.Object
-
- io.grpc.xds.client.XdsClient
-
- Direct Known Subclasses:
XdsClientImpl
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/10862") public abstract class XdsClient extends java.lang.Object
AnXdsClient
instance encapsulates all of the logic for communicating with the xDS server. It may create multiple RPC streams (or a single ADS stream) for a series of xDS protocols (e.g., LDS, RDS, VHDS, CDS and EDS) over a single channel. Watch-based interfaces are provided for each set of data needed by gRPC.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
XdsClient.ProcessingTracker
static class
XdsClient.ResourceMetadata
The metadata of the xDS resource; used by the xDS config dump.static interface
XdsClient.ResourceStore
static interface
XdsClient.ResourceUpdate
static interface
XdsClient.ResourceWatcher<T extends XdsClient.ResourceUpdate>
Watcher interface for a single requested xDS resource.(package private) static interface
XdsClient.XdsResponseHandler
-
Constructor Summary
Constructors Constructor Description XdsClient()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description LoadStatsManager2.ClusterDropStats
addClusterDropStats(Bootstrapper.ServerInfo serverInfo, java.lang.String clusterName, java.lang.String edsServiceName)
Adds drop stats for the specified cluster with edsServiceName by using the returned object to record dropped requests.LoadStatsManager2.ClusterLocalityStats
addClusterLocalityStats(Bootstrapper.ServerInfo serverInfo, java.lang.String clusterName, java.lang.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, java.lang.String resourceName, XdsClient.ResourceWatcher<T> watcher)
Unregisters the given resource watcher.static java.lang.String
canonifyResourceName(java.lang.String resourceName)
Bootstrapper.BootstrapInfo
getBootstrapInfo()
Returns the config used to bootstrap this XdsClientBootstrapper.BootstrapInfo
.java.lang.Object
getSecurityConfig()
Returns the implementation specific security configuration used in this XdsClient.java.util.Map<Bootstrapper.ServerInfo,LoadReportClient>
getServerLrsClientMap()
Returns a map of control plane server info objects to the LoadReportClients that are responsible for sending load reports to the control plane servers.com.google.common.util.concurrent.ListenableFuture<java.util.Map<XdsResourceType<?>,java.util.Map<java.lang.String,XdsClient.ResourceMetadata>>>
getSubscribedResourcesMetadataSnapshot()
Returns aListenableFuture
to the snapshot of the subscribed resources as they are at the moment of the call.static boolean
isResourceNameValid(java.lang.String resourceName, java.lang.String typeUrl)
boolean
isShutDown()
Returnstrue
ifshutdown()
has been called.static java.lang.String
percentEncodePath(java.lang.String input)
void
shutdown()
Shutdown thisXdsClient
and release resources.protected void
startSubscriberTimersIfNeeded(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.<T extends XdsClient.ResourceUpdate>
voidwatchXdsResource(XdsResourceType<T> type, java.lang.String resourceName, XdsClient.ResourceWatcher<T> watcher)
<T extends XdsClient.ResourceUpdate>
voidwatchXdsResource(XdsResourceType<T> type, java.lang.String resourceName, XdsClient.ResourceWatcher<T> watcher, java.util.concurrent.Executor executor)
Registers a data watcher for the given Xds resource.
-
-
-
Method Detail
-
isResourceNameValid
public static boolean isResourceNameValid(java.lang.String resourceName, java.lang.String typeUrl)
-
canonifyResourceName
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/10862") public static java.lang.String canonifyResourceName(java.lang.String resourceName)
-
percentEncodePath
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/10862") public static java.lang.String percentEncodePath(java.lang.String input)
-
shutdown
public void shutdown()
Shutdown thisXdsClient
and release resources.
-
isShutDown
public boolean isShutDown()
Returnstrue
ifshutdown()
has been called.
-
getBootstrapInfo
public Bootstrapper.BootstrapInfo getBootstrapInfo()
Returns the config used to bootstrap this XdsClientBootstrapper.BootstrapInfo
.
-
getSecurityConfig
public java.lang.Object getSecurityConfig()
Returns the implementation specific security configuration used in this XdsClient.
-
startSubscriberTimersIfNeeded
protected void startSubscriberTimersIfNeeded(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.
-
getSubscribedResourcesMetadataSnapshot
public com.google.common.util.concurrent.ListenableFuture<java.util.Map<XdsResourceType<?>,java.util.Map<java.lang.String,XdsClient.ResourceMetadata>>> getSubscribedResourcesMetadataSnapshot()
Returns aListenableFuture
to 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").
-
watchXdsResource
public <T extends XdsClient.ResourceUpdate> void watchXdsResource(XdsResourceType<T> type, java.lang.String resourceName, XdsClient.ResourceWatcher<T> watcher, java.util.concurrent.Executor executor)
Registers a data watcher for the given Xds resource.
-
watchXdsResource
public <T extends XdsClient.ResourceUpdate> void watchXdsResource(XdsResourceType<T> type, java.lang.String resourceName, XdsClient.ResourceWatcher<T> watcher)
-
cancelXdsResourceWatch
public <T extends XdsClient.ResourceUpdate> void cancelXdsResourceWatch(XdsResourceType<T> type, java.lang.String resourceName, XdsClient.ResourceWatcher<T> watcher)
Unregisters the given resource watcher.
-
addClusterDropStats
public LoadStatsManager2.ClusterDropStats addClusterDropStats(Bootstrapper.ServerInfo serverInfo, java.lang.String clusterName, @Nullable java.lang.String edsServiceName)
Adds 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.
-
addClusterLocalityStats
public LoadStatsManager2.ClusterLocalityStats addClusterLocalityStats(Bootstrapper.ServerInfo serverInfo, java.lang.String clusterName, @Nullable java.lang.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. 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.
-
getServerLrsClientMap
public java.util.Map<Bootstrapper.ServerInfo,LoadReportClient> getServerLrsClientMap()
Returns a map of control plane server info objects to the LoadReportClients that are responsible for sending load reports to the control plane servers.
-
-