-
Notifications
You must be signed in to change notification settings - Fork 590
HDDS-4115. CLI command to show current SCM leader and follower status. #1346
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
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ad3962e
HDDS-4115. CLI command to show current SCM leader and follower status.
amaliujia 0269d6c
fixup! address comments.
amaliujia 9850815
fixup! fix style
amaliujia 08ce2bc
fixup! fix style
amaliujia 56f2036
fixup! add cli command description
amaliujia 8373b6d
fixup! 1. use `ozone admin scm roles` 2. fix acceptance test
amaliujia 277089b
fixup! fix checkstyle
amaliujia 02810b2
fixup! address comments
amaliujia 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
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
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
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
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
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
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
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
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
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
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
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
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,28 @@ | ||
| # 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. | ||
|
|
||
| *** Settings *** | ||
| Documentation Smoketest ozone cluster startup | ||
| Library OperatingSystem | ||
| Library BuiltIn | ||
| Resource ../commonlib.robot | ||
| Test Timeout 5 minutes | ||
|
|
||
| *** Variables *** | ||
|
|
||
| *** Test Cases *** | ||
| Run scm roles | ||
| ${output} = Execute ozone admin scm roles | ||
| Should contain ${output} [] |
79 changes: 79 additions & 0 deletions
79
...op-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestScmAdminHA.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,79 @@ | ||
| /* | ||
| * 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.shell; | ||
amaliujia marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| import java.net.InetSocketAddress; | ||
| import java.util.UUID; | ||
| import org.apache.hadoop.hdds.conf.OzoneConfiguration; | ||
| import org.apache.hadoop.hdds.scm.ScmConfigKeys; | ||
| import org.apache.hadoop.ozone.MiniOzoneCluster; | ||
| import org.apache.hadoop.ozone.admin.OzoneAdmin; | ||
| import org.junit.AfterClass; | ||
| import org.junit.BeforeClass; | ||
| import org.junit.Test; | ||
|
|
||
| /** | ||
| * This class tests ozone admin scm commands. | ||
| */ | ||
| public class TestScmAdminHA { | ||
| private static OzoneAdmin ozoneAdmin; | ||
| private static OzoneConfiguration conf; | ||
| private static String omServiceId; | ||
| private static int numOfOMs; | ||
| private static String clusterId; | ||
| private static String scmId; | ||
| private static MiniOzoneCluster cluster; | ||
|
|
||
| @BeforeClass | ||
| public static void init() throws Exception { | ||
| ozoneAdmin = new OzoneAdmin(); | ||
| conf = new OzoneConfiguration(); | ||
|
|
||
| // Init HA cluster | ||
| omServiceId = "om-service-test1"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean SCM here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually I meant OM. It turns out that I cannot ignore |
||
| numOfOMs = 3; | ||
| clusterId = UUID.randomUUID().toString(); | ||
| scmId = UUID.randomUUID().toString(); | ||
| cluster = MiniOzoneCluster.newHABuilder(conf) | ||
| .setClusterId(clusterId) | ||
| .setScmId(scmId) | ||
| .setOMServiceId(omServiceId) | ||
| .setNumOfOzoneManagers(numOfOMs) | ||
| .build(); | ||
| conf.setQuietMode(false); | ||
| // enable ratis for Scm. | ||
| conf.setBoolean(ScmConfigKeys.DFS_CONTAINER_RATIS_ENABLED_KEY, true); | ||
| cluster.waitForClusterToBeReady(); | ||
| } | ||
|
|
||
| @AfterClass | ||
| public static void shutdown() { | ||
| if (cluster != null) { | ||
| cluster.shutdown(); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void testGetRatisRoles() { | ||
| InetSocketAddress address = | ||
| cluster.getStorageContainerManager().getClientRpcAddress(); | ||
| String hostPort = address.getHostName() + ":" + address.getPort(); | ||
| String[] args = {"--scm", hostPort, "scm", "roles"}; | ||
| ozoneAdmin.execute(args); | ||
amaliujia marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
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
46 changes: 46 additions & 0 deletions
46
...one/tools/src/main/java/org/apache/hadoop/ozone/admin/scm/GetScmRatisRolesSubcommand.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,46 @@ | ||
| /* | ||
| * 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.admin.scm; | ||
|
|
||
| import java.util.List; | ||
| import java.util.concurrent.Callable; | ||
| import org.apache.hadoop.hdds.cli.HddsVersionProvider; | ||
| import org.apache.hadoop.hdds.scm.client.ScmClient; | ||
| import picocli.CommandLine; | ||
|
|
||
| /** | ||
| * Handler of scm status command. | ||
| */ | ||
| @CommandLine.Command( | ||
| name = "roles", | ||
| description = "List all SCMs and their respective Ratis server roles", | ||
| mixinStandardHelpOptions = true, | ||
| versionProvider = HddsVersionProvider.class) | ||
| public class GetScmRatisRolesSubcommand implements Callable<Void> { | ||
|
|
||
| @CommandLine.ParentCommand | ||
| private ScmAdmin parent; | ||
|
|
||
| @Override | ||
| public Void call() throws Exception { | ||
| ScmClient scmClient = parent.createScmClient(); | ||
| List<String> roles = scmClient.getScmRatisRoles(); | ||
| System.out.println(roles); | ||
| return null; | ||
| } | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use the default SCM RatisServer port. Check ratisBindPort in SCMHAConfiguration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switched to use the default port. In the future I will think about how to better construct
MockSCMHAManagerfor testing purpose (as the code is evolving we can keep updatingMockSCMHAManager)