-
Notifications
You must be signed in to change notification settings - Fork 592
HDDS-10445. OM admin CLI to enable force fetching network topology tree from SCM #6304
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -147,6 +147,7 @@ enum Type { | |
| ListStatusLight = 129; | ||
| GetSnapshotInfo = 130; | ||
| RenameSnapshot = 131; | ||
| RefetchNetworkTopologyTree = 132; | ||
|
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. Let's omit |
||
| } | ||
|
|
||
| enum SafeMode { | ||
|
|
@@ -283,6 +284,7 @@ message OMRequest { | |
| optional SetSnapshotPropertyRequest SetSnapshotPropertyRequest = 127; | ||
| optional SnapshotInfoRequest SnapshotInfoRequest = 128; | ||
| optional RenameSnapshotRequest RenameSnapshotRequest = 129; | ||
| optional RefetchNetworkTopologyTreeRequest RefetchNetworkTopologyTreeRequest = 130; | ||
| } | ||
|
|
||
| message OMResponse { | ||
|
|
@@ -406,6 +408,7 @@ message OMResponse { | |
| optional SnapshotInfoResponse SnapshotInfoResponse = 130; | ||
| optional OMLockDetailsProto omLockDetails = 131; | ||
| optional RenameSnapshotResponse RenameSnapshotResponse = 132; | ||
| optional RefetchNetworkTopologyTreeResponse RefetchNetworkTopologyTreeResponse = 133; | ||
| } | ||
|
|
||
| enum Status { | ||
|
|
@@ -2129,6 +2132,13 @@ message OMLockDetailsProto { | |
| optional uint64 writeLockNanos = 4; | ||
| } | ||
|
|
||
| message RefetchNetworkTopologyTreeRequest { | ||
| } | ||
|
|
||
| message RefetchNetworkTopologyTreeResponse { | ||
| optional bool status = 1; | ||
| } | ||
|
|
||
| /** | ||
| The OM service that takes care of Ozone namespace. | ||
| */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1094,11 +1094,17 @@ private void stopSecretManager() { | |
| } | ||
| } | ||
|
|
||
| @Override | ||
| public UUID refetchSecretKey() { | ||
| secretKeyClient.refetchSecretKey(); | ||
| return secretKeyClient.getCurrentSecretKey().getId(); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean refetchNetworkTopologyTree() { | ||
| return scmTopologyClient.refetchClusterTree(configuration); | ||
|
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. I think admin privilege should be required to make the request. |
||
| } | ||
|
|
||
| @VisibleForTesting | ||
| public void startSecretManager() { | ||
| try { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| /** | ||
| * 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 | ||
| * <p> | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * <p> | ||
| * 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.om; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.concurrent.Callable; | ||
| import org.apache.hadoop.hdds.cli.HddsVersionProvider; | ||
| import org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol; | ||
| import picocli.CommandLine; | ||
|
|
||
| /** | ||
| * Handler of ozone admin om fetch-topology-tree command. | ||
| */ | ||
| @CommandLine.Command( | ||
| name = "fetch-topology-tree", | ||
| description = "CLI command for OM to force fetch the latest network " + | ||
| "topology tree information from SCM.", | ||
| mixinStandardHelpOptions = true, | ||
| versionProvider = HddsVersionProvider.class | ||
| ) | ||
| public class FetchNetworkTopologyTreeSubCommand implements Callable<Void> { | ||
| @CommandLine.ParentCommand | ||
| private OMAdmin parent; | ||
|
|
||
| @CommandLine.Option( | ||
| names = {"--service-id"}, | ||
| description = "Ozone Manager Service ID", | ||
| required = false | ||
| ) | ||
| private String omServiceId; | ||
|
|
||
| @Override | ||
| public Void call() throws Exception { | ||
| try (OzoneManagerProtocol client = parent.createOmClient(omServiceId)) { | ||
| boolean status = false; | ||
| try { | ||
| status = client.refetchNetworkTopologyTree(); | ||
| } catch (IOException e) { | ||
| System.err.println("Force fetching network topology tree information " + | ||
| "has failed: " + e.getMessage()); | ||
| } | ||
| if (status) { | ||
| System.out.println( | ||
| "Force fetching network topology tree information " + | ||
| "is complete."); | ||
| } | ||
|
Comment on lines
+54
to
+61
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. I find this output a bit too verbose. |
||
| } | ||
| return null; | ||
| } | ||
| } | ||
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.
clientneeds to be closed inshutdown().