Skip to content

Commit f60c985

Browse files
committed
fix javadoc
1 parent ef7bfcd commit f60c985

File tree

8 files changed

+52
-59
lines changed

8 files changed

+52
-59
lines changed

api/src/main/java/io/grpc/NameResolver.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,6 @@ public String getOverrideAuthority() {
408408

409409
/**
410410
* Returns the {@link MetricRecorder} that the channel uses to record metrics.
411-
*
412-
* @since 1.67.0
413411
*/
414412
@Nullable
415413
@ExperimentalApi("Insert GitHub issue")

xds/src/main/java/io/grpc/xds/XdsClientMetricReporter.java

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,38 +21,35 @@
2121

2222
/**
2323
* Interface for reporting metrics from the xDS client.
24-
* We need this indirection, to de couple Xds from OpenTelemetry
2524
*/
2625
@Internal
2726
public interface XdsClientMetricReporter {
2827

2928
/**
30-
* Reports resource update counts.
29+
* Reports number of valid and invalid resources.
3130
*
32-
* @param validResourceCount the number of resources that were successfully updated.
33-
* @param invalidResourceCount the number of resources that failed to update.
34-
* @param target the xDS management server name for the load balancing policy this update is for.
35-
* @param xdsServer the xDS management server address for this update.
36-
* @param resourceType the type of resource (e.g., "LDS", "RDS", "CDS", "EDS").
31+
* @param validResourceCount Number of resources that were valid.
32+
* @param invalidResourceCount Number of resources that were invalid.
33+
* @param target Target of the gRPC channel.
34+
* @param xdsServer Target URI of the xDS server with which the XdsClient is communicating.
35+
* @param resourceType Type of XDS resource (e.g., "envoy.config.listener.v3.Listener").
3736
*/
3837
default void reportResourceUpdates(long validResourceCount, long invalidResourceCount,
3938
String target, String xdsServer, String resourceType) {
4039
}
4140

4241
/**
43-
* Reports xDS server failure counts.
42+
* Reports number of xDS servers going from healthy to unhealthy.
4443
*
45-
* @param serverFailure the number of times the xDS server has failed.
46-
* @param target the xDS management server name for the load balancing policy this failure is for.
47-
* @param xdsServer the xDS management server address for this failure.
44+
* @param serverFailure Number of xDS server failures.
45+
* @param target Target of the gRPC channel.
46+
* @param xdsServer Target URI of the xDS server with which the XdsClient is communicating.
4847
*/
4948
default void reportServerFailure(long serverFailure, String target, String xdsServer) {
5049
}
5150

5251
/**
53-
* Sets the {@link XdsClient} instance to the reporter.
54-
*
55-
* @param xdsClient the {@link XdsClient} instance.
52+
* Sets the {@link XdsClient} instance.
5653
*/
5754
default void setXdsClient(XdsClient xdsClient) {
5855
}
@@ -64,34 +61,31 @@ default void close() {
6461
}
6562

6663
/**
67-
* Interface for reporting metrics from the xDS client callbacks.
64+
* Interface for reporting metrics through callback.
6865
*
6966
*/
7067
interface CallbackMetricReporter {
7168

7269
/**
73-
* Reports resource counts in the cache.
70+
* Reports number of resources in each cache state.
7471
*
75-
* @param resourceCount the number of resources in the cache.
76-
* @param cacheState the state of the cache (e.g., "SYNCED", "DOES_NOT_EXIST").
77-
* @param resourceType the type of resource (e.g., "LDS", "RDS", "CDS", "EDS").
78-
* @param target the xDS management server name for the load balancing policy this count is
79-
* for.
72+
* @param resourceCount Number of resources.
73+
* @param cacheState Status of the resource metadata
74+
* {@link io.grpc.xds.client.XdsClient.ResourceMetadata.ResourceMetadataStatus}.
75+
* @param resourceType Type of XDS resource (e.g., "envoy.config.listener.v3.Listener").
76+
* @param target Target of the gRPC channel.
8077
*/
81-
// TODO(@dnvindhya): include the "authority" label once authority is available.
78+
// TODO(@dnvindhya): include the "authority" label once xds.authority is available.
8279
default void reportResourceCounts(long resourceCount, String cacheState, String resourceType,
8380
String target) {
8481
}
8582

8683
/**
87-
* Reports server connection status.
84+
* Reports whether xDS client has a working ADS stream to the xDS server.
8885
*
89-
* @param isConnected {@code true} if the client is connected to the xDS server, {@code false}
90-
* otherwise.
91-
* @param target the xDS management server name for the load balancing policy this connection
92-
* is for.
93-
* @param xdsServer the xDS management server address for this connection.
94-
* @since 0.1.0
86+
* @param isConnected 1 if the client is connected to the xDS server, 0 otherwise.
87+
* @param target Target of the gRPC channel.
88+
* @param xdsServer Target URI of the xDS server with which the XdsClient is communicating.
9589
*/
9690
default void reportServerConnections(int isConnected, String target, String xdsServer) {
9791
}

xds/src/main/java/io/grpc/xds/XdsClientMetricReporterImpl.java

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,6 @@ public void reportServerFailure(long serverFailure, String target, String xdsSer
108108
Arrays.asList(target, xdsServer), Collections.emptyList());
109109
}
110110

111-
@Override
112-
public void close() {
113-
if (gaugeRegistration != null) {
114-
gaugeRegistration.close();
115-
}
116-
}
117-
118111
@Override
119112
public void setXdsClient(XdsClient client) {
120113
this.xdsClient = client;
@@ -127,9 +120,13 @@ public void accept(BatchRecorder recorder) {
127120
}, CONNECTED_GAUGE, RESOURCES_GAUGE);
128121
}
129122

130-
// ... (other methods)
123+
@Override
124+
public void close() {
125+
if (gaugeRegistration != null) {
126+
gaugeRegistration.close();
127+
}
128+
}
131129

132-
@VisibleForTesting
133130
void reportCallbackMetrics(BatchRecorder recorder) {
134131
if (callbackMetricReporter == null) {
135132
// Instantiate only if not injected
@@ -146,23 +143,13 @@ void reportCallbackMetrics(BatchRecorder recorder) {
146143
}
147144
}
148145

149-
/**
150-
* Reports resource counts.
151-
* This method is extracted for better testability.
152-
*/
153-
@VisibleForTesting
154146
void reportResourceCounts(CallbackMetricReporter callbackMetricReporter) throws Exception {
155147
SettableFuture<Void> ret = this.xdsClient.reportResourceCounts(
156148
callbackMetricReporter);
157149
// Normally this shouldn't take long, but adding a timeout to avoid indefinite blocking
158150
Void unused = ret.get(5, TimeUnit.SECONDS);
159151
}
160152

161-
/**
162-
* Reports server connections.
163-
* This method is extracted for better testability.
164-
*/
165-
@VisibleForTesting
166153
void reportServerConnections(CallbackMetricReporter callbackMetricReporter) throws Exception {
167154
SettableFuture<Void> ret = this.xdsClient.reportServerConnections(callbackMetricReporter);
168155
// Normally this shouldn't take long, but adding a timeout to avoid indefinite blocking
@@ -192,7 +179,7 @@ public void reportServerConnections(int isConnected, String target, String xdsSe
192179
Collections.emptyList());
193180
}
194181

195-
// TODO(@dnvindhya): include the "authority" label once authority is available.
182+
// TODO(@dnvindhya): include the "authority" label once xds.authority is available.
196183
@Override
197184
public void reportResourceCounts(long resourceCount, String cacheState, String resourceType,
198185
String target) {

xds/src/main/java/io/grpc/xds/client/XdsClient.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,11 +380,24 @@ public Map<Bootstrapper.ServerInfo, LoadReportClient> getServerLrsClientMap() {
380380
throw new UnsupportedOperationException();
381381
}
382382

383-
public SettableFuture<Void> reportResourceCounts(
384-
CallbackMetricReporter callbackMetricReporter) {
383+
/**
384+
* Reports the number of resources in each cache state through {@link CallbackMetricReporter}.
385+
*
386+
* <p>Cache state is determined by two factors:
387+
* <ul>
388+
* <li>Whether the resource is cached.
389+
* <li>The {@link io.grpc.xds.client.XdsClient.ResourceMetadata.ResourceMetadataStatus} of the
390+
* resource.
391+
* </ul>
392+
*/
393+
public SettableFuture<Void> reportResourceCounts(CallbackMetricReporter callbackMetricReporter) {
385394
throw new UnsupportedOperationException();
386395
}
387396

397+
/**
398+
* Reports whether xDS client has a working ADS stream to xDS server. Reporting is done through
399+
* {@link CallbackMetricReporter}.
400+
*/
388401
public SettableFuture<Void> reportServerConnections(
389402
CallbackMetricReporter callbackMetricReporter) {
390403
throw new UnsupportedOperationException();

xds/src/main/java/io/grpc/xds/client/XdsClientImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ private String cacheStateFromResourceStatus(ResourceMetadata metadata, boolean i
571571
}
572572

573573
/**
574-
* Calculates number of resources by ResourceType and ResourceSubscriber.metadata.status
574+
* Calculates number of resources by ResourceType and ResourceSubscriber.metadata.status.
575575
*/
576576
Map<XdsResourceType<?>, Map<String, Long>> getResourceCountsByType() {
577577
Map<XdsResourceType<?>, Map<String, Long>> resourceCountsByType = new HashMap<>();

xds/src/test/java/io/grpc/xds/GrpcXdsClientImplTestBase.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2575,10 +2575,11 @@ public void cdsResponseErrorHandling_badUpstreamTlsContext() {
25752575
call.sendResponse(CDS, clusters, VERSION_1, "0000");
25762576

25772577
// The response NACKed with errors indicating indices of the failed resources.
2578-
String errorMsg = "CDS response Cluster 'cluster.googleapis.com' validation error: "
2578+
String errorMsg = "CDS response Cluster 'cluster.googleapis.com' validation error: "
25792579
+ "Cluster cluster.googleapis.com: malformed UpstreamTlsContext: "
25802580
+ "io.grpc.xds.client.XdsResourceType$ResourceInvalidException: "
2581-
+ "ca_certificate_provider_instance is required in upstream-tls-context";
2581+
+ "ca_certificate_provider_instance or system_root_certs is required in "
2582+
+ "upstream-tls-context";
25822583
call.verifyRequestNack(CDS, CDS_RESOURCE, "", "0000", NODE, ImmutableList.of(errorMsg));
25832584
verify(cdsResourceWatcher).onError(errorCaptor.capture());
25842585
verifyStatusWithNodeId(errorCaptor.getValue(), Code.UNAVAILABLE, errorMsg);

xds/src/test/java/io/grpc/xds/XdsClientMetricReporterImplTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public void setUp() {
8383

8484
@Test
8585
public void reportResourceUpdates() {
86-
// TODO(dnvindhya): support the "authority" label once available.
86+
// TODO(dnvindhya): add the "authority" label once available.
8787
reporter.reportResourceUpdates(10, 5, target, server, resourceTypeUrl);
8888
verify(mockMetricRecorder).addLongCounter(
8989
eqMetricInstrumentName("grpc.xds_client.resource_updates_valid"), eq((long) 10),

xds/src/test/java/io/grpc/xds/XdsNameResolverTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ public void resolved_rpcHashingByChannelId() {
923923
public void resolved_routeActionHasAutoHostRewrite_emitsCallOptionForTheSame() {
924924
resolver = new XdsNameResolver(targetUri, null, AUTHORITY, null, serviceConfigParser,
925925
syncContext, scheduler, xdsClientPoolFactory, mockRandom,
926-
FilterRegistry.getDefaultRegistry(), null);
926+
FilterRegistry.getDefaultRegistry(), null, metricRecorder);
927927
resolver.start(mockListener);
928928
FakeXdsClient xdsClient = (FakeXdsClient) resolver.getXdsClient();
929929
xdsClient.deliverLdsUpdate(
@@ -954,7 +954,7 @@ public void resolved_routeActionHasAutoHostRewrite_emitsCallOptionForTheSame() {
954954
public void resolved_routeActionNoAutoHostRewrite_doesntEmitCallOptionForTheSame() {
955955
resolver = new XdsNameResolver(targetUri, null, AUTHORITY, null, serviceConfigParser,
956956
syncContext, scheduler, xdsClientPoolFactory, mockRandom,
957-
FilterRegistry.getDefaultRegistry(), null);
957+
FilterRegistry.getDefaultRegistry(), null, metricRecorder);
958958
resolver.start(mockListener);
959959
FakeXdsClient xdsClient = (FakeXdsClient) resolver.getXdsClient();
960960
xdsClient.deliverLdsUpdate(

0 commit comments

Comments
 (0)