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: Some style cleanups for the new LB #2748

Merged
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 @@ -35,7 +35,7 @@ protected final String getTargetResource() {
return targetResource;
}

protected final Single<C> noActiveHostsException(List<Host<ResolvedAddress, C>> usedHosts) {
protected final Single<C> noActiveHosts(List<Host<ResolvedAddress, C>> usedHosts) {
return failed(Exceptions.StacklessNoActiveHostException.newInstance("Failed to pick an active host for " +
getTargetResource() + ". Either all are busy, expired, or unhealthy: " + usedHosts,
this.getClass(), "selectConnection(...)"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import static io.servicetalk.concurrent.api.Single.succeeded;
import static io.servicetalk.concurrent.internal.FlowControlUtils.addWithOverflowProtection;
import static java.lang.Math.min;
import static java.util.Objects.requireNonNull;
import static java.util.concurrent.atomic.AtomicReferenceFieldUpdater.newUpdater;
import static java.util.stream.Collectors.toList;

Expand Down Expand Up @@ -99,13 +100,14 @@ private enum State {
private final ListenableAsyncCloseable closeable;
private volatile ConnState connState = ACTIVE_EMPTY_CONN_STATE;

DefaultHost(String lbDescription, Addr address, ConnectionFactory<Addr, ? extends C> connectionFactory,
DefaultHost(final String lbDescription, final Addr address,
final ConnectionFactory<Addr, ? extends C> connectionFactory,
int linearSearchSpace, @Nullable HealthCheckConfig healthCheckConfig) {
this.lbDescription = lbDescription;
this.address = address;
this.healthCheckConfig = healthCheckConfig;
this.connectionFactory = connectionFactory;
this.lbDescription = requireNonNull(lbDescription, "lbDescription");
this.address = requireNonNull(address, "address");
this.linearSearchSpace = linearSearchSpace;
this.connectionFactory = requireNonNull(connectionFactory, "connectionFactory");
this.healthCheckConfig = healthCheckConfig;
this.closeable = toAsyncCloseable(graceful ->
graceful ? doClose(AsyncCloseable::closeAsyncGracefully) : doClose(AsyncCloseable::closeAsync));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public Single<C> selectConnection(
// try to make a new one if the host is healthy. If it's not healthy, we fail
// and let the higher level retries decide what to do.
if (!host.isActiveAndHealthy()) {
return noActiveHostsException(hosts);
return noActiveHosts(hosts);
}
return host.newConnection(selector, forceNewConnectionAndReserve, context);
default:
Expand Down Expand Up @@ -127,7 +127,7 @@ private Single<C> p2c(int size, List<Host<ResolvedAddress, C>> hosts, Random ran
// Neither are healthy and capable of making a connection: fall through, perhaps for another attempt.
}
// Max effort exhausted. We failed to find a healthy and active host.
return noActiveHostsException(hosts);
return noActiveHosts(hosts);
}

private Random getRandom() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public Single<C> selectConnection(
}
}
if (pickedHost == null) {
return noActiveHostsException(usedHosts);
return noActiveHosts(usedHosts);
}
// We have a host but no connection was selected: create a new one.
return pickedHost.newConnection(selector, forceNewConnectionAndReserve, context);
Expand Down
Loading