Skip to content
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

api: Deprecate the old way of handling resolved addresses in LB #10028

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 19 additions & 1 deletion api/src/main/java/io/grpc/LoadBalancer.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,13 @@ public abstract class LoadBalancer {
*
* @param resolvedAddresses the resolved server addresses, attributes, and config.
* @since 1.21.0
* @deprecated Please override {@code acceptResolvedAddresses()} instead. Also note that
* {@code canHandleEmptyAddressListFromNameResolution()} is deprecated as well as
* {@code acceptResolvedAddresses()} should now indicate the acceptance of the addresses with
* its return value.
*/
@Deprecated
@SuppressWarnings("InlineMeSuggester")
public void handleResolvedAddresses(ResolvedAddresses resolvedAddresses) {
if (recursionCount++ == 0) {
// Note that the information about the addresses actually being accepted will be lost
Expand All @@ -141,7 +147,9 @@ public void handleResolvedAddresses(ResolvedAddresses resolvedAddresses) {
* EquivalentAddressGroup} addresses should be considered equivalent but may be flattened into a
* single list if needed.
*
* <p>Implementations can choose to reject the given addresses by returning {@code false}.
* <p>Implementations can choose to reject the given addresses by returning {@code false}. Please
* note that an empty list of addresses could be provided and that the deprecated {@code
* canHandleEmptyAddressListFromNameResolution()} will be ignored when this method is overwritten.
*
* <p>Implementations should not modify the given {@code addresses}.
*
Expand Down Expand Up @@ -379,7 +387,17 @@ public void handleSubchannelState(
*
* <p>This method should always return a constant value. It's not specified when this will be
* called.
*
* <p>Note that this method is only called when the deprecated {@code handleResolvedAddresses()}
* is overwritten.
*
* @deprecated Instead of overwriting this and {@code handleResolvedAddresses()} please only
* overwrite {@code acceptResolvedAddresses()}. In that method you can indicate if the
* addresses provided by the name resolver are acceptable with the {@code boolean} return
* value.
*/
@Deprecated
@SuppressWarnings("InlineMeSuggester")
public boolean canHandleEmptyAddressListFromNameResolution() {
return false;
}
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/io/grpc/util/ForwardingLoadBalancer.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public abstract class ForwardingLoadBalancer extends LoadBalancer {
protected abstract LoadBalancer delegate();

@Override
@SuppressWarnings("deprecation")
public void handleResolvedAddresses(ResolvedAddresses resolvedAddresses) {
delegate().handleResolvedAddresses(resolvedAddresses);
}
Expand All @@ -52,6 +53,7 @@ public void shutdown() {
}

@Override
@SuppressWarnings("deprecation")
public boolean canHandleEmptyAddressListFromNameResolution() {
return delegate().canHandleEmptyAddressListFromNameResolution();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
public final class GracefulSwitchLoadBalancer extends ForwardingLoadBalancer {
private final LoadBalancer defaultBalancer = new LoadBalancer() {
@Override
@SuppressWarnings("deprecation")
public void handleResolvedAddresses(ResolvedAddresses resolvedAddresses) {
// Most LB policies using this class will receive child policy configuration within the
// service config, so they are naturally calling switchTo() just before
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ public void handleNameResolutionError(Status error) {
}

@Override
@SuppressWarnings("deprecation")
public boolean canHandleEmptyAddressListFromNameResolution() {
return true;
}
Expand Down