diff --git a/api/src/main/java/io/grpc/LoadBalancer.java b/api/src/main/java/io/grpc/LoadBalancer.java
index d5f44dafa5e..88c1d9fcd6f 100644
--- a/api/src/main/java/io/grpc/LoadBalancer.java
+++ b/api/src/main/java/io/grpc/LoadBalancer.java
@@ -156,15 +156,16 @@ public String toString() {
private int recursionCount;
/**
- * Handles newly resolved server groups and metadata attributes from name resolution system.
- * {@code servers} contained in {@link EquivalentAddressGroup} should be considered equivalent
- * but may be flattened into a single list if needed.
+ * Handles newly resolved addresses and metadata attributes from name resolution system.
+ * {@link EquivalentAddressGroup} addresses should be considered equivalent but may be flattened
+ * into a single list if needed.
*
- *
Implementations should not modify the given {@code servers}.
+ *
Implementations should not modify the given {@code resolvedAddresses}.
*
* @param resolvedAddresses the resolved server addresses, attributes, and config.
* @since 1.21.0
*/
+ @Deprecated
public void handleResolvedAddresses(ResolvedAddresses resolvedAddresses) {
if (recursionCount++ == 0) {
// Note that the information about the addresses actually being accepted will be lost
@@ -179,12 +180,15 @@ public void handleResolvedAddresses(ResolvedAddresses resolvedAddresses) {
* EquivalentAddressGroup} addresses should be considered equivalent but may be flattened into a
* single list if needed.
*
- *
Implementations can choose to reject the given addresses by returning {@code false}.
+ *
Implementations can choose to reject the given addresses by returning
+ * {@code Status.UNAVAILABLE}.
*
- *
Implementations should not modify the given {@code addresses}.
+ *
Implementations should not modify the given {@code resolvedAddresses}.
*
* @param resolvedAddresses the resolved server addresses, attributes, and config.
- * @return {@code true} if the resolved addresses were accepted. {@code false} if rejected.
+ * @return {@code Status.OK} if the resolved addresses were accepted. {@code Status.UNAVAILABLE}
+ * if rejected.
+ *
* @since 1.49.0
*/
public Status acceptResolvedAddresses(ResolvedAddresses resolvedAddresses) {
diff --git a/interop-testing/src/main/java/io/grpc/testing/integration/RpcBehaviorLoadBalancerProvider.java b/interop-testing/src/main/java/io/grpc/testing/integration/RpcBehaviorLoadBalancerProvider.java
index 83c416765ec..7d78725a82d 100644
--- a/interop-testing/src/main/java/io/grpc/testing/integration/RpcBehaviorLoadBalancerProvider.java
+++ b/interop-testing/src/main/java/io/grpc/testing/integration/RpcBehaviorLoadBalancerProvider.java
@@ -111,10 +111,10 @@ protected LoadBalancer delegate() {
}
@Override
- public void handleResolvedAddresses(ResolvedAddresses resolvedAddresses) {
+ public Status acceptResolvedAddresses(ResolvedAddresses resolvedAddresses) {
helper.setRpcBehavior(
((RpcBehaviorConfig) resolvedAddresses.getLoadBalancingPolicyConfig()).rpcBehavior);
- delegateLb.handleResolvedAddresses(resolvedAddresses);
+ return delegateLb.acceptResolvedAddresses(resolvedAddresses);
}
}
diff --git a/interop-testing/src/test/java/io/grpc/testing/integration/RpcBehaviorLoadBalancerProviderTest.java b/interop-testing/src/test/java/io/grpc/testing/integration/RpcBehaviorLoadBalancerProviderTest.java
index 02ede46bcdd..9ae2c3f70ec 100644
--- a/interop-testing/src/test/java/io/grpc/testing/integration/RpcBehaviorLoadBalancerProviderTest.java
+++ b/interop-testing/src/test/java/io/grpc/testing/integration/RpcBehaviorLoadBalancerProviderTest.java
@@ -83,8 +83,8 @@ public void handleResolvedAddressesDelegated() {
RpcBehaviorLoadBalancer lb = new RpcBehaviorLoadBalancer(new RpcBehaviorHelper(mockHelper),
mockDelegateLb);
ResolvedAddresses resolvedAddresses = buildResolvedAddresses(buildConfig());
- lb.handleResolvedAddresses(resolvedAddresses);
- verify(mockDelegateLb).handleResolvedAddresses(resolvedAddresses);
+ lb.acceptResolvedAddresses(resolvedAddresses);
+ verify(mockDelegateLb).acceptResolvedAddresses(resolvedAddresses);
}
@Test
diff --git a/services/src/main/java/io/grpc/protobuf/services/HealthCheckingLoadBalancerFactory.java b/services/src/main/java/io/grpc/protobuf/services/HealthCheckingLoadBalancerFactory.java
index cac522caf9e..91e8cc14882 100644
--- a/services/src/main/java/io/grpc/protobuf/services/HealthCheckingLoadBalancerFactory.java
+++ b/services/src/main/java/io/grpc/protobuf/services/HealthCheckingLoadBalancerFactory.java
@@ -187,14 +187,14 @@ protected LoadBalancer delegate() {
}
@Override
- public void handleResolvedAddresses(ResolvedAddresses resolvedAddresses) {
+ public Status acceptResolvedAddresses(ResolvedAddresses resolvedAddresses) {
Map healthCheckingConfig =
resolvedAddresses
.getAttributes()
.get(LoadBalancer.ATTR_HEALTH_CHECKING_CONFIG);
String serviceName = ServiceConfigUtil.getHealthCheckedServiceName(healthCheckingConfig);
helper.setHealthCheckedService(serviceName);
- super.handleResolvedAddresses(resolvedAddresses);
+ return super.acceptResolvedAddresses(resolvedAddresses);
}
@Override
diff --git a/services/src/test/java/io/grpc/protobuf/services/HealthCheckingLoadBalancerFactoryTest.java b/services/src/test/java/io/grpc/protobuf/services/HealthCheckingLoadBalancerFactoryTest.java
index 08a33106fb9..a49c426f7e1 100644
--- a/services/src/test/java/io/grpc/protobuf/services/HealthCheckingLoadBalancerFactoryTest.java
+++ b/services/src/test/java/io/grpc/protobuf/services/HealthCheckingLoadBalancerFactoryTest.java
@@ -206,15 +206,16 @@ public void setup() throws Exception {
boolean shutdown;
@Override
- public void handleResolvedAddresses(final ResolvedAddresses resolvedAddresses) {
+ public Status acceptResolvedAddresses(final ResolvedAddresses resolvedAddresses) {
syncContext.execute(new Runnable() {
@Override
public void run() {
if (!shutdown) {
- hcLb.handleResolvedAddresses(resolvedAddresses);
+ hcLb.acceptResolvedAddresses(resolvedAddresses);
}
}
});
+ return Status.OK;
}
@Override
@@ -264,9 +265,9 @@ public void typicalWorkflow() {
.setAddresses(resolvedAddressList)
.setAttributes(resolutionAttrs)
.build();
- hcLbEventDelivery.handleResolvedAddresses(result);
+ hcLbEventDelivery.acceptResolvedAddresses(result);
- verify(origLb).handleResolvedAddresses(result);
+ verify(origLb).acceptResolvedAddresses(result);
verify(origHelper, atLeast(0)).getSynchronizationContext();
verify(origHelper, atLeast(0)).getScheduledExecutorService();
verifyNoMoreInteractions(origHelper);
@@ -404,9 +405,9 @@ public void healthCheckDisabledWhenServiceNotImplemented() {
.setAddresses(resolvedAddressList)
.setAttributes(resolutionAttrs)
.build();
- hcLbEventDelivery.handleResolvedAddresses(result);
+ hcLbEventDelivery.acceptResolvedAddresses(result);
- verify(origLb).handleResolvedAddresses(result);
+ verify(origLb).acceptResolvedAddresses(result);
verifyNoMoreInteractions(origLb);
// We create 2 Subchannels. One of them connects to a server that doesn't implement health check
@@ -489,9 +490,9 @@ public void backoffRetriesWhenServerErroneouslyClosesRpcBeforeAnyResponse() {
.setAddresses(resolvedAddressList)
.setAttributes(resolutionAttrs)
.build();
- hcLbEventDelivery.handleResolvedAddresses(result);
+ hcLbEventDelivery.acceptResolvedAddresses(result);
- verify(origLb).handleResolvedAddresses(result);
+ verify(origLb).acceptResolvedAddresses(result);
verifyNoMoreInteractions(origLb);
SubchannelStateListener mockHealthListener = mockHealthListeners[0];
@@ -567,9 +568,9 @@ public void serverRespondResetsBackoff() {
.setAddresses(resolvedAddressList)
.setAttributes(resolutionAttrs)
.build();
- hcLbEventDelivery.handleResolvedAddresses(result);
+ hcLbEventDelivery.acceptResolvedAddresses(result);
- verify(origLb).handleResolvedAddresses(result);
+ verify(origLb).acceptResolvedAddresses(result);
verifyNoMoreInteractions(origLb);
SubchannelStateListener mockStateListener = mockStateListeners[0];
@@ -667,9 +668,9 @@ public void serviceConfigHasNoHealthCheckingInitiallyButDoesLater() {
.setAddresses(resolvedAddressList)
.setAttributes(Attributes.EMPTY)
.build();
- hcLbEventDelivery.handleResolvedAddresses(result1);
+ hcLbEventDelivery.acceptResolvedAddresses(result1);
- verify(origLb).handleResolvedAddresses(result1);
+ verify(origLb).acceptResolvedAddresses(result1);
verifyNoMoreInteractions(origLb);
// First, create Subchannels 0
@@ -688,8 +689,8 @@ public void serviceConfigHasNoHealthCheckingInitiallyButDoesLater() {
.setAddresses(resolvedAddressList)
.setAttributes(resolutionAttrs)
.build();
- hcLbEventDelivery.handleResolvedAddresses(result2);
- verify(origLb).handleResolvedAddresses(result2);
+ hcLbEventDelivery.acceptResolvedAddresses(result2);
+ verify(origLb).acceptResolvedAddresses(result2);
// Health check started on existing Subchannel
assertThat(healthImpls[0].calls).hasSize(1);
@@ -711,9 +712,9 @@ public void serviceConfigDisablesHealthCheckWhenRpcActive() {
.setAddresses(resolvedAddressList)
.setAttributes(resolutionAttrs)
.build();
- hcLbEventDelivery.handleResolvedAddresses(result1);
+ hcLbEventDelivery.acceptResolvedAddresses(result1);
- verify(origLb).handleResolvedAddresses(result1);
+ verify(origLb).acceptResolvedAddresses(result1);
verifyNoMoreInteractions(origLb);
Subchannel subchannel = createSubchannel(0, Attributes.EMPTY, maybeGetMockListener());
@@ -738,7 +739,7 @@ public void serviceConfigDisablesHealthCheckWhenRpcActive() {
.setAddresses(resolvedAddressList)
.setAttributes(Attributes.EMPTY)
.build();
- hcLbEventDelivery.handleResolvedAddresses(result2);
+ hcLbEventDelivery.acceptResolvedAddresses(result2);
// Health check RPC cancelled.
assertThat(serverCall.cancelled).isTrue();
@@ -746,7 +747,7 @@ public void serviceConfigDisablesHealthCheckWhenRpcActive() {
inOrder.verify(getMockListener()).onSubchannelState(
eq(ConnectivityStateInfo.forNonError(READY)));
- inOrder.verify(origLb).handleResolvedAddresses(result2);
+ inOrder.verify(origLb).acceptResolvedAddresses(result2);
verifyNoMoreInteractions(origLb, mockStateListeners[0]);
assertThat(healthImpl.calls).isEmpty();
@@ -759,9 +760,9 @@ public void serviceConfigDisablesHealthCheckWhenRetryPending() {
.setAddresses(resolvedAddressList)
.setAttributes(resolutionAttrs)
.build();
- hcLbEventDelivery.handleResolvedAddresses(result);
+ hcLbEventDelivery.acceptResolvedAddresses(result);
- verify(origLb).handleResolvedAddresses(result);
+ verify(origLb).acceptResolvedAddresses(result);
verifyNoMoreInteractions(origLb);
SubchannelStateListener mockHealthListener = mockHealthListeners[0];
@@ -793,7 +794,7 @@ public void serviceConfigDisablesHealthCheckWhenRetryPending() {
.setAddresses(resolvedAddressList)
.setAttributes(Attributes.EMPTY)
.build();
- hcLbEventDelivery.handleResolvedAddresses(result2);
+ hcLbEventDelivery.acceptResolvedAddresses(result2);
// Retry timer is cancelled
assertThat(clock.getPendingTasks()).isEmpty();
@@ -805,7 +806,7 @@ public void serviceConfigDisablesHealthCheckWhenRetryPending() {
inOrder.verify(getMockListener()).onSubchannelState(
eq(ConnectivityStateInfo.forNonError(READY)));
- inOrder.verify(origLb).handleResolvedAddresses(result2);
+ inOrder.verify(origLb).acceptResolvedAddresses(result2);
verifyNoMoreInteractions(origLb, mockStateListeners[0]);
}
@@ -817,9 +818,9 @@ public void serviceConfigDisablesHealthCheckWhenRpcInactive() {
.setAddresses(resolvedAddressList)
.setAttributes(resolutionAttrs)
.build();
- hcLbEventDelivery.handleResolvedAddresses(result1);
+ hcLbEventDelivery.acceptResolvedAddresses(result1);
- verify(origLb).handleResolvedAddresses(result1);
+ verify(origLb).acceptResolvedAddresses(result1);
verifyNoMoreInteractions(origLb);
Subchannel subchannel = createSubchannel(0, Attributes.EMPTY, maybeGetMockListener());
@@ -842,9 +843,9 @@ public void serviceConfigDisablesHealthCheckWhenRpcInactive() {
.setAddresses(resolvedAddressList)
.setAttributes(Attributes.EMPTY)
.build();
- hcLbEventDelivery.handleResolvedAddresses(result2);
+ hcLbEventDelivery.acceptResolvedAddresses(result2);
- inOrder.verify(origLb).handleResolvedAddresses(result2);
+ inOrder.verify(origLb).acceptResolvedAddresses(result2);
// Underlying subchannel is now ready
deliverSubchannelState(0, ConnectivityStateInfo.forNonError(READY));
@@ -870,9 +871,9 @@ public void serviceConfigChangesServiceNameWhenRpcActive() {
.setAddresses(resolvedAddressList)
.setAttributes(resolutionAttrs)
.build();
- hcLbEventDelivery.handleResolvedAddresses(result1);
+ hcLbEventDelivery.acceptResolvedAddresses(result1);
- verify(origLb).handleResolvedAddresses(result1);
+ verify(origLb).acceptResolvedAddresses(result1);
verifyNoMoreInteractions(origLb);
SubchannelStateListener mockHealthListener = mockHealthListeners[0];
@@ -900,9 +901,9 @@ public void serviceConfigChangesServiceNameWhenRpcActive() {
eq(ConnectivityStateInfo.forNonError(READY)));
// Service config returns with the same health check name.
- hcLbEventDelivery.handleResolvedAddresses(result1);
+ hcLbEventDelivery.acceptResolvedAddresses(result1);
// It's delivered to origLb, but nothing else happens
- inOrder.verify(origLb).handleResolvedAddresses(result1);
+ inOrder.verify(origLb).acceptResolvedAddresses(result1);
verifyNoMoreInteractions(origLb, mockListener);
// Service config returns a different health check name.
@@ -911,8 +912,8 @@ public void serviceConfigChangesServiceNameWhenRpcActive() {
.setAddresses(resolvedAddressList)
.setAttributes(resolutionAttrs)
.build();
- hcLbEventDelivery.handleResolvedAddresses(result2);
- inOrder.verify(origLb).handleResolvedAddresses(result2);
+ hcLbEventDelivery.acceptResolvedAddresses(result2);
+ inOrder.verify(origLb).acceptResolvedAddresses(result2);
// Current health check RPC cancelled.
assertThat(serverCall.cancelled).isTrue();
@@ -934,9 +935,9 @@ public void serviceConfigChangesServiceNameWhenRetryPending() {
.setAddresses(resolvedAddressList)
.setAttributes(resolutionAttrs)
.build();
- hcLbEventDelivery.handleResolvedAddresses(result1);
+ hcLbEventDelivery.acceptResolvedAddresses(result1);
- verify(origLb).handleResolvedAddresses(result1);
+ verify(origLb).acceptResolvedAddresses(result1);
verifyNoMoreInteractions(origLb);
SubchannelStateListener mockHealthListener = mockHealthListeners[0];
@@ -969,9 +970,9 @@ public void serviceConfigChangesServiceNameWhenRetryPending() {
// Service config returns with the same health check name.
- hcLbEventDelivery.handleResolvedAddresses(result1);
+ hcLbEventDelivery.acceptResolvedAddresses(result1);
// It's delivered to origLb, but nothing else happens
- inOrder.verify(origLb).handleResolvedAddresses(result1);
+ inOrder.verify(origLb).acceptResolvedAddresses(result1);
verifyNoMoreInteractions(origLb, mockListener);
assertThat(clock.getPendingTasks()).hasSize(1);
assertThat(healthImpl.calls).isEmpty();
@@ -982,12 +983,12 @@ public void serviceConfigChangesServiceNameWhenRetryPending() {
.setAddresses(resolvedAddressList)
.setAttributes(resolutionAttrs)
.build();
- hcLbEventDelivery.handleResolvedAddresses(result2);
+ hcLbEventDelivery.acceptResolvedAddresses(result2);
// Concluded CONNECTING state
inOrder.verify(getMockListener()).onSubchannelState(
eq(ConnectivityStateInfo.forNonError(CONNECTING)));
- inOrder.verify(origLb).handleResolvedAddresses(result2);
+ inOrder.verify(origLb).acceptResolvedAddresses(result2);
// Current retry timer cancelled
assertThat(clock.getPendingTasks()).isEmpty();
@@ -1008,9 +1009,9 @@ public void serviceConfigChangesServiceNameWhenRpcInactive() {
.setAddresses(resolvedAddressList)
.setAttributes(resolutionAttrs)
.build();
- hcLbEventDelivery.handleResolvedAddresses(result1);
+ hcLbEventDelivery.acceptResolvedAddresses(result1);
- verify(origLb).handleResolvedAddresses(result1);
+ verify(origLb).acceptResolvedAddresses(result1);
verifyNoMoreInteractions(origLb);
Subchannel subchannel = createSubchannel(0, Attributes.EMPTY, maybeGetMockListener());
@@ -1031,9 +1032,9 @@ public void serviceConfigChangesServiceNameWhenRpcInactive() {
inOrder.verifyNoMoreInteractions();
// Service config returns with the same health check name.
- hcLbEventDelivery.handleResolvedAddresses(result1);
+ hcLbEventDelivery.acceptResolvedAddresses(result1);
// It's delivered to origLb, but nothing else happens
- inOrder.verify(origLb).handleResolvedAddresses(result1);
+ inOrder.verify(origLb).acceptResolvedAddresses(result1);
assertThat(healthImpl.calls).isEmpty();
verifyNoMoreInteractions(origLb);
@@ -1043,9 +1044,9 @@ public void serviceConfigChangesServiceNameWhenRpcInactive() {
.setAddresses(resolvedAddressList)
.setAttributes(resolutionAttrs)
.build();
- hcLbEventDelivery.handleResolvedAddresses(result2);
+ hcLbEventDelivery.acceptResolvedAddresses(result2);
- inOrder.verify(origLb).handleResolvedAddresses(result2);
+ inOrder.verify(origLb).acceptResolvedAddresses(result2);
// Underlying subchannel is now ready
deliverSubchannelState(0, ConnectivityStateInfo.forNonError(READY));
@@ -1092,9 +1093,9 @@ public void balancerShutdown() {
.setAddresses(resolvedAddressList)
.setAttributes(resolutionAttrs)
.build();
- hcLbEventDelivery.handleResolvedAddresses(result);
+ hcLbEventDelivery.acceptResolvedAddresses(result);
- verify(origLb).handleResolvedAddresses(result);
+ verify(origLb).acceptResolvedAddresses(result);
verifyNoMoreInteractions(origLb);
ServerSideCall[] serverCalls = new ServerSideCall[NUM_SUBCHANNELS];
@@ -1172,8 +1173,8 @@ public LoadBalancer newLoadBalancer(Helper helper) {
.setAddresses(resolvedAddressList)
.setAttributes(resolutionAttrs)
.build();
- hcLbEventDelivery.handleResolvedAddresses(result);
- verify(origLb).handleResolvedAddresses(result);
+ hcLbEventDelivery.acceptResolvedAddresses(result);
+ verify(origLb).acceptResolvedAddresses(result);
createSubchannel(0, Attributes.EMPTY);
assertThat(healthImpls[0].calls).isEmpty();
deliverSubchannelState(0, ConnectivityStateInfo.forNonError(READY));
diff --git a/util/src/main/java/io/grpc/util/ForwardingLoadBalancer.java b/util/src/main/java/io/grpc/util/ForwardingLoadBalancer.java
index cefcbf344ea..8112e55fbbc 100644
--- a/util/src/main/java/io/grpc/util/ForwardingLoadBalancer.java
+++ b/util/src/main/java/io/grpc/util/ForwardingLoadBalancer.java
@@ -30,8 +30,8 @@ public abstract class ForwardingLoadBalancer extends LoadBalancer {
protected abstract LoadBalancer delegate();
@Override
- public void handleResolvedAddresses(ResolvedAddresses resolvedAddresses) {
- delegate().handleResolvedAddresses(resolvedAddresses);
+ public Status acceptResolvedAddresses(ResolvedAddresses resolvedAddresses) {
+ return delegate().acceptResolvedAddresses(resolvedAddresses);
}
@Override
diff --git a/util/src/main/java/io/grpc/util/GracefulSwitchLoadBalancer.java b/util/src/main/java/io/grpc/util/GracefulSwitchLoadBalancer.java
index a63a641b037..c1dd87109f8 100644
--- a/util/src/main/java/io/grpc/util/GracefulSwitchLoadBalancer.java
+++ b/util/src/main/java/io/grpc/util/GracefulSwitchLoadBalancer.java
@@ -56,7 +56,7 @@
public final class GracefulSwitchLoadBalancer extends ForwardingLoadBalancer {
private final LoadBalancer defaultBalancer = new LoadBalancer() {
@Override
- public void handleResolvedAddresses(ResolvedAddresses resolvedAddresses) {
+ public Status acceptResolvedAddresses(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
// handleResolvedAddresses(), within their own handleResolvedAddresses(). If switchTo() is
@@ -112,20 +112,6 @@ public GracefulSwitchLoadBalancer(Helper helper) {
this.helper = checkNotNull(helper, "helper");
}
- @Override
- public void handleResolvedAddresses(ResolvedAddresses resolvedAddresses) {
- if (switchToCalled) {
- delegate().handleResolvedAddresses(resolvedAddresses);
- return;
- }
- Config config = (Config) resolvedAddresses.getLoadBalancingPolicyConfig();
- switchToInternal(config.childFactory);
- delegate().handleResolvedAddresses(
- resolvedAddresses.toBuilder()
- .setLoadBalancingPolicyConfig(config.childConfig)
- .build());
- }
-
@Override
public Status acceptResolvedAddresses(ResolvedAddresses resolvedAddresses) {
if (switchToCalled) {
diff --git a/util/src/main/java/io/grpc/util/MultiChildLoadBalancer.java b/util/src/main/java/io/grpc/util/MultiChildLoadBalancer.java
index 3e56f41d038..389350bc346 100644
--- a/util/src/main/java/io/grpc/util/MultiChildLoadBalancer.java
+++ b/util/src/main/java/io/grpc/util/MultiChildLoadBalancer.java
@@ -193,7 +193,7 @@ private List updateChildrenWithResolvedAddresses(
newChildLbStates.add(childLbState);
if (entry.getValue() != null) {
childLbState.setResolvedAddresses(entry.getValue()); // update child
- childLbState.lb.handleResolvedAddresses(entry.getValue()); // update child LB
+ childLbState.lb.acceptResolvedAddresses(entry.getValue()); // update child LB
}
}
diff --git a/util/src/main/java/io/grpc/util/OutlierDetectionLoadBalancer.java b/util/src/main/java/io/grpc/util/OutlierDetectionLoadBalancer.java
index 1f0290e76d7..080faba578a 100644
--- a/util/src/main/java/io/grpc/util/OutlierDetectionLoadBalancer.java
+++ b/util/src/main/java/io/grpc/util/OutlierDetectionLoadBalancer.java
@@ -171,7 +171,7 @@ public Status acceptResolvedAddresses(ResolvedAddresses resolvedAddresses) {
endpointTrackerMap.cancelTracking();
}
- switchLb.handleResolvedAddresses(
+ switchLb.acceptResolvedAddresses(
resolvedAddresses.toBuilder().setLoadBalancingPolicyConfig(config.childConfig).build());
return Status.OK;
}
diff --git a/util/src/test/java/io/grpc/util/ForwardingLoadBalancerTest.java b/util/src/test/java/io/grpc/util/ForwardingLoadBalancerTest.java
index f9b53400cea..afdbfd77dad 100644
--- a/util/src/test/java/io/grpc/util/ForwardingLoadBalancerTest.java
+++ b/util/src/test/java/io/grpc/util/ForwardingLoadBalancerTest.java
@@ -45,6 +45,8 @@ public void allMethodsForwarded() throws Exception {
mockDelegate,
new TestBalancer(),
Arrays.asList(
- LoadBalancer.class.getMethod("acceptResolvedAddresses", ResolvedAddresses.class)));
+ LoadBalancer.class.getMethod("acceptResolvedAddresses", ResolvedAddresses.class),
+ LoadBalancer.class.getMethod("handleResolvedAddresses", ResolvedAddresses.class))
+ );
}
}
diff --git a/util/src/test/java/io/grpc/util/GracefulSwitchLoadBalancerTest.java b/util/src/test/java/io/grpc/util/GracefulSwitchLoadBalancerTest.java
index f31443ace7b..1c87091a192 100644
--- a/util/src/test/java/io/grpc/util/GracefulSwitchLoadBalancerTest.java
+++ b/util/src/test/java/io/grpc/util/GracefulSwitchLoadBalancerTest.java
@@ -125,17 +125,17 @@ public void switchTo_handleResolvedAddressesAndNameResolutionErrorForwardedToLat
helper0.updateBalancingState(READY, picker);
ResolvedAddresses addresses = newFakeAddresses();
- gracefulSwitchLb.handleResolvedAddresses(addresses);
- verify(lb0).handleResolvedAddresses(addresses);
+ gracefulSwitchLb.acceptResolvedAddresses(addresses);
+ verify(lb0).acceptResolvedAddresses(addresses);
gracefulSwitchLb.handleNameResolutionError(Status.DATA_LOSS);
verify(lb0).handleNameResolutionError(Status.DATA_LOSS);
gracefulSwitchLb.switchTo(lbPolicies[1]);
LoadBalancer lb1 = balancers.get(lbPolicies[1]);
addresses = newFakeAddresses();
- gracefulSwitchLb.handleResolvedAddresses(addresses);
- verify(lb0, never()).handleResolvedAddresses(addresses);
- verify(lb1).handleResolvedAddresses(addresses);
+ gracefulSwitchLb.acceptResolvedAddresses(addresses);
+ verify(lb0, never()).acceptResolvedAddresses(addresses);
+ verify(lb1).acceptResolvedAddresses(addresses);
gracefulSwitchLb.handleNameResolutionError(Status.ALREADY_EXISTS);
verify(lb0, never()).handleNameResolutionError(Status.ALREADY_EXISTS);
verify(lb1).handleNameResolutionError(Status.ALREADY_EXISTS);
@@ -144,10 +144,10 @@ public void switchTo_handleResolvedAddressesAndNameResolutionErrorForwardedToLat
verify(lb1).shutdown();
LoadBalancer lb2 = balancers.get(lbPolicies[2]);
addresses = newFakeAddresses();
- gracefulSwitchLb.handleResolvedAddresses(addresses);
- verify(lb0, never()).handleResolvedAddresses(addresses);
- verify(lb1, never()).handleResolvedAddresses(addresses);
- verify(lb2).handleResolvedAddresses(addresses);
+ gracefulSwitchLb.acceptResolvedAddresses(addresses);
+ verify(lb0, never()).acceptResolvedAddresses(addresses);
+ verify(lb1, never()).acceptResolvedAddresses(addresses);
+ verify(lb2).acceptResolvedAddresses(addresses);
gracefulSwitchLb.handleNameResolutionError(Status.CANCELLED);
verify(lb0, never()).handleNameResolutionError(Status.CANCELLED);
verify(lb1, never()).handleNameResolutionError(Status.CANCELLED);
@@ -591,11 +591,11 @@ public void canHandleEmptyAddressListFromNameResolutionForwardedToLatestPolicy()
public void handleResolvedAddressesAndNameResolutionErrorForwardedToLatestPolicy() {
ResolvedAddresses addresses = newFakeAddresses();
Object child0Config = new Object();
- gracefulSwitchLb.handleResolvedAddresses(addresses.toBuilder()
+ gracefulSwitchLb.acceptResolvedAddresses(addresses.toBuilder()
.setLoadBalancingPolicyConfig(createConfig(lbPolicies[0], child0Config))
.build());
LoadBalancer lb0 = balancers.get(lbPolicies[0]);
- verify(lb0).handleResolvedAddresses(addresses.toBuilder()
+ verify(lb0).acceptResolvedAddresses(addresses.toBuilder()
.setLoadBalancingPolicyConfig(child0Config)
.build());
Helper helper0 = helpers.get(lb0);
@@ -606,14 +606,14 @@ public void handleResolvedAddressesAndNameResolutionErrorForwardedToLatestPolicy
Object child1Config = new Object();
addresses = newFakeAddresses();
- gracefulSwitchLb.handleResolvedAddresses(addresses.toBuilder()
+ gracefulSwitchLb.acceptResolvedAddresses(addresses.toBuilder()
.setLoadBalancingPolicyConfig(createConfig(lbPolicies[1], child1Config))
.build());
LoadBalancer lb1 = balancers.get(lbPolicies[1]);
- verify(lb0, never()).handleResolvedAddresses(addresses.toBuilder()
+ verify(lb0, never()).acceptResolvedAddresses(addresses.toBuilder()
.setLoadBalancingPolicyConfig(child1Config)
.build());
- verify(lb1).handleResolvedAddresses(addresses.toBuilder()
+ verify(lb1).acceptResolvedAddresses(addresses.toBuilder()
.setLoadBalancingPolicyConfig(child1Config)
.build());
gracefulSwitchLb.handleNameResolutionError(Status.ALREADY_EXISTS);
@@ -622,18 +622,18 @@ public void handleResolvedAddressesAndNameResolutionErrorForwardedToLatestPolicy
Object child2Config = new Object();
addresses = newFakeAddresses();
- gracefulSwitchLb.handleResolvedAddresses(addresses.toBuilder()
+ gracefulSwitchLb.acceptResolvedAddresses(addresses.toBuilder()
.setLoadBalancingPolicyConfig(createConfig(lbPolicies[2], child2Config))
.build());
verify(lb1).shutdown();
LoadBalancer lb2 = balancers.get(lbPolicies[2]);
- verify(lb0, never()).handleResolvedAddresses(addresses.toBuilder()
+ verify(lb0, never()).acceptResolvedAddresses(addresses.toBuilder()
.setLoadBalancingPolicyConfig(child2Config)
.build());
- verify(lb1, never()).handleResolvedAddresses(addresses.toBuilder()
+ verify(lb1, never()).acceptResolvedAddresses(addresses.toBuilder()
.setLoadBalancingPolicyConfig(child2Config)
.build());
- verify(lb2).handleResolvedAddresses(addresses.toBuilder()
+ verify(lb2).acceptResolvedAddresses(addresses.toBuilder()
.setLoadBalancingPolicyConfig(child2Config)
.build());
gracefulSwitchLb.handleNameResolutionError(Status.CANCELLED);
diff --git a/util/src/test/java/io/grpc/util/OutlierDetectionLoadBalancerTest.java b/util/src/test/java/io/grpc/util/OutlierDetectionLoadBalancerTest.java
index 1b0139affef..d81740e116a 100644
--- a/util/src/test/java/io/grpc/util/OutlierDetectionLoadBalancerTest.java
+++ b/util/src/test/java/io/grpc/util/OutlierDetectionLoadBalancerTest.java
@@ -280,7 +280,7 @@ public void acceptResolvedAddresses() {
loadBalancer.acceptResolvedAddresses(resolvedAddresses);
// Handling of resolved addresses is delegated
- verify(mockChildLb).handleResolvedAddresses(
+ verify(mockChildLb).acceptResolvedAddresses(
resolvedAddresses.toBuilder().setLoadBalancingPolicyConfig(childConfig).build());
// There is a single pending task to run the outlier detection algorithm
diff --git a/xds/src/test/java/io/grpc/xds/CdsLoadBalancer2Test.java b/xds/src/test/java/io/grpc/xds/CdsLoadBalancer2Test.java
index da32332a2a5..7357817c665 100644
--- a/xds/src/test/java/io/grpc/xds/CdsLoadBalancer2Test.java
+++ b/xds/src/test/java/io/grpc/xds/CdsLoadBalancer2Test.java
@@ -797,8 +797,9 @@ private final class FakeLoadBalancer extends LoadBalancer {
}
@Override
- public void handleResolvedAddresses(ResolvedAddresses resolvedAddresses) {
+ public Status acceptResolvedAddresses(ResolvedAddresses resolvedAddresses) {
config = resolvedAddresses.getLoadBalancingPolicyConfig();
+ return Status.OK;
}
@Override
diff --git a/xds/src/test/java/io/grpc/xds/MetadataLoadBalancerProvider.java b/xds/src/test/java/io/grpc/xds/MetadataLoadBalancerProvider.java
index ecc0112a2e0..45f2337b746 100644
--- a/xds/src/test/java/io/grpc/xds/MetadataLoadBalancerProvider.java
+++ b/xds/src/test/java/io/grpc/xds/MetadataLoadBalancerProvider.java
@@ -108,11 +108,11 @@ protected LoadBalancer delegate() {
}
@Override
- public void handleResolvedAddresses(ResolvedAddresses resolvedAddresses) {
+ public Status acceptResolvedAddresses(ResolvedAddresses resolvedAddresses) {
MetadataLoadBalancerConfig config
= (MetadataLoadBalancerConfig) resolvedAddresses.getLoadBalancingPolicyConfig();
helper.setMetadata(config.metadataKey, config.metadataValue);
- delegateLb.handleResolvedAddresses(resolvedAddresses);
+ return delegateLb.acceptResolvedAddresses(resolvedAddresses);
}
}
diff --git a/xds/src/test/java/io/grpc/xds/PriorityLoadBalancerTest.java b/xds/src/test/java/io/grpc/xds/PriorityLoadBalancerTest.java
index fafcd4d674a..a79af4cb66c 100644
--- a/xds/src/test/java/io/grpc/xds/PriorityLoadBalancerTest.java
+++ b/xds/src/test/java/io/grpc/xds/PriorityLoadBalancerTest.java
@@ -141,7 +141,7 @@ public void tearDown() {
}
@Test
- public void handleResolvedAddresses() {
+ public void acceptResolvedAddresses() {
SocketAddress socketAddress = new InetSocketAddress(8080);
EquivalentAddressGroup eag = new EquivalentAddressGroup(socketAddress);
eag = AddressFilter.setPathFilter(eag, ImmutableList.of("p1"));
@@ -162,7 +162,7 @@ public void handleResolvedAddresses() {
ImmutableMap.of("p0", priorityChildConfig0, "p1", priorityChildConfig1,
"p2", priorityChildConfig2),
ImmutableList.of("p0", "p1", "p2"));
- priorityLb.handleResolvedAddresses(
+ priorityLb.acceptResolvedAddresses(
ResolvedAddresses.newBuilder()
.setAddresses(addresses)
.setAttributes(attributes)
@@ -171,7 +171,7 @@ public void handleResolvedAddresses() {
assertThat(fooBalancers).hasSize(1);
assertThat(barBalancers).isEmpty();
LoadBalancer fooBalancer0 = Iterables.getOnlyElement(fooBalancers);
- verify(fooBalancer0).handleResolvedAddresses(resolvedAddressesCaptor.capture());
+ verify(fooBalancer0).acceptResolvedAddresses(resolvedAddressesCaptor.capture());
ResolvedAddresses addressesReceived = resolvedAddressesCaptor.getValue();
assertThat(addressesReceived.getAddresses()).isEmpty();
assertThat(addressesReceived.getAttributes()).isEqualTo(attributes);
@@ -182,7 +182,7 @@ public void handleResolvedAddresses() {
assertThat(fooBalancers).hasSize(1);
assertThat(barBalancers).hasSize(1);
LoadBalancer barBalancer0 = Iterables.getOnlyElement(barBalancers);
- verify(barBalancer0).handleResolvedAddresses(resolvedAddressesCaptor.capture());
+ verify(barBalancer0).acceptResolvedAddresses(resolvedAddressesCaptor.capture());
addressesReceived = resolvedAddressesCaptor.getValue();
assertThat(Iterables.getOnlyElement(addressesReceived.getAddresses()).getAddresses())
.containsExactly(socketAddress);
@@ -194,7 +194,7 @@ public void handleResolvedAddresses() {
assertThat(fooBalancers).hasSize(2);
assertThat(barBalancers).hasSize(1);
LoadBalancer fooBalancer1 = Iterables.getLast(fooBalancers);
- verify(fooBalancer1).handleResolvedAddresses(resolvedAddressesCaptor.capture());
+ verify(fooBalancer1).acceptResolvedAddresses(resolvedAddressesCaptor.capture());
addressesReceived = resolvedAddressesCaptor.getValue();
assertThat(addressesReceived.getAddresses()).isEmpty();
assertThat(addressesReceived.getAttributes()).isEqualTo(attributes);
@@ -211,14 +211,14 @@ public void handleResolvedAddresses() {
ImmutableMap.of("p1",
new PriorityChildConfig(newChildConfig(barLbProvider, newBarConfig), true)),
ImmutableList.of("p1"));
- priorityLb.handleResolvedAddresses(
+ priorityLb.acceptResolvedAddresses(
ResolvedAddresses.newBuilder()
.setAddresses(newAddresses)
.setLoadBalancingPolicyConfig(newPriorityLbConfig)
.build());
assertThat(fooBalancers).hasSize(2);
assertThat(barBalancers).hasSize(1);
- verify(barBalancer0, times(2)).handleResolvedAddresses(resolvedAddressesCaptor.capture());
+ verify(barBalancer0, times(2)).acceptResolvedAddresses(resolvedAddressesCaptor.capture());
addressesReceived = resolvedAddressesCaptor.getValue();
assertThat(Iterables.getOnlyElement(addressesReceived.getAddresses()).getAddresses())
.containsExactly(newSocketAddress);
@@ -243,7 +243,7 @@ public void handleNameResolutionError() {
PriorityLbConfig priorityLbConfig =
new PriorityLbConfig(ImmutableMap.of("p0", priorityChildConfig0), ImmutableList.of("p0"));
- priorityLb.handleResolvedAddresses(
+ priorityLb.acceptResolvedAddresses(
ResolvedAddresses.newBuilder()
.setAddresses(ImmutableList.of())
.setLoadBalancingPolicyConfig(priorityLbConfig)
@@ -255,7 +255,7 @@ public void handleNameResolutionError() {
priorityLbConfig =
new PriorityLbConfig(ImmutableMap.of("p1", priorityChildConfig1), ImmutableList.of("p1"));
- priorityLb.handleResolvedAddresses(
+ priorityLb.acceptResolvedAddresses(
ResolvedAddresses.newBuilder()
.setAddresses(ImmutableList.of())
.setLoadBalancingPolicyConfig(priorityLbConfig)
@@ -286,7 +286,7 @@ public void typicalPriorityFailOverFlow() {
ImmutableMap.of("p0", priorityChildConfig0, "p1", priorityChildConfig1,
"p2", priorityChildConfig2, "p3", priorityChildConfig3),
ImmutableList.of("p0", "p1", "p2", "p3"));
- priorityLb.handleResolvedAddresses(
+ priorityLb.acceptResolvedAddresses(
ResolvedAddresses.newBuilder()
.setAddresses(ImmutableList.of())
.setLoadBalancingPolicyConfig(priorityLbConfig)
@@ -419,7 +419,7 @@ public void idleToConnectingDoesNotTriggerFailOver() {
new PriorityLbConfig(
ImmutableMap.of("p0", priorityChildConfig0, "p1", priorityChildConfig1),
ImmutableList.of("p0", "p1"));
- priorityLb.handleResolvedAddresses(
+ priorityLb.acceptResolvedAddresses(
ResolvedAddresses.newBuilder()
.setAddresses(ImmutableList.of())
.setLoadBalancingPolicyConfig(priorityLbConfig)
@@ -455,7 +455,7 @@ public void connectingResetFailOverIfSeenReadyOrIdleSinceTransientFailure() {
new PriorityLbConfig(
ImmutableMap.of("p0", priorityChildConfig0, "p1", priorityChildConfig1),
ImmutableList.of("p0", "p1"));
- priorityLb.handleResolvedAddresses(
+ priorityLb.acceptResolvedAddresses(
ResolvedAddresses.newBuilder()
.setAddresses(ImmutableList.of())
.setLoadBalancingPolicyConfig(priorityLbConfig)
@@ -497,7 +497,7 @@ public void readyToConnectDoesNotFailOverButUpdatesPicker() {
new PriorityLbConfig(
ImmutableMap.of("p0", priorityChildConfig0, "p1", priorityChildConfig1),
ImmutableList.of("p0", "p1"));
- priorityLb.handleResolvedAddresses(
+ priorityLb.acceptResolvedAddresses(
ResolvedAddresses.newBuilder()
.setAddresses(ImmutableList.of())
.setLoadBalancingPolicyConfig(priorityLbConfig)
@@ -530,7 +530,7 @@ public PickResult pickSubchannel(PickSubchannelArgs args) {
// resolution update without priority change does not trigger failover
Attributes.Key fooKey = Attributes.Key.create("fooKey");
- priorityLb.handleResolvedAddresses(
+ priorityLb.acceptResolvedAddresses(
ResolvedAddresses.newBuilder()
.setAddresses(ImmutableList.of())
.setLoadBalancingPolicyConfig(priorityLbConfig)
@@ -559,7 +559,7 @@ public void typicalPriorityFailOverFlowWithIdleUpdate() {
ImmutableMap.of("p0", priorityChildConfig0, "p1", priorityChildConfig1,
"p2", priorityChildConfig2, "p3", priorityChildConfig3),
ImmutableList.of("p0", "p1", "p2", "p3"));
- priorityLb.handleResolvedAddresses(
+ priorityLb.acceptResolvedAddresses(
ResolvedAddresses.newBuilder()
.setAddresses(ImmutableList.of())
.setLoadBalancingPolicyConfig(priorityLbConfig)
@@ -662,7 +662,7 @@ public void bypassReresolutionRequestsIfConfiged() {
new PriorityLbConfig(
ImmutableMap.of("p0", priorityChildConfig0, "p1", priorityChildConfig1),
ImmutableList.of("p0", "p1"));
- priorityLb.handleResolvedAddresses(
+ priorityLb.acceptResolvedAddresses(
ResolvedAddresses.newBuilder()
.setAddresses(ImmutableList.of())
.setLoadBalancingPolicyConfig(priorityLbConfig)
@@ -690,7 +690,7 @@ public void raceBetweenShutdownAndChildLbBalancingStateUpdate() {
new PriorityLbConfig(
ImmutableMap.of("p0", priorityChildConfig0, "p1", priorityChildConfig1),
ImmutableList.of("p0", "p1"));
- priorityLb.handleResolvedAddresses(
+ priorityLb.acceptResolvedAddresses(
ResolvedAddresses.newBuilder()
.setAddresses(ImmutableList.of())
.setLoadBalancingPolicyConfig(priorityLbConfig)
@@ -717,7 +717,7 @@ public void noDuplicateOverallBalancingStateUpdate() {
new PriorityLbConfig(
ImmutableMap.of("p0", priorityChildConfig0),
ImmutableList.of("p0"));
- priorityLb.handleResolvedAddresses(
+ priorityLb.acceptResolvedAddresses(
ResolvedAddresses.newBuilder()
.setAddresses(ImmutableList.of())
.setLoadBalancingPolicyConfig(priorityLbConfig)
@@ -727,7 +727,7 @@ public void noDuplicateOverallBalancingStateUpdate() {
new PriorityLbConfig(
ImmutableMap.of("p0", priorityChildConfig0, "p1", priorityChildConfig1),
ImmutableList.of("p0", "p1"));
- priorityLb.handleResolvedAddresses(
+ priorityLb.acceptResolvedAddresses(
ResolvedAddresses.newBuilder()
.setAddresses(ImmutableList.of())
.setLoadBalancingPolicyConfig(priorityLbConfig)
@@ -801,9 +801,10 @@ static class FakeLoadBalancer extends LoadBalancer {
}
@Override
- public void handleResolvedAddresses(ResolvedAddresses resolvedAddresses) {
+ public Status acceptResolvedAddresses(ResolvedAddresses resolvedAddresses) {
helper.updateBalancingState(
TRANSIENT_FAILURE, new FixedResultPicker(PickResult.withError(Status.INTERNAL)));
+ return Status.OK;
}
@Override
diff --git a/xds/src/test/java/io/grpc/xds/WeightedTargetLoadBalancerTest.java b/xds/src/test/java/io/grpc/xds/WeightedTargetLoadBalancerTest.java
index cc6cb98412c..46fe3881167 100644
--- a/xds/src/test/java/io/grpc/xds/WeightedTargetLoadBalancerTest.java
+++ b/xds/src/test/java/io/grpc/xds/WeightedTargetLoadBalancerTest.java
@@ -180,7 +180,7 @@ public void tearDown() {
}
@Test
- public void handleResolvedAddresses() {
+ public void acceptResolvedAddresses() {
ArgumentCaptor resolvedAddressesCaptor =
ArgumentCaptor.forClass(ResolvedAddresses.class);
Attributes.Key