Skip to content
Open
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 @@ -54,7 +54,8 @@
import io.servicetalk.http.netty.ReservableRequestConcurrencyControllers.InternalRetryingHttpClientFilter;
import io.servicetalk.http.utils.HostHeaderHttpRequesterFilter;
import io.servicetalk.http.utils.IdleTimeoutConnectionFilter;
import io.servicetalk.loadbalancer.RoundRobinLoadBalancers;
import io.servicetalk.loadbalancer.LoadBalancers;
import io.servicetalk.loadbalancer.OutlierDetectorConfigs;
import io.servicetalk.logging.api.LogLevel;
import io.servicetalk.transport.api.ClientSslConfig;
import io.servicetalk.transport.api.DomainSocketAddress;
Expand Down Expand Up @@ -839,8 +840,11 @@ default StreamingHttpClientFilter create(FilterableStreamingHttpClient client) {

private static <ResolvedAddress> HttpLoadBalancerFactory<ResolvedAddress> defaultLoadBalancer() {
return new DefaultHttpLoadBalancerFactory<>(
RoundRobinLoadBalancers.<ResolvedAddress, FilterableStreamingHttpLoadBalancedConnection>builder(
DefaultHttpLoadBalancerFactory.class.getSimpleName()).build());
LoadBalancers.<ResolvedAddress, FilterableStreamingHttpLoadBalancedConnection>builder(
DefaultHttpLoadBalancerFactory.class.getSimpleName())
// For now, only use the l4 detection to reproduce the old RoundRobinLoadBalancer behavior
.outlierDetectorConfig(OutlierDetectorConfigs.l4Only())
.build());
}

// Because of the change in https://github.com/apple/servicetalk/pull/2379, we should constrain the type back to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
import io.servicetalk.http.api.ProxyConfig;
import io.servicetalk.http.api.SingleAddressHttpClientBuilder;
import io.servicetalk.http.api.StreamingHttpRequest;
import io.servicetalk.loadbalancer.RoundRobinLoadBalancers;
import io.servicetalk.loadbalancer.LoadBalancers;
import io.servicetalk.loadbalancer.OutlierDetectorConfigs;
import io.servicetalk.transport.api.HostAndPort;
import io.servicetalk.transport.api.TransportObserver;

Expand Down Expand Up @@ -485,12 +486,14 @@ private static <U, R> SingleAddressHttpClientBuilder<U, R> forSingleAddress(
.retryServiceDiscoveryErrors(NoRetriesStrategy.INSTANCE)
// Disable health-checking:
.loadBalancerFactory(new DefaultHttpLoadBalancerFactory<>(
RoundRobinLoadBalancers.<R, FilterableStreamingHttpLoadBalancedConnection>builder(
LoadBalancers.<R, FilterableStreamingHttpLoadBalancedConnection>builder(
// Use a different ID to let providers distinguish this LB from the default one
DefaultHttpLoadBalancerFactory.class.getSimpleName() + '-' +
DiscoveryStrategy.ON_NEW_CONNECTION.name())
.healthCheckFailedConnectionsThreshold(-1)
.build()))
// Disable all outlier detection since we're really using the
// Host as the load balancer and not the LoadBalancer itself.
.outlierDetectorConfig(OutlierDetectorConfigs.disabled())
.build()))
.appendConnectionFactoryFilter(resolvingConnectionFactory.get());
default:
throw new IllegalArgumentException("Unsupported strategy: " + discoveryStrategy);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright © 2025 Apple Inc. and the ServiceTalk project authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.servicetalk.loadbalancer;

import java.time.Duration;

/**
* Useful default {@link OutlierDetectorConfig} values.
*
* The configuration values can be used as a base layer for configuration and then modified using the
* {@link OutlierDetectorConfig.Builder} constructor as follows:
* <pre>{@code
* OutlierDetectorConfig config = new OutlierDetectorConfig.Builder(disabled())
Copy link
Member

Choose a reason for hiding this comment

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

This copy constructor is not public

Copy link
Member

Choose a reason for hiding this comment

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

Also, consider adding @link or @see to OutlierDetectorConfigs from OutlierDetectorConfig and OutlierDetectorConfig.Builder javadoc

* .failedConnectionsThreshold(2)
* .build();
* }</pre>
*/
public final class OutlierDetectorConfigs {

private static final OutlierDetectorConfig L4_ONLY =
new OutlierDetectorConfig.Builder()
.ewmaHalfLife(Duration.ZERO)
.enforcingFailurePercentage(0)
.enforcingSuccessRate(0)
.enforcingConsecutive5xx(0)
.build();

private static final OutlierDetectorConfig DISABLED =
new OutlierDetectorConfig.Builder(L4_ONLY)
.failedConnectionsThreshold(-1)
.build();

private OutlierDetectorConfigs() {
// no instances
}

/**
* {@link OutlierDetectorConfig} that only enables the default consecutive connection failure detection.
* @return the {@link OutlierDetectorConfig}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @return the {@link OutlierDetectorConfig}
* @return the {@link OutlierDetectorConfig} that only enables the default consecutive connection failure detection.

*/
public static OutlierDetectorConfig l4Only() {
Copy link
Member

Choose a reason for hiding this comment

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

Do you have any other name ideas for this one? WDYT about onlyConnectFailures()? l4 might be a bit encryptive for some users

return L4_ONLY;
}

/**
* {@link OutlierDetectorConfig} that disables all outlier detection.
* @return the {@link OutlierDetectorConfig}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @return the {@link OutlierDetectorConfig}
* @return the {@link OutlierDetectorConfig} that disables all outlier detection.

*/
public static OutlierDetectorConfig disabled() {
return DISABLED;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,10 @@ private <T extends C> LoadBalancer<T> buildDefaultLoadBalancerFactory(
backgroundExecutor = healthCheckConfig.executor;
}

OutlierDetectorConfig outlierDetectorConfig = new OutlierDetectorConfig.Builder()
.ewmaHalfLife(Duration.ZERO)
// disable the xDS outlier detectors
.enforcingFailurePercentage(0)
.enforcingSuccessRate(0)
.enforcingConsecutive5xx(0)
// set the ServiceTalk L4 connection outlier detector settings
OutlierDetectorConfig outlierDetectorConfig =
// Start with outlier detection disabled. When we set failedConnectionsThreshold it may turn
// L4 outlier detection back on.
new OutlierDetectorConfig.Builder(OutlierDetectorConfigs.disabled())
.failedConnectionsThreshold(healthCheckFailedConnectionsThreshold)
.failureDetectorInterval(healthCheckInterval, healthCheckJitter)
.serviceDiscoveryResubscribeInterval(healthCheckResubscribeInterval, healthCheckResubscribeJitter)
Expand Down