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

loadbalancer-experimental: fix some raw types usages #3133

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void cleanup() {
}
}

private void buildHost(@Nullable HealthIndicator healthIndicator) {
private void buildHost(@Nullable HealthIndicator<String, TestLoadBalancedConnection> healthIndicator) {
host = new DefaultHost<>("lbDescription", DEFAULT_ADDRESS,
LinearSearchConnectionSelector.<TestLoadBalancedConnection>factory(DEFAULT_LINEAR_SEARCH_SPACE)
.buildConnectionSelector("resource"),
Expand Down Expand Up @@ -206,7 +206,7 @@ void hostStatus() throws Exception {

@Test
void healthIndicatorInfluencesHealthStatus() {
HealthIndicator healthIndicator = mock(HealthIndicator.class);
HealthIndicator<String, TestLoadBalancedConnection> healthIndicator = mock(HealthIndicator.class);
when(healthIndicator.isHealthy()).thenReturn(true);
buildHost(healthIndicator);
assertThat(host.isHealthy(), is(true));
Expand All @@ -216,7 +216,7 @@ void healthIndicatorInfluencesHealthStatus() {

@Test
void forwardsHealthIndicatorScore() {
HealthIndicator healthIndicator = mock(HealthIndicator.class);
HealthIndicator<String, TestLoadBalancedConnection> healthIndicator = mock(HealthIndicator.class);
when(healthIndicator.score()).thenReturn(10);
buildHost(healthIndicator);
assertThat(host.score(), is(10));
Expand All @@ -226,7 +226,7 @@ void forwardsHealthIndicatorScore() {
@Test
void connectFailuresAreForwardedToHealthIndicator() {
connectionFactory = new TestConnectionFactory(address -> failed(DELIBERATE_EXCEPTION));
HealthIndicator healthIndicator = mock(HealthIndicator.class);
HealthIndicator<String, TestLoadBalancedConnection> healthIndicator = mock(HealthIndicator.class);
buildHost(healthIndicator);
Throwable underlying = assertThrows(ExecutionException.class, () ->
host.newConnection(cxn -> true, false, null).toFuture().get()).getCause();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ static List<Host<String, TestLoadBalancedConnection>> generateHosts(boolean equa
return results;
}

private static Host mockHost(String addr, TestLoadBalancedConnection connection) {
private static Host<String, TestLoadBalancedConnection> mockHost(
String addr, TestLoadBalancedConnection connection) {
Host<String, TestLoadBalancedConnection> host = mock(Host.class);
when(host.address()).thenReturn(addr);
when(host.isHealthy()).thenReturn(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ void healthChecksAreScheduled() {
void cancellation() {
config = withAllEnforcing().maxEjectionPercentage(100).build();
outlierDetector = buildOutlierDetector();
HealthIndicator indicator1 = outlierDetector.newHealthIndicator("address-1", observer());
HealthIndicator indicator2 = outlierDetector.newHealthIndicator("address-2", observer());
HealthIndicator<String, TestLoadBalancedConnection> indicator1 =
outlierDetector.newHealthIndicator("address-1", observer());
HealthIndicator<String, TestLoadBalancedConnection> indicator2 =
outlierDetector.newHealthIndicator("address-2", observer());
eject(indicator1);
eject(indicator2);
assertFalse(indicator1.isHealthy());
Expand Down Expand Up @@ -110,7 +112,8 @@ void withoutOutlierDetectorsWeStillDecrementFailureMultiplier() {
.build();
outlierDetector = buildOutlierDetector();

HealthIndicator indicator1 = outlierDetector.newHealthIndicator("address-1", observer());
HealthIndicator<String, TestLoadBalancedConnection> indicator1 =
outlierDetector.newHealthIndicator("address-1", observer());
eject(indicator1);
assertFalse(indicator1.isHealthy());
testExecutor.advanceTimeBy(config.baseEjectionTime().toNanos(), TimeUnit.NANOSECONDS);
Expand All @@ -133,12 +136,12 @@ void withoutOutlierDetectorsWeStillDecrementFailureMultiplier() {
private void testEjectPercentage(int maxEjectPercentage) {
config = withAllEnforcing().maxEjectionPercentage(maxEjectPercentage).build();
outlierDetector = buildOutlierDetector();
List<HealthIndicator> healthIndicators = new ArrayList<>(4);
List<HealthIndicator<String, TestLoadBalancedConnection>> healthIndicators = new ArrayList<>(4);
for (int i = 0; i < 4; i++) {
healthIndicators.add(outlierDetector.newHealthIndicator("address-" + i, observer()));
}

for (HealthIndicator indicator : healthIndicators) {
for (HealthIndicator<String, TestLoadBalancedConnection> indicator : healthIndicators) {
eject(indicator);
}

Expand All @@ -147,7 +150,7 @@ private void testEjectPercentage(int maxEjectPercentage) {
.filter(indicator -> !indicator.isHealthy()).collect(Collectors.toList()), hasSize(expectedFailed));
}

private void eject(HealthIndicator indicator) {
private void eject(HealthIndicator<String, TestLoadBalancedConnection> indicator) {
for (int i = 0; i < config.consecutive5xx(); i++) {
if (!indicator.isHealthy()) {
break;
Expand Down
Loading