This is an automated email from the ASF dual-hosted git repository.
adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new ce54200b066 HDDS-14345. Use ThreadLocalRandom in
RandomPipelineChoosePolicy (#9583)
ce54200b066 is described below
commit ce54200b06639fe0c60ba9b6dca75b4f758d2359
Author: Siddhant Sangwan <[email protected]>
AuthorDate: Wed Jan 7 19:31:53 2026 +0530
HDDS-14345. Use ThreadLocalRandom in RandomPipelineChoosePolicy (#9583)
---
.../scm/pipeline/choose/algorithms/RandomPipelineChoosePolicy.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/choose/algorithms/RandomPipelineChoosePolicy.java
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/choose/algorithms/RandomPipelineChoosePolicy.java
index c9c787d9cdd..0ec3c4bf1dd 100644
---
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/choose/algorithms/RandomPipelineChoosePolicy.java
+++
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/choose/algorithms/RandomPipelineChoosePolicy.java
@@ -18,6 +18,7 @@
package org.apache.hadoop.hdds.scm.pipeline.choose.algorithms;
import java.util.List;
+import java.util.concurrent.ThreadLocalRandom;
import org.apache.hadoop.hdds.scm.PipelineChoosePolicy;
import org.apache.hadoop.hdds.scm.PipelineRequestInformation;
import org.apache.hadoop.hdds.scm.pipeline.Pipeline;
@@ -46,6 +47,9 @@ public Pipeline choosePipeline(List<Pipeline> pipelineList,
@Override
public int choosePipelineIndex(List<Pipeline> pipelineList,
PipelineRequestInformation pri) {
- return (int) (Math.random() * pipelineList.size());
+ if (pipelineList.isEmpty()) {
+ return -1;
+ }
+ return ThreadLocalRandom.current().nextInt(pipelineList.size());
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]