Copilot commented on code in PR #10147: URL: https://github.com/apache/ozone/pull/10147#discussion_r3147982807
########## hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/local/OzoneLocal.java: ########## @@ -0,0 +1,385 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.ozone.local; + +import java.nio.file.InvalidPathException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.time.Duration; +import java.time.format.DateTimeParseException; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.Callable; +import java.util.concurrent.TimeUnit; +import org.apache.hadoop.hdds.cli.GenericCli; +import org.apache.hadoop.hdds.cli.HddsVersionProvider; +import org.apache.hadoop.hdds.conf.OzoneConfiguration; +import picocli.CommandLine; +import picocli.CommandLine.Command; +import picocli.CommandLine.Option; + +/** + * Internal CLI entry point for local single-node Ozone commands. + */ +@Command(name = "ozone local", + hidden = true, + description = "Internal commands for local single-node Ozone", + versionProvider = HddsVersionProvider.class, + mixinStandardHelpOptions = true, + subcommands = { + OzoneLocal.RunCommand.class + }) +public class OzoneLocal extends GenericCli { + + static final String ENV_DATA_DIR = "OZONE_LOCAL_DATA_DIR"; + static final String ENV_FORMAT = "OZONE_LOCAL_FORMAT"; + static final String ENV_DATANODES = "OZONE_LOCAL_DATANODES"; + static final String ENV_HOST = "OZONE_LOCAL_HOST"; + static final String ENV_BIND_HOST = "OZONE_LOCAL_BIND_HOST"; + static final String ENV_SCM_PORT = "OZONE_LOCAL_SCM_PORT"; + static final String ENV_OM_PORT = "OZONE_LOCAL_OM_PORT"; + static final String ENV_S3G_ENABLED = "OZONE_LOCAL_S3G_ENABLED"; + static final String ENV_S3G_PORT = "OZONE_LOCAL_S3G_PORT"; + static final String ENV_EPHEMERAL = "OZONE_LOCAL_EPHEMERAL"; + static final String ENV_STARTUP_TIMEOUT = "OZONE_LOCAL_STARTUP_TIMEOUT"; + static final String ENV_S3_ACCESS_KEY = "OZONE_LOCAL_S3_ACCESS_KEY"; + static final String ENV_S3_SECRET_KEY = "OZONE_LOCAL_S3_SECRET_KEY"; + static final String ENV_S3_REGION = "OZONE_LOCAL_S3_REGION"; + + public OzoneLocal() { + super(); + } + + OzoneLocal(CommandLine.IFactory factory) { + super(factory); + } + + public static void main(String[] args) { + new OzoneLocal().run(args); + } + + @Command(name = "run", + hidden = true, + description = "Internal placeholder for a local Ozone runtime") + static class RunCommand implements Callable<Void> { + + private final Map<String, String> environment; + + @Option(names = "--data-dir", + description = "Persistent data directory for the local cluster") + private String dataDir; + + @Option(names = "--format", + description = "Storage init mode: if-needed, always, never") + private String format; + + @Option(names = "--datanodes", + description = "Number of datanodes to start") + private Integer datanodes; + + @Option(names = "--host", + description = "Advertised host to write into local service addresses") + private String host; + + @Option(names = "--bind-host", + description = "Bind host for HTTP and RPC listeners") + private String bindHost; + + @Option(names = "--scm-port", + description = "SCM client RPC port (0 means auto-allocate)") + private Integer scmPort; + + @Option(names = "--om-port", + description = "OM RPC port (0 means auto-allocate)") + private Integer omPort; + + @Option(names = "--s3g-port", + description = "S3 Gateway HTTP port (0 means auto-allocate)") + private Integer s3gPort; + + @Option(names = "--without-s3g", + description = "Disable S3 Gateway") + private boolean withoutS3g; + + @Option(names = "--ephemeral", + description = "Delete the data directory on shutdown") + private boolean ephemeral; + + @Option(names = "--startup-timeout", + description = "How long to wait for the local cluster to become ready") + private String startupTimeout; + + @Option(names = "--s3-access-key", + description = "Suggested local AWS access key to print on startup") + private String s3AccessKey; + + @Option(names = "--s3-secret-key", + description = "Suggested local AWS secret key to print on startup") + private String s3SecretKey; + + @Option(names = "--s3-region", + description = "Suggested local AWS region to print on startup") + private String s3Region; + + RunCommand() { + this(System.getenv()); + } + + RunCommand(Map<String, String> environment) { + this.environment = Objects.requireNonNull(environment, "environment"); + } + + @Override + public Void call() { + resolveConfig(new OzoneConfiguration()); + return null; + } Review Comment: `RunCommand.call()` constructs a new `OzoneConfiguration` instead of using the `GenericCli` configuration (including `-conf` resources and `-D/--set` overrides). This means user-supplied config overrides won’t affect parsing (and future runtime startup). Consider wiring the parent `OzoneLocal` into `RunCommand` (eg via `@ParentCommand` or extending `AbstractSubcommand`) and passing `parent.getOzoneConf()` into `resolveConfig(...)`. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
