forked from grpc/grpc-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Client watcher changes #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
shivaspeaks
wants to merge
6
commits into
master
Choose a base branch
from
client-watcher-changes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d7ef02a
Merge branch 'master' of https://github.com/grpc/grpc-java
shivaspeaks 724d490
xds: client watcher API changes
shivaspeaks f07ddd9
xds: client watcher API changes
shivaspeaks b60f99b
Update xds/src/main/java/io/grpc/xds/ClusterResolverLoadBalancer.java
shivaspeaks d5f29f7
xds: client watcher API changes
shivaspeaks 4e456c2
xds: client watcher API changes
shivaspeaks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,13 +87,6 @@ public final class BinderClientTransport extends BinderTransport | |
| @GuardedBy("this") | ||
| private ScheduledFuture<?> readyTimeoutFuture; // != null iff timeout scheduled. | ||
|
|
||
| @GuardedBy("this") | ||
| @Nullable | ||
| private ListenableFuture<Status> authResultFuture; // null before we check auth. | ||
|
|
||
| @GuardedBy("this") | ||
| @Nullable | ||
| private ListenableFuture<Status> preAuthResultFuture; // null before we pre-auth. | ||
|
|
||
| /** | ||
| * Constructs a new transport instance. | ||
|
|
@@ -193,7 +186,8 @@ private void preAuthorize(ServiceInfo serviceInfo) { | |
| // unauthorized server a chance to run, but the connection will still fail by SecurityPolicy | ||
| // check later in handshake. Pre-auth remains effective at mitigating abuse because malware | ||
| // can't typically control the exact timing of its installation. | ||
| preAuthResultFuture = checkServerAuthorizationAsync(serviceInfo.applicationInfo.uid); | ||
| ListenableFuture<Status> preAuthResultFuture = | ||
| register(checkServerAuthorizationAsync(serviceInfo.applicationInfo.uid)); | ||
| Futures.addCallback( | ||
| preAuthResultFuture, | ||
| new FutureCallback<Status>() { | ||
|
|
@@ -314,12 +308,6 @@ void notifyTerminated() { | |
| readyTimeoutFuture.cancel(false); | ||
| readyTimeoutFuture = null; | ||
| } | ||
| if (preAuthResultFuture != null) { | ||
| preAuthResultFuture.cancel(false); // No effect if already complete. | ||
| } | ||
| if (authResultFuture != null) { | ||
| authResultFuture.cancel(false); // No effect if already complete. | ||
| } | ||
| serviceBinding.unbind(); | ||
| clientTransportListener.transportTerminated(); | ||
| } | ||
|
|
@@ -339,7 +327,8 @@ protected void handleSetupTransport(Parcel parcel) { | |
| } else { | ||
| restrictIncomingBinderToCallsFrom(remoteUid); | ||
| attributes = setSecurityAttrs(attributes, remoteUid); | ||
| authResultFuture = checkServerAuthorizationAsync(remoteUid); | ||
| ListenableFuture<Status> authResultFuture = | ||
| register(checkServerAuthorizationAsync(remoteUid)); | ||
|
Comment on lines
+330
to
+331
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| Futures.addCallback( | ||
| authResultFuture, | ||
| new FutureCallback<Status>() { | ||
|
|
@@ -398,6 +387,7 @@ protected void handlePingResponse(Parcel parcel) { | |
| pingTracker.onPingResponse(parcel.readInt()); | ||
| } | ||
|
|
||
|
|
||
| private static ClientStream newFailingClientStream( | ||
| Status failure, Attributes attributes, Metadata headers, ClientStreamTracer[] tracers) { | ||
| StatsTraceContext statsTraceContext = | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ | |
| package io.grpc.xds; | ||
|
|
||
| import static com.google.common.base.Preconditions.checkNotNull; | ||
| import static io.grpc.xds.client.LoadStatsManager2.isEnabledOrcaLrsPropagation; | ||
|
|
||
| import com.google.common.annotations.VisibleForTesting; | ||
| import com.google.common.base.MoreObjects; | ||
|
|
@@ -46,6 +47,7 @@ | |
| import io.grpc.xds.EnvoyServerProtoData.UpstreamTlsContext; | ||
| import io.grpc.xds.ThreadSafeRandom.ThreadSafeRandomImpl; | ||
| import io.grpc.xds.XdsNameResolverProvider.CallCounterProvider; | ||
| import io.grpc.xds.client.BackendMetricPropagation; | ||
| import io.grpc.xds.client.Bootstrapper.ServerInfo; | ||
| import io.grpc.xds.client.LoadStatsManager2.ClusterDropStats; | ||
| import io.grpc.xds.client.LoadStatsManager2.ClusterLocalityStats; | ||
|
|
@@ -149,6 +151,7 @@ public Status acceptResolvedAddresses(ResolvedAddresses resolvedAddresses) { | |
| childLbHelper.updateMaxConcurrentRequests(config.maxConcurrentRequests); | ||
| childLbHelper.updateSslContextProviderSupplier(config.tlsContext); | ||
| childLbHelper.updateFilterMetadata(config.filterMetadata); | ||
| childLbHelper.updateBackendMetricPropagation(config.backendMetricPropagation); | ||
|
|
||
| childSwitchLb.handleResolvedAddresses( | ||
| resolvedAddresses.toBuilder() | ||
|
|
@@ -209,6 +212,8 @@ private final class ClusterImplLbHelper extends ForwardingLoadBalancerHelper { | |
| private Map<String, Struct> filterMetadata = ImmutableMap.of(); | ||
| @Nullable | ||
| private final ServerInfo lrsServerInfo; | ||
| @Nullable | ||
| private BackendMetricPropagation backendMetricPropagation; | ||
|
|
||
| private ClusterImplLbHelper(AtomicLong inFlights, @Nullable ServerInfo lrsServerInfo) { | ||
| this.inFlights = checkNotNull(inFlights, "inFlights"); | ||
|
|
@@ -321,7 +326,7 @@ private ClusterLocality createClusterLocalityFromAttributes(Attributes addressAt | |
| (lrsServerInfo == null) | ||
| ? null | ||
| : xdsClient.addClusterLocalityStats(lrsServerInfo, cluster, | ||
| edsServiceName, locality); | ||
| edsServiceName, locality, backendMetricPropagation); | ||
|
Comment on lines
326
to
+329
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| return new ClusterLocality(localityStats, localityName); | ||
| } | ||
|
|
@@ -371,6 +376,11 @@ private void updateFilterMetadata(Map<String, Struct> filterMetadata) { | |
| this.filterMetadata = ImmutableMap.copyOf(filterMetadata); | ||
| } | ||
|
|
||
| private void updateBackendMetricPropagation( | ||
| @Nullable BackendMetricPropagation backendMetricPropagation) { | ||
| this.backendMetricPropagation = backendMetricPropagation; | ||
| } | ||
|
|
||
| private class RequestLimitingSubchannelPicker extends SubchannelPicker { | ||
| private final SubchannelPicker delegate; | ||
| private final List<DropOverload> dropPolicies; | ||
|
|
@@ -506,11 +516,19 @@ private OrcaPerRpcListener(ClusterLocalityStats stats) { | |
| } | ||
|
|
||
| /** | ||
| * Copies {@link MetricReport#getNamedMetrics()} to {@link ClusterLocalityStats} such that it is | ||
| * included in the snapshot for the LRS report sent to the LRS server. | ||
| * Copies ORCA metrics from {@link MetricReport} to {@link ClusterLocalityStats} | ||
| * such that they are included in the snapshot for the LRS report sent to the LRS server. | ||
| * This includes both top-level metrics (CPU, memory, application utilization) and named | ||
| * metrics, filtered according to the backend metric propagation configuration. | ||
| */ | ||
| @Override | ||
| public void onLoadReport(MetricReport report) { | ||
| if (isEnabledOrcaLrsPropagation) { | ||
| stats.recordTopLevelMetrics( | ||
| report.getCpuUtilization(), | ||
| report.getMemoryUtilization(), | ||
| report.getApplicationUtilization()); | ||
|
Comment on lines
+526
to
+530
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
| stats.recordBackendLoadMetricStats(report.getNamedMetrics()); | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
registermethod is used here to ensure that thepreAuthResultFutureis properly managed for cancellation. This is a good practice to prevent resource leaks, especially in long-lived transports. However, it's crucial to ensure that theregistermethod itself is thread-safe and handles exceptions appropriately.