From fffa7f5804944e1cea4965c502ecf8afeafef504 Mon Sep 17 00:00:00 2001
From: Zhifeng Chen
Date: Sat, 2 Mar 2024 18:00:05 -0800
Subject: [PATCH] upgrade to java 11
---
concurrency-loadbalancer-core/pom.xml | 4 +-
.../ArrayConcurrencyLoadBalancer.java | 4 +-
.../HeapConcurrencyLoadBalancer.java | 6 ++-
.../loadbalancer/RoundRobinLoadBalancer.java | 7 +--
.../internal/TaskConcurrency.java | 5 --
.../timedcounter/WindowScheduledCounter.java | 6 ++-
.../utils/HashIndexedPriorityQueue.java | 8 +--
.../loadbalancer/utils/ReservoirSampler.java | 2 +
concurrency-loadbalancer-m3/pom.xml | 4 +-
.../TallyMetricsTaskListener.java | 2 +
concurrency-loadbalancer-tracing/pom.xml | 4 +-
.../loadbalancer/TracingTaskListener.java | 3 +-
pom.xml | 54 ++++++++++++++++---
13 files changed, 78 insertions(+), 31 deletions(-)
diff --git a/concurrency-loadbalancer-core/pom.xml b/concurrency-loadbalancer-core/pom.xml
index 581d85b..7fc56e8 100644
--- a/concurrency-loadbalancer-core/pom.xml
+++ b/concurrency-loadbalancer-core/pom.xml
@@ -38,7 +38,7 @@
org.mockito
- mockito-all
+ mockito-core
test
@@ -48,7 +48,7 @@
org.powermock
- powermock-api-mockito
+ powermock-api-mockito2
test
diff --git a/concurrency-loadbalancer-core/src/main/java/com/uber/concurrency/loadbalancer/ArrayConcurrencyLoadBalancer.java b/concurrency-loadbalancer-core/src/main/java/com/uber/concurrency/loadbalancer/ArrayConcurrencyLoadBalancer.java
index 705600c..3b8d7ab 100644
--- a/concurrency-loadbalancer-core/src/main/java/com/uber/concurrency/loadbalancer/ArrayConcurrencyLoadBalancer.java
+++ b/concurrency-loadbalancer-core/src/main/java/com/uber/concurrency/loadbalancer/ArrayConcurrencyLoadBalancer.java
@@ -34,15 +34,15 @@
*
* Example:
*
+ * {@code
* ArrayList entries = new ArrayList() {{add("a"); add("b");}};
*
* ArrayConcurrencyLoadBalancer loadBalancer = ArrayConcurrencyLoadBalancer.newBuilder()
* .withTasks(entries)
* .build();
* loadBalancer.next();
+ * }
*
- *
- * @param the type parameter
*/
public final class ArrayConcurrencyLoadBalancer extends AbstractConcurrencyLoadBalancer {
private static final TaskConcurrency LEAST_TASK_CONCURRENCY = new TaskConcurrency.Noop(Integer.MAX_VALUE);
diff --git a/concurrency-loadbalancer-core/src/main/java/com/uber/concurrency/loadbalancer/HeapConcurrencyLoadBalancer.java b/concurrency-loadbalancer-core/src/main/java/com/uber/concurrency/loadbalancer/HeapConcurrencyLoadBalancer.java
index b4bd0f2..c01c6f5 100644
--- a/concurrency-loadbalancer-core/src/main/java/com/uber/concurrency/loadbalancer/HeapConcurrencyLoadBalancer.java
+++ b/concurrency-loadbalancer-core/src/main/java/com/uber/concurrency/loadbalancer/HeapConcurrencyLoadBalancer.java
@@ -29,6 +29,7 @@
*
* Example:
*
+ * {@code
* ArrayList urls = new ArrayList() {{add("http://192.168.0.1:80"); add("http://192.168.0.2:80");}};
*
* HeapConcurrencyLoadBalancer loadBalancer = HeapConcurrencyLoadBalancer.newBuilder()
@@ -37,9 +38,8 @@
* CompletableTask url = loadBalancer.next();
* boolean succeed = doPost(url.getTask()); //make rest call with url.getTask()
* url.complete(succeed); //finish the task
- *
+ * }
*
- * @param the type parameter
*/
public final class HeapConcurrencyLoadBalancer extends AbstractConcurrencyLoadBalancer {
private final TaskConcurrencyQueue taskConcurrencyQueue;
@@ -75,10 +75,12 @@ TaskConcurrencyQueue getTaskConcurrencyQueue() {
*
* To prevent surge of failure, specify timeout to treat failure as timeout
*
+ * {@code
* HeapConcurrencyLoadBalancer loadBalancer = HeapConcurrencyLoadBalancer.newBuilder(String.class)
* .withTasks(entries)
* .withTimeout(Duration.ofSeconds(10))
* .build();
+ * }
*
* @param the type parameter
*/
diff --git a/concurrency-loadbalancer-core/src/main/java/com/uber/concurrency/loadbalancer/RoundRobinLoadBalancer.java b/concurrency-loadbalancer-core/src/main/java/com/uber/concurrency/loadbalancer/RoundRobinLoadBalancer.java
index 69055d4..f6e021c 100644
--- a/concurrency-loadbalancer-core/src/main/java/com/uber/concurrency/loadbalancer/RoundRobinLoadBalancer.java
+++ b/concurrency-loadbalancer-core/src/main/java/com/uber/concurrency/loadbalancer/RoundRobinLoadBalancer.java
@@ -2,6 +2,7 @@
import com.google.common.collect.ImmutableList;
+import javax.annotation.concurrent.ThreadSafe;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
@@ -12,6 +13,7 @@
* interaction evenly across all entities with index
*
* Example:
+ * {@code
* String[] tasks = new String[]{"a", "b", "c", "d", "e"};
*
* RoundRobinLoadBalancer lb = RoundRobinLoadBalancer
@@ -19,11 +21,10 @@
* .withTasks(Arrays.asList(tasks))
* .build();
* return lb.next();
- *
- * @ThreadSafe
- *
+ * }
* @param the type parameter
*/
+@ThreadSafe
public final class RoundRobinLoadBalancer implements LoadBalancer {
private final ImmutableList tasks;
private final AtomicInteger index;
diff --git a/concurrency-loadbalancer-core/src/main/java/com/uber/concurrency/loadbalancer/internal/TaskConcurrency.java b/concurrency-loadbalancer-core/src/main/java/com/uber/concurrency/loadbalancer/internal/TaskConcurrency.java
index abddb3f..83c48f4 100644
--- a/concurrency-loadbalancer-core/src/main/java/com/uber/concurrency/loadbalancer/internal/TaskConcurrency.java
+++ b/concurrency-loadbalancer-core/src/main/java/com/uber/concurrency/loadbalancer/internal/TaskConcurrency.java
@@ -17,8 +17,6 @@ public interface TaskConcurrency extends Comparable {
/**
* Acquire task
- *
- * @return concurrency
*/
default void acquire() {
acquire(1);
@@ -29,7 +27,6 @@ default void acquire() {
*
* @param succeed the result
* @param latency the latency
- * @return concurrency
*/
default void complete(boolean succeed, Duration latency) {
complete(1, latency);
@@ -39,7 +36,6 @@ default void complete(boolean succeed, Duration latency) {
* Acquire tasks in batch
*
* @param n number of requests processed
- * @return the int
*/
void acquire(int n);
@@ -48,7 +44,6 @@ default void complete(boolean succeed, Duration latency) {
*
* @param n number of requests
* @param latency total duration
- * @return concurrency
*/
void complete(int n, Duration latency);
diff --git a/concurrency-loadbalancer-core/src/main/java/com/uber/concurrency/loadbalancer/timedcounter/WindowScheduledCounter.java b/concurrency-loadbalancer-core/src/main/java/com/uber/concurrency/loadbalancer/timedcounter/WindowScheduledCounter.java
index 1e74d0b..c1ad190 100644
--- a/concurrency-loadbalancer-core/src/main/java/com/uber/concurrency/loadbalancer/timedcounter/WindowScheduledCounter.java
+++ b/concurrency-loadbalancer-core/src/main/java/com/uber/concurrency/loadbalancer/timedcounter/WindowScheduledCounter.java
@@ -3,6 +3,7 @@
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Ticker;
+import javax.annotation.concurrent.ThreadSafe;
import java.time.Duration;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Consumer;
@@ -21,22 +22,23 @@
* for this case .check() @12s will call consumer.accept(2)
* Example:
*
+ * {@code
* WindowScheduledCounter scheduledCounter = WindowScheduledCounter.newBuilder()
* .withMaxDelay(Duration.ofSeconds(30))
* .withNumWindow(100)
* .of(consumer);
* scheduledCounter.schedule(1, Duration.ofMillis(delayMs));
* scheduledCounter.check() //check and push count to consumer
+ * }
*
- *
*
* Performance related
* more windows indicates higher precision but also more CPU cost
* ScheduledCounter use the number of window as its concurrency limit, when the limit reached
*
*
- * @TheadSafe
*/
+@ThreadSafe
public class WindowScheduledCounter implements ScheduledCounter {
final LifespanTracker lifespanTracker;
private final Consumer consumer;
diff --git a/concurrency-loadbalancer-core/src/main/java/com/uber/concurrency/loadbalancer/utils/HashIndexedPriorityQueue.java b/concurrency-loadbalancer-core/src/main/java/com/uber/concurrency/loadbalancer/utils/HashIndexedPriorityQueue.java
index e35d24c..164b119 100644
--- a/concurrency-loadbalancer-core/src/main/java/com/uber/concurrency/loadbalancer/utils/HashIndexedPriorityQueue.java
+++ b/concurrency-loadbalancer-core/src/main/java/com/uber/concurrency/loadbalancer/utils/HashIndexedPriorityQueue.java
@@ -13,7 +13,7 @@
import java.util.Set;
/**
- * HashIndexedPriorityQueue implemented both interfaces of Queue<> and Set<>
+ * HashIndexedPriorityQueue implemented both interfaces of Queue and Set
* Comparing with {@link java.util.PriorityQueue}, HashIndexedPriorityQueue
* - reduced contains(obj)/remove(obj) complexity from O(n) to O(logN)
* - offer(obj)/add(obj) ensures uniqueness
@@ -31,6 +31,7 @@
*
* Example: Suppose class Entity.value is Integer
*
+ * {@code
* class Entity {
* int value;
* Entity(int v) {
@@ -42,6 +43,7 @@
* //add entities into queue
* entity1.value+=1; //change order of entity
* queue.offer(entity1) //if entity1 is not in the queue, it will be added. otherwise order of entity1 will be in-place adjusted
+ * }
*
*
* @param the type parameter
@@ -73,7 +75,7 @@ public HashIndexedPriorityQueue(Comparator comparator) {
/**
* Instantiates a new Hash indexed priority queue.
- * use (e1, e2) -> e1.compareTo(e2) as default comparator
+ * use {@code(e1, e2) -> e1.compareTo(e2)} as default comparator
*/
public HashIndexedPriorityQueue() {
this(null);
@@ -94,7 +96,7 @@ public int size() {
* 2. adjust order in-place with O(logn) complexity, if obj exist.
*
* @param e entity to add or update order
- * @return
+ * @return true indicates element added successfully
*/
@Override
public boolean offer(E e) {
diff --git a/concurrency-loadbalancer-core/src/main/java/com/uber/concurrency/loadbalancer/utils/ReservoirSampler.java b/concurrency-loadbalancer-core/src/main/java/com/uber/concurrency/loadbalancer/utils/ReservoirSampler.java
index 8352bc4..9549ed3 100644
--- a/concurrency-loadbalancer-core/src/main/java/com/uber/concurrency/loadbalancer/utils/ReservoirSampler.java
+++ b/concurrency-loadbalancer-core/src/main/java/com/uber/concurrency/loadbalancer/utils/ReservoirSampler.java
@@ -12,11 +12,13 @@
*
* Example:
*
+ * {@code
* ReservoirSampler sampler = new ReservoirSampler();
* for(Entity e : entities) {
* sampler.sample(e);
* }
* Entity selected = sampler.get();
+ * }
*
* @param the entity type
*/
diff --git a/concurrency-loadbalancer-m3/pom.xml b/concurrency-loadbalancer-m3/pom.xml
index 6510f2e..0cef1c5 100644
--- a/concurrency-loadbalancer-m3/pom.xml
+++ b/concurrency-loadbalancer-m3/pom.xml
@@ -47,7 +47,7 @@
org.mockito
- mockito-all
+ mockito-core
test
@@ -57,7 +57,7 @@
org.powermock
- powermock-api-mockito
+ powermock-api-mockito2
test
diff --git a/concurrency-loadbalancer-m3/src/main/java/com/uber/concurrency/loadbalancer/TallyMetricsTaskListener.java b/concurrency-loadbalancer-m3/src/main/java/com/uber/concurrency/loadbalancer/TallyMetricsTaskListener.java
index e01d521..2f977f1 100644
--- a/concurrency-loadbalancer-m3/src/main/java/com/uber/concurrency/loadbalancer/TallyMetricsTaskListener.java
+++ b/concurrency-loadbalancer-m3/src/main/java/com/uber/concurrency/loadbalancer/TallyMetricsTaskListener.java
@@ -17,6 +17,7 @@
*
* usage:
*
+ * {@code
* TallyMetricsTaskListener listener = TallyMetricsTaskListener.newBuilder(String.class)
* .withName("my-loadBalancer")
* .build(mockScope);
@@ -25,6 +26,7 @@
* .withTasks(entries)
* .withTaskListener(listener)
* .build();
+ * }
*
* @param the type parameter
*/
diff --git a/concurrency-loadbalancer-tracing/pom.xml b/concurrency-loadbalancer-tracing/pom.xml
index fa8ad41..5f872db 100644
--- a/concurrency-loadbalancer-tracing/pom.xml
+++ b/concurrency-loadbalancer-tracing/pom.xml
@@ -39,7 +39,7 @@
org.mockito
- mockito-all
+ mockito-core
test
@@ -49,7 +49,7 @@
org.powermock
- powermock-api-mockito
+ powermock-api-mockito2
test
diff --git a/concurrency-loadbalancer-tracing/src/main/java/com/uber/concurrency/loadbalancer/TracingTaskListener.java b/concurrency-loadbalancer-tracing/src/main/java/com/uber/concurrency/loadbalancer/TracingTaskListener.java
index 62cb3e2..fb69aa6 100644
--- a/concurrency-loadbalancer-tracing/src/main/java/com/uber/concurrency/loadbalancer/TracingTaskListener.java
+++ b/concurrency-loadbalancer-tracing/src/main/java/com/uber/concurrency/loadbalancer/TracingTaskListener.java
@@ -10,6 +10,7 @@
*
* Usage:
*
+ * {@code
* TracingTaskListener listener = TracingTaskListener.newBuilder(String.class)
* .withName("a-loadBalancer")
* .withTaskNameMapper(o->o+"Name")
@@ -19,8 +20,8 @@
* .withTasks(entries)
* .withTaskListener(listener)
* .build();
+ * }
*
- * @param the type parameter
*/
public class TracingTaskListener implements CompletableTask.Listener {
private static final Function DEFAULT_TASK_NAME_MAPPER = o->o.toString();
diff --git a/pom.xml b/pom.xml
index a2803fa..e385e0b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,24 +29,25 @@
0.1-SNAPSHOT
- 1.8
+ 11
30.1-jre
3.1.1
3.4.1
3.5
4.13.1
- 1.10.19
- 1.6.4
+ 2.23.4
+ 2.0.2
0.32.0
0.3.1
2.17
checkstyles/uber_checks.xml
3.14.0
- 3.1.0-RC6
+ 3.1.10
3.0.0
0.8.6
- 2.10.4
+ 3.2.0
2.18.1
+ 2.1.2
@@ -87,7 +88,7 @@
org.mockito
- mockito-all
+ mockito-core
${mockito.version}
@@ -103,7 +104,7 @@
org.powermock
- powermock-api-mockito
+ powermock-api-mockito2
${powermock.version}
test
@@ -142,6 +143,11 @@
maven-javadoc-plugin
${javadoc.version}
+
+ org.apache.maven.plugins
+ maven-source-plugin
+ ${source.plugin.version}
+
@@ -155,6 +161,40 @@
+
+ maven-source-plugin
+
+
+ attach-sources
+ deploy
+ jar-no-fork
+
+
+
+
+ maven-javadoc-plugin
+
+ 1.8
+
+
+
+ attach-javadocs
+ deploy
+ jar
+
+
+
+
+
+ maven-deploy-plugin
+
+
+ deploy
+ deploy
+ deploy
+
+
+