Skip to content

Commit 4985335

Browse files
committed
Adjust exponential backoff
1 parent f2c29f8 commit 4985335

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/main/java/oracle/kubernetes/operator/helpers/CallBuilder.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,9 +1223,10 @@ public interface RetryStrategy {
12231223
}
12241224

12251225
private static final Random R = new Random();
1226-
private static final int HIGH = 1000;
1227-
private static final int LOW = 100;
1228-
private static final int MAX = 30000;
1226+
private static final int HIGH = 200;
1227+
private static final int LOW = 10;
1228+
private static final int SCALE = 100;
1229+
private static final int MAX = 10000;
12291230

12301231
private final class DefaultRetryStrategy implements RetryStrategy {
12311232
private long retryCount = 0;
@@ -1248,7 +1249,7 @@ public NextAction doPotentialRetry(Step conflictStep, Packet packet, ApiExceptio
12481249
statusCode == 504 /* StatusServerTimeout */) {
12491250

12501251
// exponential back-off
1251-
long waitTime = Math.min((2 << ++retryCount) * 1000 + (R.nextInt(HIGH - LOW) + LOW), MAX);
1252+
long waitTime = Math.min((2 << ++retryCount) * SCALE, MAX) + (R.nextInt(HIGH - LOW) + LOW);
12521253

12531254
if (statusCode == 0 || statusCode == 504 /* StatusServerTimeout */) {
12541255
// increase server timeout
@@ -1265,7 +1266,7 @@ public NextAction doPotentialRetry(Step conflictStep, Packet packet, ApiExceptio
12651266
// the request based on latest contents. If provided, a conflict step will do that.
12661267

12671268
// exponential back-off
1268-
long waitTime = Math.min((2 << ++retryCount) * 1000 + (R.nextInt(HIGH - LOW) + LOW), MAX);
1269+
long waitTime = Math.min((2 << ++retryCount) * SCALE, MAX) + (R.nextInt(HIGH - LOW) + LOW);
12691270

12701271
LOGGER.info(MessageKeys.ASYNC_RETRY, String.valueOf(waitTime));
12711272
NextAction na = new NextAction();

src/main/java/oracle/kubernetes/operator/wlsconfig/WlsConfigRetriever.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,10 @@ public static Step readConfigStep(Step next) {
9090
private static final String START_TIME = "WlsConfigRetriever-startTime";
9191
private static final String RETRY_COUNT = "WlsConfigRetriever-retryCount";
9292
private static final Random R = new Random();
93-
private static final int HIGH = 1000;
94-
private static final int LOW = 100;
95-
private static final int MAX = 30000;
93+
private static final int HIGH = 50;
94+
private static final int LOW = 10;
95+
private static final int SCALE = 100;
96+
private static final int MAX = 10000;
9697

9798
private static final class ReadConfigStep extends Step {
9899
public ReadConfigStep(Step next) {
@@ -134,7 +135,7 @@ public NextAction apply(Packet packet) {
134135
if (retryCount == null) {
135136
retryCount = 0;
136137
}
137-
long waitTime = Math.min((2 << ++retryCount) * 1000 + (R.nextInt(HIGH - LOW) + LOW), MAX);
138+
long waitTime = Math.min((2 << ++retryCount) * SCALE, MAX) + (R.nextInt(HIGH - LOW) + LOW);
138139
packet.put(RETRY_COUNT, retryCount);
139140
return doRetry(packet, waitTime, TimeUnit.MILLISECONDS);
140141
}
@@ -183,7 +184,7 @@ public NextAction apply(Packet packet) {
183184
if (retryCount == null) {
184185
retryCount = 0;
185186
}
186-
long waitTime = Math.min((2 << ++retryCount) * 1000 + (R.nextInt(HIGH - LOW) + LOW), MAX);
187+
long waitTime = Math.min((2 << ++retryCount) * SCALE, MAX) + (R.nextInt(HIGH - LOW) + LOW);
187188
packet.put(RETRY_COUNT, retryCount);
188189
return doRetry(packet, waitTime, TimeUnit.MILLISECONDS);
189190
}

0 commit comments

Comments
 (0)