Skip to content

Commit e477836

Browse files
author
Rishabh Kumar
committed
OAK-11769 : replaced Doubles.fuzzyCompare with commons-math3 Precision
1 parent aec6d3e commit e477836

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

oak-run-elastic/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
105 MB: Azure updates
4343
107 MB: RDB/Tomcat (OAK-10752)
4444
-->
45-
<max.jar.size>117000000</max.jar.size>
45+
<max.jar.size>119000000</max.jar.size>
4646

4747
</properties>
4848

oak-store-document/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@
152152
<groupId>commons-io</groupId>
153153
<artifactId>commons-io</artifactId>
154154
</dependency>
155+
<dependency>
156+
<groupId>org.apache.commons</groupId>
157+
<artifactId>commons-math3</artifactId>
158+
</dependency>
155159
<dependency>
156160
<groupId>org.quartz-scheduler</groupId>
157161
<artifactId>quartz</artifactId>

oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoThrottlerFactory.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
*/
1919
package org.apache.jackrabbit.oak.plugins.document.mongo;
2020

21+
import org.apache.commons.math3.util.Precision;
2122
import org.apache.jackrabbit.guava.common.util.concurrent.AtomicDouble;
2223
import org.apache.jackrabbit.oak.plugins.document.Throttler;
2324
import org.jetbrains.annotations.NotNull;
2425

25-
import static org.apache.jackrabbit.guava.common.math.DoubleMath.fuzzyCompare;
2626
import static java.util.Objects.requireNonNull;
2727
import static org.apache.jackrabbit.oak.plugins.document.Throttler.NO_THROTTLING;
2828

@@ -75,16 +75,16 @@ public ExponentialThrottler(final int threshold, final @NotNull AtomicDouble opl
7575
@Override
7676
public long throttlingTime() {
7777
final double threshold = this.threshold;
78-
final double oplogWindow = this.oplogWindow.doubleValue();
78+
final double oplogWindow = this.oplogWindow.get();
7979
long throttleTime = throttlingTime;
8080

81-
if (fuzzyCompare(oplogWindow,threshold/8, 0.001) <= 0) {
81+
if (Precision.compareTo(oplogWindow,threshold/8, 0.001) <= 0) {
8282
throttleTime = throttleTime * 8;
83-
} else if (fuzzyCompare(oplogWindow,threshold/4, 0.001) <= 0) {
83+
} else if (Precision.compareTo(oplogWindow,threshold/4, 0.001) <= 0) {
8484
throttleTime = throttleTime * 4;
85-
} else if (fuzzyCompare(oplogWindow, threshold/2, 0.001) <= 0) {
85+
} else if (Precision.compareTo(oplogWindow, threshold/2, 0.001) <= 0) {
8686
throttleTime = throttleTime * 2;
87-
} else if (fuzzyCompare(oplogWindow, threshold,0.001) <= 0) {
87+
} else if (Precision.compareTo(oplogWindow, threshold,0.001) <= 0) {
8888
throttleTime = throttlingTime;
8989
} else {
9090
throttleTime = 0;

0 commit comments

Comments
 (0)