This is an automated email from the ASF dual-hosted git repository.
jackie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 547c1f370c use ThreadLocalRandom in DynamicBrokerSelector (#13860)
547c1f370c is described below
commit 547c1f370c71e8e445d4feda6ae3ecbc424d7147
Author: sullis <[email protected]>
AuthorDate: Wed Aug 21 12:19:19 2024 -0700
use ThreadLocalRandom in DynamicBrokerSelector (#13860)
---
.../main/java/org/apache/pinot/client/DynamicBrokerSelector.java | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git
a/pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/DynamicBrokerSelector.java
b/pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/DynamicBrokerSelector.java
index 346e3867c3..6683b6a5fc 100644
---
a/pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/DynamicBrokerSelector.java
+++
b/pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/DynamicBrokerSelector.java
@@ -24,8 +24,8 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Random;
import java.util.Set;
+import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import javax.annotation.Nullable;
@@ -42,7 +42,6 @@ import org.slf4j.LoggerFactory;
*/
public class DynamicBrokerSelector implements BrokerSelector, IZkDataListener {
private static final Logger LOGGER =
LoggerFactory.getLogger(DynamicBrokerSelector.class);
- private static final Random RANDOM = new Random();
protected final AtomicReference<Map<String, List<String>>>
_tableToBrokerListMapRef = new AtomicReference<>();
protected final AtomicReference<List<String>> _allBrokerListRef = new
AtomicReference<>();
@@ -95,14 +94,14 @@ public class DynamicBrokerSelector implements
BrokerSelector, IZkDataListener {
List<String> list =
BrokerSelectorUtils.getTablesCommonBrokers(Arrays.asList(tableNames),
_tableToBrokerListMapRef.get());
if (list != null && !list.isEmpty()) {
- return list.get(RANDOM.nextInt(list.size()));
+ return list.get(ThreadLocalRandom.current().nextInt(list.size()));
}
}
// Return a broker randomly if table is null or no broker is found for the
specified table.
List<String> list = _allBrokerListRef.get();
if (list != null && !list.isEmpty()) {
- return list.get(RANDOM.nextInt(list.size()));
+ return list.get(ThreadLocalRandom.current().nextInt(list.size()));
}
return null;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]