Skip to content

util: Mark OutlierDetectionLb classes final #12141

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

Merged
merged 2 commits into from
Jun 13, 2025
Merged
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
28 changes: 14 additions & 14 deletions util/src/main/java/io/grpc/util/OutlierDetectionLoadBalancer.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public void shutdown() {
* This timer will be invoked periodically, according to configuration, and it will look for any
* outlier subchannels.
*/
class DetectionTimer implements Runnable {
final class DetectionTimer implements Runnable {

OutlierDetectionLoadBalancerConfig config;
ChannelLogger logger;
Expand Down Expand Up @@ -217,7 +217,7 @@ public void run() {
* This child helper wraps the provided helper so that it can hand out wrapped {@link
* OutlierDetectionSubchannel}s and manage the address info map.
*/
class ChildHelper extends ForwardingLoadBalancerHelper {
final class ChildHelper extends ForwardingLoadBalancerHelper {

private Helper delegate;

Expand Down Expand Up @@ -259,7 +259,7 @@ public void updateBalancingState(ConnectivityState newState, SubchannelPicker ne
}
}

class OutlierDetectionSubchannel extends ForwardingSubchannel {
final class OutlierDetectionSubchannel extends ForwardingSubchannel {

private final Subchannel delegate;
private EndpointTracker endpointTracker;
Expand Down Expand Up @@ -398,7 +398,7 @@ protected Subchannel delegate() {
/**
* Wraps the actual listener so that state changes from the actual one can be intercepted.
*/
class OutlierDetectionSubchannelStateListener implements SubchannelStateListener {
final class OutlierDetectionSubchannelStateListener implements SubchannelStateListener {

private final SubchannelStateListener delegate;

Expand Down Expand Up @@ -428,7 +428,7 @@ public String toString() {
* This picker delegates the actual picking logic to a wrapped delegate, but associates a {@link
* ClientStreamTracer} with each pick to track the results of each subchannel stream.
*/
class OutlierDetectionPicker extends SubchannelPicker {
final class OutlierDetectionPicker extends SubchannelPicker {

private final SubchannelPicker delegate;

Expand All @@ -454,7 +454,7 @@ public PickResult pickSubchannel(PickSubchannelArgs args) {
* Builds instances of a {@link ClientStreamTracer} that increments the call count in the
* tracker for each closed stream.
*/
class ResultCountingClientStreamTracerFactory extends ClientStreamTracer.Factory {
final class ResultCountingClientStreamTracerFactory extends ClientStreamTracer.Factory {

private final EndpointTracker tracker;

Expand Down Expand Up @@ -498,7 +498,7 @@ public void streamClosed(Status status) {
/**
* Tracks additional information about the endpoint needed for outlier detection.
*/
static class EndpointTracker {
static final class EndpointTracker {

private OutlierDetectionLoadBalancerConfig config;
// Marked as volatile to assure that when the inactive counter is swapped in as the new active
Expand Down Expand Up @@ -642,7 +642,7 @@ public boolean maxEjectionTimeElapsed(long currentTimeNanos) {
}

/** Tracks both successful and failed call counts. */
private static class CallCounter {
private static final class CallCounter {
AtomicLong successCount = new AtomicLong();
AtomicLong failureCount = new AtomicLong();

Expand All @@ -663,7 +663,7 @@ public String toString() {
/**
* Maintains a mapping from endpoint (a set of addresses) to their trackers.
*/
static class EndpointTrackerMap extends ForwardingMap<Set<SocketAddress>, EndpointTracker> {
static final class EndpointTrackerMap extends ForwardingMap<Set<SocketAddress>, EndpointTracker> {
private final Map<Set<SocketAddress>, EndpointTracker> trackerMap;

EndpointTrackerMap() {
Expand Down Expand Up @@ -784,7 +784,7 @@ static List<OutlierEjectionAlgorithm> forConfig(OutlierDetectionLoadBalancerConf
* required rate is not fixed, but is based on the mean and standard deviation of the success
* rates of all of the addresses.
*/
static class SuccessRateOutlierEjectionAlgorithm implements OutlierEjectionAlgorithm {
static final class SuccessRateOutlierEjectionAlgorithm implements OutlierEjectionAlgorithm {

private final OutlierDetectionLoadBalancerConfig config;

Expand Down Expand Up @@ -869,7 +869,7 @@ static double standardDeviation(Collection<Double> values, double mean) {
}
}

static class FailurePercentageOutlierEjectionAlgorithm implements OutlierEjectionAlgorithm {
static final class FailurePercentageOutlierEjectionAlgorithm implements OutlierEjectionAlgorithm {

private final OutlierDetectionLoadBalancerConfig config;

Expand Down Expand Up @@ -970,7 +970,7 @@ private OutlierDetectionLoadBalancerConfig(Builder builder) {
}

/** Builds a new {@link OutlierDetectionLoadBalancerConfig}. */
public static class Builder {
public static final class Builder {
long intervalNanos = 10_000_000_000L; // 10s
long baseEjectionTimeNanos = 30_000_000_000L; // 30s
long maxEjectionTimeNanos = 300_000_000_000L; // 300s
Expand Down Expand Up @@ -1035,7 +1035,7 @@ public OutlierDetectionLoadBalancerConfig build() {
}

/** The configuration for success rate ejection. */
public static class SuccessRateEjection {
public static final class SuccessRateEjection {

public final int stdevFactor;
public final int enforcementPercentage;
Expand Down Expand Up @@ -1094,7 +1094,7 @@ public SuccessRateEjection build() {
}

/** The configuration for failure percentage ejection. */
public static class FailurePercentageEjection {
public static final class FailurePercentageEjection {
public final int threshold;
public final int enforcementPercentage;
public final int minimumHosts;
Expand Down
Loading