Skip to content

Commit

Permalink
lb:Implement LeastRequestLB as a petiole policy and restore RR and WRR (
Browse files Browse the repository at this point in the history
grpc#10584)

* Change LeastRequest, Round Robin and WeightedRoundRobin into petiole policies
  • Loading branch information
larry-safran authored Oct 16, 2023
1 parent fc03f2b commit 0d39bf5
Show file tree
Hide file tree
Showing 16 changed files with 1,532 additions and 1,029 deletions.
3 changes: 3 additions & 0 deletions api/src/main/java/io/grpc/EquivalentAddressGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ public int hashCode() {
*/
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof EquivalentAddressGroup)) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
/** Unit tests for {@link ManagedChannelImpl}. */
@RunWith(JUnit4.class)
// TODO(creamsoup) remove backward compatible check when fully migrated
@SuppressWarnings("deprecation")
@SuppressWarnings({"deprecation"})
public class ManagedChannelImplTest {
private static final int DEFAULT_PORT = 447;

Expand Down
10 changes: 10 additions & 0 deletions core/src/testFixtures/java/io/grpc/internal/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import io.grpc.Attributes;
import io.grpc.CallOptions;
import io.grpc.ChannelLogger;
import io.grpc.ClientStreamTracer;
import io.grpc.EquivalentAddressGroup;
import io.grpc.InternalLogId;
import io.grpc.LoadBalancer.PickResult;
import io.grpc.LoadBalancer.PickSubchannelArgs;
Expand Down Expand Up @@ -143,6 +145,14 @@ public Runnable answer(InvocationOnMock invocation) throws Throwable {
return captor;
}

@SuppressWarnings("ReferenceEquality")
public static final EquivalentAddressGroup stripAttrs(EquivalentAddressGroup eag) {
if (eag.getAttributes() == Attributes.EMPTY) {
return eag;
}
return new EquivalentAddressGroup(eag.getAddresses());
}

private TestUtils() {
}

Expand Down
12 changes: 10 additions & 2 deletions util/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id "java-library"
id "java-test-fixtures"
id "maven-publish"

id "me.champeau.jmh"
Expand All @@ -19,11 +20,18 @@ dependencies {

implementation libraries.animalsniffer.annotations,
libraries.guava
testImplementation testFixtures(project(':grpc-api')),
testImplementation libraries.guava.testlib,
testFixtures(project(':grpc-api')),
testFixtures(project(':grpc-core')),
project(':grpc-testing')
testImplementation libraries.guava.testlib

testFixturesApi project(':grpc-core')
testFixturesImplementation libraries.guava,
libraries.junit,
libraries.mockito.core,
testFixtures(project(':grpc-api')),
testFixtures(project(':grpc-core')),
project(':grpc-testing')
jmh project(':grpc-testing')

signature libraries.signature.java
Expand Down
Loading

0 comments on commit 0d39bf5

Please sign in to comment.