Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b679dae

Browse filesBrowse files
committed
fix second/millis confusion
1 parent 1cdc9d3 commit b679dae
Copy full SHA for b679dae

File tree

1 file changed

+7
-10
lines changed
Filter options

1 file changed

+7
-10
lines changed

‎src/main/java/org/fluentd/logger/sender/ExponentialDelayReconnector.java

Copy file name to clipboardExpand all lines: src/main/java/org/fluentd/logger/sender/ExponentialDelayReconnector.java
+7-10
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
package org.fluentd.logger.sender;
22

3-
import org.slf4j.Logger;
4-
import org.slf4j.LoggerFactory;
5-
63
import java.util.LinkedList;
74

85
/**
96
* Calcurate exponential delay for reconnecting
107
*/
118
public class ExponentialDelayReconnector implements Reconnector {
129

13-
private double wait = 0.5;
10+
private double waitMillis = 50; // Start wait is 50ms
1411

1512
private double waitIncrRate = 1.5;
1613

17-
private double waitMax = 60;
14+
private double waitMaxMillis = 60 * 1000; // Max wait is 1 minute
1815

1916
private int waitMaxCount;
2017

@@ -26,7 +23,7 @@ public ExponentialDelayReconnector() {
2623
}
2724

2825
private int getWaitMaxCount() {
29-
double r = waitMax / wait;
26+
double r = waitMaxMillis / waitMillis;
3027
for (int j = 1; j <= 100; j++) {
3128
if (r < waitIncrRate) {
3229
return j + 1;
@@ -57,13 +54,13 @@ public boolean enableReconnection(long timestamp) {
5754
return true;
5855
}
5956

60-
double suppressSec;
57+
double suppressMillis;
6158
if (size < waitMaxCount) {
62-
suppressSec = wait * Math.pow(waitIncrRate, size - 1);
59+
suppressMillis = waitMillis * Math.pow(waitIncrRate, size - 1);
6360
} else {
64-
suppressSec = waitMax;
61+
suppressMillis = waitMaxMillis;
6562
}
6663

67-
return (!(timestamp - errorHistory.getLast() < suppressSec));
64+
return (timestamp - errorHistory.getLast()) > suppressMillis;
6865
}
6966
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.