HDDS-15082. Add User facing Config Contract#10147
HDDS-15082. Add User facing Config Contract#10147henrybear327 wants to merge 2 commits intoapache:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an internal ozone local CLI surface and supporting configuration objects to define a user-facing configuration contract for spinning up a local single-node Ozone cluster.
Changes:
- Introduces
OzoneLocal(hidden) CLI withrunsubcommand and env/CLI-based config resolution intoLocalOzoneClusterConfig. - Adds
LocalOzoneClusterConfigandLocalOzoneRuntimeas the local runtime contract/config model. - Adds unit tests covering command metadata/help visibility and config parsing/precedence/validation.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/local/OzoneLocal.java | New internal CLI entry point and config resolution logic from flags/env vars. |
| hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/local/LocalOzoneClusterConfig.java | New config model + builder + FormatMode parsing for user-facing values. |
| hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/local/LocalOzoneRuntime.java | New runtime interface contract for local single-node runtimes. |
| hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/local/package-info.java | New package documentation for the local runtime support package. |
| hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/local/TestOzoneLocal.java | Tests for CLI metadata, help behavior, and env/CLI precedence + validation errors. |
| hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/local/TestLocalOzoneClusterConfig.java | Tests for builder defaults/overrides and FormatMode parsing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| : parsePort(environment.get(ENV_S3G_PORT), ENV_S3G_PORT, | ||
| LocalOzoneClusterConfig.DEFAULT_PORT); | ||
|
|
||
| boolean resolvedS3gEnabled = withoutS3g ? false |
| boolean resolvedEphemeral = ephemeral || parseBoolean( | ||
| environment.get(ENV_EPHEMERAL), ENV_EPHEMERAL, | ||
| LocalOzoneClusterConfig.DEFAULT_EPHEMERAL); |
| public static FormatMode fromString(String value) { | ||
| String normalized = value.trim().toUpperCase(Locale.ROOT) | ||
| .replace('-', '_'); | ||
| return valueOf(normalized); | ||
| } |
| @Override | ||
| public Void call() { | ||
| resolveConfig(new OzoneConfiguration()); | ||
| return null; | ||
| } |
| @Option(names = "--format", | ||
| description = "Storage init mode: if-needed, always, never") | ||
| private String format; |
There was a problem hiding this comment.
could we use enum? not sure if other similar cases do the same thing.
| private static boolean parseBoolean(String rawValue, String source, | ||
| boolean fallback) { | ||
| if (isBlank(rawValue)) { | ||
| return fallback; | ||
| } | ||
| String value = rawValue.trim(); | ||
| if ("true".equalsIgnoreCase(value) | ||
| || "yes".equalsIgnoreCase(value) | ||
| || "on".equalsIgnoreCase(value)) { | ||
| return true; | ||
| } | ||
| if ("false".equalsIgnoreCase(value) | ||
| || "no".equalsIgnoreCase(value) | ||
| || "off".equalsIgnoreCase(value)) { | ||
| return false; | ||
| } | ||
| throw new IllegalArgumentException("Unable to parse " + source | ||
| + " as a boolean. Use true/false, yes/no, or on/off."); | ||
| } |
There was a problem hiding this comment.
please could you help me to look if there is any existing helper for this?
| return parseFormat(rawValue, source); | ||
| } | ||
|
|
||
| private static int parseInt(String rawValue, String source, int fallback) { |
| return parseDuration(rawValue, source, baseConfiguration); | ||
| } | ||
|
|
||
| private static Duration parseDuration(String rawValue, String source, |
There was a problem hiding this comment.
7ce1aa3#r3148108852
ditto
can use ai to scan all of these parsers
|
@henrybear327 please merge upstream master, thanks! |
What changes were proposed in this pull request?
Introduce user-facing paremeters for local ozone cluster spin up.
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-15082
How was this patch tested?
Unit tests.