@@ -142,7 +142,7 @@ public Status acceptResolvedAddresses(ResolvedAddresses resolvedAddresses) {
142
142
// If outlier detection is actually configured, start a timer that will periodically try to
143
143
// detect outliers.
144
144
if (config .outlierDetectionEnabled ()) {
145
- Long initialDelayNanos ;
145
+ long initialDelayNanos ;
146
146
147
147
if (detectionTimerStartNanos == null ) {
148
148
// On the first go we use the configured interval.
@@ -723,7 +723,7 @@ void swapCounters() {
723
723
* that don't have ejected subchannels and uneject ones that have spent the maximum ejection
724
724
* time allowed.
725
725
*/
726
- void maybeUnejectOutliers (Long detectionTimerStartNanos ) {
726
+ void maybeUnejectOutliers (long detectionTimerStartNanos ) {
727
727
for (EndpointTracker tracker : trackerMap .values ()) {
728
728
if (!tracker .subchannelsEjected ()) {
729
729
tracker .decrementEjectionTimeMultiplier ();
@@ -951,64 +951,54 @@ private static boolean hasSingleAddress(List<EquivalentAddressGroup> addressGrou
951
951
*/
952
952
public static final class OutlierDetectionLoadBalancerConfig {
953
953
954
- public final Long intervalNanos ;
955
- public final Long baseEjectionTimeNanos ;
956
- public final Long maxEjectionTimeNanos ;
957
- public final Integer maxEjectionPercent ;
954
+ public final long intervalNanos ;
955
+ public final long baseEjectionTimeNanos ;
956
+ public final long maxEjectionTimeNanos ;
957
+ public final int maxEjectionPercent ;
958
958
public final SuccessRateEjection successRateEjection ;
959
959
public final FailurePercentageEjection failurePercentageEjection ;
960
960
public final Object childConfig ;
961
961
962
- private OutlierDetectionLoadBalancerConfig (Long intervalNanos ,
963
- Long baseEjectionTimeNanos ,
964
- Long maxEjectionTimeNanos ,
965
- Integer maxEjectionPercent ,
966
- SuccessRateEjection successRateEjection ,
967
- FailurePercentageEjection failurePercentageEjection ,
968
- Object childConfig ) {
969
- this .intervalNanos = intervalNanos ;
970
- this .baseEjectionTimeNanos = baseEjectionTimeNanos ;
971
- this .maxEjectionTimeNanos = maxEjectionTimeNanos ;
972
- this .maxEjectionPercent = maxEjectionPercent ;
973
- this .successRateEjection = successRateEjection ;
974
- this .failurePercentageEjection = failurePercentageEjection ;
975
- this .childConfig = childConfig ;
962
+ private OutlierDetectionLoadBalancerConfig (Builder builder ) {
963
+ this .intervalNanos = builder .intervalNanos ;
964
+ this .baseEjectionTimeNanos = builder .baseEjectionTimeNanos ;
965
+ this .maxEjectionTimeNanos = builder .maxEjectionTimeNanos ;
966
+ this .maxEjectionPercent = builder .maxEjectionPercent ;
967
+ this .successRateEjection = builder .successRateEjection ;
968
+ this .failurePercentageEjection = builder .failurePercentageEjection ;
969
+ this .childConfig = builder .childConfig ;
976
970
}
977
971
978
972
/** Builds a new {@link OutlierDetectionLoadBalancerConfig}. */
979
973
public static class Builder {
980
- Long intervalNanos = 10_000_000_000L ; // 10s
981
- Long baseEjectionTimeNanos = 30_000_000_000L ; // 30s
982
- Long maxEjectionTimeNanos = 300_000_000_000L ; // 300s
983
- Integer maxEjectionPercent = 10 ;
974
+ long intervalNanos = 10_000_000_000L ; // 10s
975
+ long baseEjectionTimeNanos = 30_000_000_000L ; // 30s
976
+ long maxEjectionTimeNanos = 300_000_000_000L ; // 300s
977
+ int maxEjectionPercent = 10 ;
984
978
SuccessRateEjection successRateEjection ;
985
979
FailurePercentageEjection failurePercentageEjection ;
986
980
Object childConfig ;
987
981
988
982
/** The interval between outlier detection sweeps. */
989
- public Builder setIntervalNanos (Long intervalNanos ) {
990
- checkArgument (intervalNanos != null );
983
+ public Builder setIntervalNanos (long intervalNanos ) {
991
984
this .intervalNanos = intervalNanos ;
992
985
return this ;
993
986
}
994
987
995
988
/** The base time an address is ejected for. */
996
- public Builder setBaseEjectionTimeNanos (Long baseEjectionTimeNanos ) {
997
- checkArgument (baseEjectionTimeNanos != null );
989
+ public Builder setBaseEjectionTimeNanos (long baseEjectionTimeNanos ) {
998
990
this .baseEjectionTimeNanos = baseEjectionTimeNanos ;
999
991
return this ;
1000
992
}
1001
993
1002
994
/** The longest time an address can be ejected. */
1003
- public Builder setMaxEjectionTimeNanos (Long maxEjectionTimeNanos ) {
1004
- checkArgument (maxEjectionTimeNanos != null );
995
+ public Builder setMaxEjectionTimeNanos (long maxEjectionTimeNanos ) {
1005
996
this .maxEjectionTimeNanos = maxEjectionTimeNanos ;
1006
997
return this ;
1007
998
}
1008
999
1009
1000
/** The algorithm agnostic maximum percentage of addresses that can be ejected. */
1010
- public Builder setMaxEjectionPercent (Integer maxEjectionPercent ) {
1011
- checkArgument (maxEjectionPercent != null );
1001
+ public Builder setMaxEjectionPercent (int maxEjectionPercent ) {
1012
1002
this .maxEjectionPercent = maxEjectionPercent ;
1013
1003
return this ;
1014
1004
}
@@ -1040,118 +1030,106 @@ public Builder setChildConfig(Object childConfig) {
1040
1030
/** Builds a new instance of {@link OutlierDetectionLoadBalancerConfig}. */
1041
1031
public OutlierDetectionLoadBalancerConfig build () {
1042
1032
checkState (childConfig != null );
1043
- return new OutlierDetectionLoadBalancerConfig (intervalNanos , baseEjectionTimeNanos ,
1044
- maxEjectionTimeNanos , maxEjectionPercent , successRateEjection ,
1045
- failurePercentageEjection , childConfig );
1033
+ return new OutlierDetectionLoadBalancerConfig (this );
1046
1034
}
1047
1035
}
1048
1036
1049
1037
/** The configuration for success rate ejection. */
1050
1038
public static class SuccessRateEjection {
1051
1039
1052
- public final Integer stdevFactor ;
1053
- public final Integer enforcementPercentage ;
1054
- public final Integer minimumHosts ;
1055
- public final Integer requestVolume ;
1056
-
1057
- SuccessRateEjection (Integer stdevFactor , Integer enforcementPercentage , Integer minimumHosts ,
1058
- Integer requestVolume ) {
1059
- this .stdevFactor = stdevFactor ;
1060
- this .enforcementPercentage = enforcementPercentage ;
1061
- this .minimumHosts = minimumHosts ;
1062
- this .requestVolume = requestVolume ;
1040
+ public final int stdevFactor ;
1041
+ public final int enforcementPercentage ;
1042
+ public final int minimumHosts ;
1043
+ public final int requestVolume ;
1044
+
1045
+ SuccessRateEjection (Builder builder ) {
1046
+ this .stdevFactor = builder .stdevFactor ;
1047
+ this .enforcementPercentage = builder .enforcementPercentage ;
1048
+ this .minimumHosts = builder .minimumHosts ;
1049
+ this .requestVolume = builder .requestVolume ;
1063
1050
}
1064
1051
1065
1052
/** Builds new instances of {@link SuccessRateEjection}. */
1066
1053
public static final class Builder {
1067
1054
1068
- Integer stdevFactor = 1900 ;
1069
- Integer enforcementPercentage = 100 ;
1070
- Integer minimumHosts = 5 ;
1071
- Integer requestVolume = 100 ;
1055
+ int stdevFactor = 1900 ;
1056
+ int enforcementPercentage = 100 ;
1057
+ int minimumHosts = 5 ;
1058
+ int requestVolume = 100 ;
1072
1059
1073
1060
/** The product of this and the standard deviation of success rates determine the ejection
1074
1061
* threshold.
1075
1062
*/
1076
- public Builder setStdevFactor (Integer stdevFactor ) {
1077
- checkArgument (stdevFactor != null );
1063
+ public Builder setStdevFactor (int stdevFactor ) {
1078
1064
this .stdevFactor = stdevFactor ;
1079
1065
return this ;
1080
1066
}
1081
1067
1082
1068
/** Only eject this percentage of outliers. */
1083
- public Builder setEnforcementPercentage (Integer enforcementPercentage ) {
1084
- checkArgument (enforcementPercentage != null );
1069
+ public Builder setEnforcementPercentage (int enforcementPercentage ) {
1085
1070
checkArgument (enforcementPercentage >= 0 && enforcementPercentage <= 100 );
1086
1071
this .enforcementPercentage = enforcementPercentage ;
1087
1072
return this ;
1088
1073
}
1089
1074
1090
1075
/** The minimum amount of hosts needed for success rate ejection. */
1091
- public Builder setMinimumHosts (Integer minimumHosts ) {
1092
- checkArgument (minimumHosts != null );
1076
+ public Builder setMinimumHosts (int minimumHosts ) {
1093
1077
checkArgument (minimumHosts >= 0 );
1094
1078
this .minimumHosts = minimumHosts ;
1095
1079
return this ;
1096
1080
}
1097
1081
1098
1082
/** The minimum address request volume to be considered for success rate ejection. */
1099
- public Builder setRequestVolume (Integer requestVolume ) {
1100
- checkArgument (requestVolume != null );
1083
+ public Builder setRequestVolume (int requestVolume ) {
1101
1084
checkArgument (requestVolume >= 0 );
1102
1085
this .requestVolume = requestVolume ;
1103
1086
return this ;
1104
1087
}
1105
1088
1106
1089
/** Builds a new instance of {@link SuccessRateEjection}. */
1107
1090
public SuccessRateEjection build () {
1108
- return new SuccessRateEjection (stdevFactor , enforcementPercentage , minimumHosts ,
1109
- requestVolume );
1091
+ return new SuccessRateEjection (this );
1110
1092
}
1111
1093
}
1112
1094
}
1113
1095
1114
1096
/** The configuration for failure percentage ejection. */
1115
1097
public static class FailurePercentageEjection {
1116
- public final Integer threshold ;
1117
- public final Integer enforcementPercentage ;
1118
- public final Integer minimumHosts ;
1119
- public final Integer requestVolume ;
1120
-
1121
- FailurePercentageEjection (Integer threshold , Integer enforcementPercentage ,
1122
- Integer minimumHosts , Integer requestVolume ) {
1123
- this .threshold = threshold ;
1124
- this .enforcementPercentage = enforcementPercentage ;
1125
- this .minimumHosts = minimumHosts ;
1126
- this .requestVolume = requestVolume ;
1098
+ public final int threshold ;
1099
+ public final int enforcementPercentage ;
1100
+ public final int minimumHosts ;
1101
+ public final int requestVolume ;
1102
+
1103
+ FailurePercentageEjection (Builder builder ) {
1104
+ this .threshold = builder .threshold ;
1105
+ this .enforcementPercentage = builder .enforcementPercentage ;
1106
+ this .minimumHosts = builder .minimumHosts ;
1107
+ this .requestVolume = builder .requestVolume ;
1127
1108
}
1128
1109
1129
1110
/** For building new {@link FailurePercentageEjection} instances. */
1130
1111
public static class Builder {
1131
- Integer threshold = 85 ;
1132
- Integer enforcementPercentage = 100 ;
1133
- Integer minimumHosts = 5 ;
1134
- Integer requestVolume = 50 ;
1112
+ int threshold = 85 ;
1113
+ int enforcementPercentage = 100 ;
1114
+ int minimumHosts = 5 ;
1115
+ int requestVolume = 50 ;
1135
1116
1136
1117
/** The failure percentage that will result in an address being considered an outlier. */
1137
- public Builder setThreshold (Integer threshold ) {
1138
- checkArgument (threshold != null );
1118
+ public Builder setThreshold (int threshold ) {
1139
1119
checkArgument (threshold >= 0 && threshold <= 100 );
1140
1120
this .threshold = threshold ;
1141
1121
return this ;
1142
1122
}
1143
1123
1144
1124
/** Only eject this percentage of outliers. */
1145
- public Builder setEnforcementPercentage (Integer enforcementPercentage ) {
1146
- checkArgument (enforcementPercentage != null );
1125
+ public Builder setEnforcementPercentage (int enforcementPercentage ) {
1147
1126
checkArgument (enforcementPercentage >= 0 && enforcementPercentage <= 100 );
1148
1127
this .enforcementPercentage = enforcementPercentage ;
1149
1128
return this ;
1150
1129
}
1151
1130
1152
1131
/** The minimum amount of host for failure percentage ejection to be enabled. */
1153
- public Builder setMinimumHosts (Integer minimumHosts ) {
1154
- checkArgument (minimumHosts != null );
1132
+ public Builder setMinimumHosts (int minimumHosts ) {
1155
1133
checkArgument (minimumHosts >= 0 );
1156
1134
this .minimumHosts = minimumHosts ;
1157
1135
return this ;
@@ -1161,17 +1139,15 @@ public Builder setMinimumHosts(Integer minimumHosts) {
1161
1139
* The request volume required for an address to be considered for failure percentage
1162
1140
* ejection.
1163
1141
*/
1164
- public Builder setRequestVolume (Integer requestVolume ) {
1165
- checkArgument (requestVolume != null );
1142
+ public Builder setRequestVolume (int requestVolume ) {
1166
1143
checkArgument (requestVolume >= 0 );
1167
1144
this .requestVolume = requestVolume ;
1168
1145
return this ;
1169
1146
}
1170
1147
1171
1148
/** Builds a new instance of {@link FailurePercentageEjection}. */
1172
1149
public FailurePercentageEjection build () {
1173
- return new FailurePercentageEjection (threshold , enforcementPercentage , minimumHosts ,
1174
- requestVolume );
1150
+ return new FailurePercentageEjection (this );
1175
1151
}
1176
1152
}
1177
1153
}
0 commit comments