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 Object
An
XdsClient
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 ClassesModifier and TypeClassDescription(package private) static final class
static final class
The metadata of the xDS resource; used by the xDS config dump.static interface
static interface
static interface
Watcher interface for a single requested xDS resource.(package private) static interface
-
Constructor Summary
Constructors -
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.static String
canonifyResourceName
(String resourceName) Returns the config used to bootstrap this XdsClientBootstrapper.BootstrapInfo
.Returns the implementation specific security configuration used in this XdsClient.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
<Map<XdsResourceType<?>, Map<String, XdsClient.ResourceMetadata>>> Returns aListenableFuture
to the snapshot of the subscribed resources as they are at the moment of the call.static boolean
isResourceNameValid
(String resourceName, String typeUrl) boolean
Returnstrue
ifshutdown()
has been called.static String
percentEncodePath
(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, String resourceName, XdsClient.ResourceWatcher<T> watcher) <T extends XdsClient.ResourceUpdate>
voidwatchXdsResource
(XdsResourceType<T> type, String resourceName, XdsClient.ResourceWatcher<T> watcher, Executor executor) Registers a data watcher for the given Xds resource.
-
Constructor Details
-
XdsClient
public XdsClient()
-
-
Method Details
-
isResourceNameValid
-
canonifyResourceName
-
percentEncodePath
-
shutdown
public void shutdown()Shutdown thisXdsClient
and release resources. -
isShutDown
public boolean isShutDown()Returnstrue
ifshutdown()
has been called. -
getBootstrapInfo
Returns the config used to bootstrap this XdsClientBootstrapper.BootstrapInfo
. -
getSecurityConfig
Returns the implementation specific security configuration used in this XdsClient. -
startSubscriberTimersIfNeeded
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<Map<XdsResourceType<?>,Map<String, getSubscribedResourcesMetadataSnapshot()XdsClient.ResourceMetadata>>> 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, String resourceName, XdsClient.ResourceWatcher<T> watcher, Executor executor) Registers a data watcher for the given Xds resource. -
watchXdsResource
public <T extends XdsClient.ResourceUpdate> void watchXdsResource(XdsResourceType<T> type, String resourceName, XdsClient.ResourceWatcher<T> watcher) -
cancelXdsResourceWatch
public <T extends XdsClient.ResourceUpdate> void cancelXdsResourceWatch(XdsResourceType<T> type, String resourceName, XdsClient.ResourceWatcher<T> watcher) Unregisters the given resource watcher. -
addClusterDropStats
public LoadStatsManager2.ClusterDropStats addClusterDropStats(Bootstrapper.ServerInfo serverInfo, String clusterName, @Nullable 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, String clusterName, @Nullable 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
Returns a map of control plane server info objects to the LoadReportClients that are responsible for sending load reports to the control plane servers.
-