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 22 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
20 changes: 12 additions & 8 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 All @@ -197,7 +201,7 @@ public Status acceptResolvedAddresses(ResolvedAddresses resolvedAddresses) {
return unavailableStatus;
} else {
if (recursionCount++ == 0) {
handleResolvedAddresses(resolvedAddresses);
//handleResolvedAddresses(resolvedAddresses);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have you commented this out?

}
recursionCount = 0;

Expand Down
14 changes: 8 additions & 6 deletions api/src/test/java/io/grpc/LoadBalancerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public void shutdown() {
new EquivalentAddressGroup(new SocketAddress(){}));
ResolvedAddresses addresses = ResolvedAddresses.newBuilder().setAddresses(servers)
.setAttributes(attrs).build();
balancer.handleResolvedAddresses(addresses);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed not to change this test.

balancer.acceptResolvedAddresses(addresses);
assertThat(resultCapture.get()).isEqualTo(
ResolvedAddresses.newBuilder().setAddresses(servers).setAttributes(attrs).build());
}
Expand All @@ -275,8 +275,9 @@ public void acceptResolvedAddresses_delegatesToHandleResolvedAddressGroups() {

LoadBalancer balancer = new LoadBalancer() {
@Override
public void handleResolvedAddresses(ResolvedAddresses addresses) {
public Status acceptResolvedAddresses(ResolvedAddresses addresses) {
addressesCapture.set(addresses);
return Status.OK;
}

@Override
Expand All @@ -297,7 +298,7 @@ public void shutdown() {
new EquivalentAddressGroup(new SocketAddress(){}));
ResolvedAddresses addresses = ResolvedAddresses.newBuilder().setAddresses(servers)
.setAttributes(attrs).build();
balancer.handleResolvedAddresses(addresses);
balancer.acceptResolvedAddresses(addresses);
assertThat(addressesCapture.get().getAddresses()).isEqualTo(servers);
assertThat(addressesCapture.get().getAttributes()).isEqualTo(attrs);
}
Expand All @@ -309,9 +310,10 @@ public void acceptResolvedAddresses_noInfiniteLoop() {

LoadBalancer balancer = new LoadBalancer() {
@Override
public void handleResolvedAddresses(ResolvedAddresses addresses) {
public Status acceptResolvedAddresses(ResolvedAddresses addresses) {
addressesCapture.add(addresses);
super.handleResolvedAddresses(addresses);
super.acceptResolvedAddresses(addresses);
return Status.OK;
}

@Override
Expand All @@ -328,7 +330,7 @@ public void shutdown() {
new EquivalentAddressGroup(new SocketAddress(){}));
ResolvedAddresses addresses = ResolvedAddresses.newBuilder().setAddresses(servers)
.setAttributes(attrs).build();
balancer.handleResolvedAddresses(addresses);
balancer.acceptResolvedAddresses(addresses);
assertThat(addressesCapture).hasSize(1);
assertThat(addressesCapture.get(0).getAddresses()).isEqualTo(servers);
assertThat(addressesCapture.get(0).getAttributes()).isEqualTo(attrs);
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
Loading