Apache9 commented on a change in pull request #4118:
URL: https://github.com/apache/hbase/pull/4118#discussion_r810471219
##########
File path:
hbase-asyncfs/src/test/java/org/apache/hadoop/hbase/io/asyncfs/TestFanOutOneBlockAsyncDFSOutput.java
##########
@@ -72,14 +72,11 @@
HBaseClassTestRule.forClass(TestFanOutOneBlockAsyncDFSOutput.class);
private static final Logger LOG =
LoggerFactory.getLogger(TestFanOutOneBlockAsyncDFSOutput.class);
-
private static DistributedFileSystem FS;
-
private static EventLoopGroup EVENT_LOOP_GROUP;
-
private static Class<? extends Channel> CHANNEL_CLASS;
-
private static int READ_TIMEOUT_MS = 2000;
+ private static final Random RNG = new Random();
Review comment:
As said in the previous PR, let's just use ThreadLocalRandom.current()
##########
File path:
hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestBytes.java
##########
@@ -386,14 +388,11 @@ public void testBinarySearch() {
@Test
public void testToStringBytesBinaryReversible() {
- // let's run test with 1000 randomly generated byte arrays
- Random rand = new Random(EnvironmentEdgeManager.currentTime());
byte[] randomBytes = new byte[1000];
for (int i = 0; i < 1000; i++) {
- rand.nextBytes(randomBytes);
+ Bytes.random(randomBytes);
Review comment:
We do not need to use SecureRandom here? Anyway, not a big deal, can
have another follow on issue to clean up the usage of Bytes.random. Maybe we
could introduce a insecureRandom(byte[]) where we just use ThreadLocalRandom.
##########
File path:
hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/actions/ChangeBloomFilterAction.java
##########
@@ -49,14 +49,13 @@ public ChangeBloomFilterAction(int sleepTime, TableName
tableName) {
@Override
public void perform() throws Exception {
- final Random random = new Random();
final BloomType[] bloomArray = BloomType.values();
final int bloomArraySize = bloomArray.length;
getLogger().info("Performing action: Change bloom filter on all columns of
table " + tableName);
modifyAllTableColumns(tableName, (columnName, columnBuilder) -> {
- BloomType bloomType = bloomArray[random.nextInt(bloomArraySize)];
+ BloomType bloomType = bloomArray[RandomUtils.nextInt(0, bloomArraySize)];
Review comment:
Could also use ThreadLocalRandom.current().nextInt here?
##########
File path:
hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/actions/ChangeCompressionAction.java
##########
@@ -57,7 +56,7 @@ public void perform() throws IOException {
// exception.
Algorithm algo;
do {
- algo = possibleAlgos[random.nextInt(possibleAlgos.length)];
+ algo = possibleAlgos[RandomUtils.nextInt(0, possibleAlgos.length)];
Review comment:
ThreadLocalRandom.current()? Let's follow the same pattern.
##########
File path:
hbase-client/src/main/java/org/apache/hadoop/hbase/client/PerClientRandomNonceGenerator.java
##########
@@ -19,9 +19,8 @@
package org.apache.hadoop.hbase.client;
import java.util.Arrays;
-import java.util.Random;
-
import org.apache.hadoop.hbase.HConstants;
+import org.apache.hbase.thirdparty.io.netty.util.internal.ThreadLocalRandom;
Review comment:
java.util.concurrent.ThreadLocalRandom. Maybe we should ban this import
in maven enforcer to avoid typo.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]