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: Javadoc changes for io.grpc.LoadBalancer method signatures #11623

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ab97045
SynchronizationContextTest changes for scheduleFixedDelay with Duration
SreeramdasLavanya Sep 20, 2024
fef4c92
Revert "SynchronizationContextTest changes for scheduleFixedDelay wit…
SreeramdasLavanya Sep 20, 2024
778cfb4
Merge branch 'grpc:master' into master
SreeramdasLavanya Sep 23, 2024
328bcbf
Merge branch 'grpc:master' into master
SreeramdasLavanya Sep 24, 2024
6a66054
Merge branch 'grpc:master' into master
SreeramdasLavanya Sep 26, 2024
4113845
Merge branch 'grpc:master' into master
SreeramdasLavanya Oct 1, 2024
09c3509
Merge branch 'grpc:master' into master
SreeramdasLavanya Oct 8, 2024
62a88ec
Merge branch 'grpc:master' into master
SreeramdasLavanya Oct 9, 2024
f658685
Merge branch 'grpc:master' into master
SreeramdasLavanya Oct 11, 2024
c51a5e4
Merge branch 'grpc:master' into master
SreeramdasLavanya Oct 15, 2024
02e92c5
Merge branch 'grpc:master' into master
SreeramdasLavanya Oct 17, 2024
4c31880
api: Javadoc changes for LoadBalancer method signatures
SreeramdasLavanya Oct 17, 2024
9ddcb09
api: Changes for UNAVAILABLE to Status.UNAVAILABLE and Status.OK
SreeramdasLavanya Oct 21, 2024
596d11d
api: Check style fix for UNAVAILABLE to Status.UNAVAILABLE and Status.OK
SreeramdasLavanya Oct 21, 2024
d9bf85e
api: Check style fix for Status.UNAVAILABLE and Status.OK
SreeramdasLavanya Oct 21, 2024
401a7d2
api: Check style fix for Status.UNAVAILABLE
SreeramdasLavanya Oct 21, 2024
f388ac2
api: Check style fix for Status.UNAVAILABLE
SreeramdasLavanya Oct 21, 2024
cb315f0
Merge branch 'grpc:master' into FixIssue-11194
SreeramdasLavanya Oct 25, 2024
380345c
Merge branch 'grpc:master' into FixIssue-11194
SreeramdasLavanya Oct 28, 2024
846eb00
api/util/services: Deprected handleResolvedAddresses method and relat…
SreeramdasLavanya Oct 28, 2024
ee36c4e
interop-testing: Changes for deprecated handleResolvedAddresses metho…
SreeramdasLavanya Oct 29, 2024
b1f857f
xds: Changes for deprecated handleResolvedAddresses method and relate…
SreeramdasLavanya Oct 29, 2024
891b547
Merge branch 'grpc:master' into FixIssue-11194
SreeramdasLavanya Oct 30, 2024
6d3abf0
api: Reverted changes for LoadBalancer and LoadBalancerTest
SreeramdasLavanya Nov 4, 2024
ca3e613
Merge branch 'grpc:master' into FixIssue-11194
SreeramdasLavanya Nov 4, 2024
47002fe
util: Replaced handleResolvedAddress to acceptResolvedAddresses.
SreeramdasLavanya Nov 4, 2024
cb85563
api: Reverted back to acceptResolvedAddress
SreeramdasLavanya Nov 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions api/src/main/java/io/grpc/LoadBalancer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
* <p>Implementations should not modify the given {@code servers}.
* <p>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
Expand All @@ -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.
*
* <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 Status.UNAVAILABLE}.
*
* <p>Implementations should not modify the given {@code addresses}.
* <p>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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,14 @@ protected LoadBalancer delegate() {
}

@Override
public void handleResolvedAddresses(ResolvedAddresses resolvedAddresses) {
public Status acceptResolvedAddresses(ResolvedAddresses resolvedAddresses) {
Map<String, ?> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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
Expand All @@ -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);
Expand All @@ -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());
Expand All @@ -738,15 +739,15 @@ public void serviceConfigDisablesHealthCheckWhenRpcActive() {
.setAddresses(resolvedAddressList)
.setAttributes(Attributes.EMPTY)
.build();
hcLbEventDelivery.handleResolvedAddresses(result2);
hcLbEventDelivery.acceptResolvedAddresses(result2);

// Health check RPC cancelled.
assertThat(serverCall.cancelled).isTrue();
// Subchannel uses original state
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();
Expand All @@ -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];
Expand Down Expand Up @@ -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();
Expand All @@ -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]);
}
Expand All @@ -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());
Expand All @@ -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));
Expand All @@ -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];
Expand Down Expand Up @@ -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.
Expand All @@ -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();
Expand All @@ -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];
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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());
Expand All @@ -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);

Expand All @@ -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));
Expand Down Expand Up @@ -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];

Expand Down Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions util/src/main/java/io/grpc/util/ForwardingLoadBalancer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading