From 948b3fcc35f22422a438610dd9b62bab34df6935 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Fri, 6 Feb 2026 17:24:08 -0500 Subject: [PATCH 1/2] Move Randomness from server to libs/common Signed-off-by: Craig Perkins --- .../fips-demo-installer-cli/build.gradle | 2 +- .../org/opensearch/common/Randomness.java | 19 ------------------- .../org/opensearch/env/NodeEnvironment.java | 2 +- 3 files changed, 2 insertions(+), 21 deletions(-) rename {server => libs/common}/src/main/java/org/opensearch/common/Randomness.java (92%) diff --git a/distribution/tools/fips-demo-installer-cli/build.gradle b/distribution/tools/fips-demo-installer-cli/build.gradle index fe5ce9b798353..3e18fb9bb5c3d 100644 --- a/distribution/tools/fips-demo-installer-cli/build.gradle +++ b/distribution/tools/fips-demo-installer-cli/build.gradle @@ -12,7 +12,7 @@ apply plugin: 'opensearch.build' dependencies { api project(":libs:opensearch-cli") - api project(":server") + api project(":libs:opensearch-common") api project(':distribution:tools:java-version-checker') api "info.picocli:picocli:${versions.picocli}" api "org.bouncycastle:bc-fips:${versions.bouncycastle_jce}" diff --git a/server/src/main/java/org/opensearch/common/Randomness.java b/libs/common/src/main/java/org/opensearch/common/Randomness.java similarity index 92% rename from server/src/main/java/org/opensearch/common/Randomness.java rename to libs/common/src/main/java/org/opensearch/common/Randomness.java index 211c3242088e9..71ce35f77d690 100644 --- a/server/src/main/java/org/opensearch/common/Randomness.java +++ b/libs/common/src/main/java/org/opensearch/common/Randomness.java @@ -32,9 +32,6 @@ package org.opensearch.common; -import org.opensearch.common.settings.Setting; -import org.opensearch.common.settings.Settings; - import java.lang.reflect.Method; import java.security.GeneralSecurityException; import java.security.NoSuchAlgorithmException; @@ -82,22 +79,6 @@ public final class Randomness { private Randomness() {} - /** - * Provides a reproducible source of randomness seeded by a long - * seed in the settings with the key setting. - * - * @param settings the settings containing the seed - * @param setting the setting to access the seed - * @return a reproducible source of randomness - */ - public static Random get(Settings settings, Setting setting) { - if (setting.exists(settings)) { - return new Random(setting.get(settings)); - } else { - return get(); - } - } - /** * Provides a source of randomness that is reproducible when * running under the OpenSearch test suite, and otherwise diff --git a/server/src/main/java/org/opensearch/env/NodeEnvironment.java b/server/src/main/java/org/opensearch/env/NodeEnvironment.java index 8b5c6d4497007..955540cd65368 100644 --- a/server/src/main/java/org/opensearch/env/NodeEnvironment.java +++ b/server/src/main/java/org/opensearch/env/NodeEnvironment.java @@ -507,7 +507,7 @@ private static NodeMetadata loadNodeMetadata(Settings settings, Logger logger, N } public static String generateNodeId(Settings settings) { - Random random = Randomness.get(settings, NODE_ID_SEED_SETTING); + Random random = NODE_ID_SEED_SETTING.exists(settings) ? new Random(NODE_ID_SEED_SETTING.get(settings)) : Randomness.get(); return UUIDs.randomBase64UUID(random); } From ebbd3724e8acaf2204d4e77e33ade50558ffb9bc Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Fri, 6 Feb 2026 17:25:55 -0500 Subject: [PATCH 2/2] Add CHANGELOG entry Signed-off-by: Craig Perkins --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba28875b7119e..c61a5868a96f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Support expected cluster name with validation in CCS Sniff mode ([#20532](https://github.com/opensearch-project/OpenSearch/pull/20532)) ### Changed +- Move Randomness from server to libs/common ([#20570](https://github.com/opensearch-project/OpenSearch/pull/20570)) ### Fixed - Fix flaky test failures in ShardsLimitAllocationDeciderIT ([#20375](https://github.com/opensearch-project/OpenSearch/pull/20375))