-
Notifications
You must be signed in to change notification settings - Fork 601
HDDS-15081. Add Internal Scaffold #10146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/local/LocalOzoneRuntime.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| /* | ||
| * 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; | ||
|
|
||
| /** | ||
| * Runtime contract for local single-node Ozone commands. | ||
| */ | ||
| public interface LocalOzoneRuntime extends AutoCloseable { | ||
|
|
||
| void start() throws Exception; | ||
|
|
||
| String getDisplayHost(); | ||
|
|
||
| int getScmPort(); | ||
|
|
||
| int getOmPort(); | ||
|
|
||
| int getS3gPort(); | ||
|
|
||
| String getS3Endpoint(); | ||
|
|
||
| @Override | ||
| void close() throws Exception; | ||
| } |
52 changes: 52 additions & 0 deletions
52
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/local/OzoneLocal.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /* | ||
| * 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.util.concurrent.Callable; | ||
| import org.apache.hadoop.hdds.cli.GenericCli; | ||
| import org.apache.hadoop.hdds.cli.HddsVersionProvider; | ||
| import picocli.CommandLine.Command; | ||
|
|
||
| /** | ||
| * 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 { | ||
|
|
||
| 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> { | ||
|
|
||
| @Override | ||
| public Void call() { | ||
| return null; | ||
| } | ||
| } | ||
| } |
21 changes: 21 additions & 0 deletions
21
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/local/package-info.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| /** | ||
| * Internal local single-node Ozone runtime support. | ||
| */ | ||
| package org.apache.hadoop.ozone.local; |
100 changes: 100 additions & 0 deletions
100
hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/local/TestOzoneLocal.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| /* | ||
| * 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 static java.nio.charset.StandardCharsets.UTF_8; | ||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertFalse; | ||
| import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| import java.io.ByteArrayOutputStream; | ||
| import java.io.OutputStreamWriter; | ||
| import java.io.PrintWriter; | ||
| import org.junit.jupiter.api.Test; | ||
| import picocli.CommandLine; | ||
| import picocli.CommandLine.Command; | ||
|
|
||
| /** | ||
| * Tests for {@link OzoneLocal}. | ||
| */ | ||
| class TestOzoneLocal { | ||
|
|
||
| @Test | ||
| void localCommandMetadataIsPresentAndHidden() { | ||
| Command command = OzoneLocal.class.getAnnotation(Command.class); | ||
|
|
||
| assertNotNull(command); | ||
| assertEquals("ozone local", command.name()); | ||
| assertTrue(command.hidden()); | ||
| } | ||
|
|
||
| @Test | ||
| void runCommandMetadataIsPresentAndHidden() { | ||
| Command command = OzoneLocal.RunCommand.class.getAnnotation(Command.class); | ||
|
|
||
| assertNotNull(command); | ||
| assertEquals("run", command.name()); | ||
| assertTrue(command.hidden()); | ||
| } | ||
|
|
||
| @Test | ||
| void genericCliRegistersRunPlaceholder() { | ||
| OzoneLocal local = new OzoneLocal(); | ||
|
|
||
| assertTrue(local.getCmd().getSubcommands().containsKey("run")); | ||
| } | ||
|
|
||
| @Test | ||
| void rootHelpHidesRunPlaceholder() throws Exception { | ||
| OzoneLocal local = new OzoneLocal(); | ||
| CommandLine commandLine = local.getCmd(); | ||
| ByteArrayOutputStream out = new ByteArrayOutputStream(); | ||
| ByteArrayOutputStream err = new ByteArrayOutputStream(); | ||
| commandLine.setOut(new PrintWriter(new OutputStreamWriter(out, UTF_8), | ||
| true)); | ||
| commandLine.setErr(new PrintWriter(new OutputStreamWriter(err, UTF_8), | ||
| true)); | ||
|
|
||
| int exitCode = local.execute(new String[] {"--help"}); | ||
|
|
||
| String help = out.toString(UTF_8.name()); | ||
| assertEquals(0, exitCode); | ||
| assertTrue(help.contains("Usage: ozone local")); | ||
| assertFalse(help.contains("run")); | ||
| assertEquals("", err.toString(UTF_8.name())); | ||
| } | ||
|
|
||
| @Test | ||
| void runCommandIsQuietNoOpPlaceholder() throws Exception { | ||
| OzoneLocal local = new OzoneLocal(); | ||
| CommandLine commandLine = local.getCmd(); | ||
| ByteArrayOutputStream out = new ByteArrayOutputStream(); | ||
| ByteArrayOutputStream err = new ByteArrayOutputStream(); | ||
| commandLine.setOut(new PrintWriter(new OutputStreamWriter(out, UTF_8), | ||
| true)); | ||
| commandLine.setErr(new PrintWriter(new OutputStreamWriter(err, UTF_8), | ||
| true)); | ||
|
|
||
| int exitCode = local.execute(new String[] {"run"}); | ||
|
|
||
| assertEquals(0, exitCode); | ||
| assertEquals("", out.toString(UTF_8.name())); | ||
| assertEquals("", err.toString(UTF_8.name())); | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.