mukul1987 commented on a change in pull request #1959:
URL: https://github.com/apache/ozone/pull/1959#discussion_r584412936



##########
File path: 
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/DatanodeLayout.java
##########
@@ -0,0 +1,104 @@
+/*
+ * 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.debug;
+
+import org.apache.hadoop.hdds.cli.GenericCli;
+import org.apache.hadoop.hdds.cli.HddsVersionProvider;
+import org.apache.hadoop.hdds.cli.SubcommandWithParent;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.hdds.scm.ScmConfigKeys;
+import org.apache.hadoop.ozone.container.common.impl.ContainerSet;
+import org.apache.hadoop.ozone.container.common.volume.HddsVolume;
+import org.apache.hadoop.ozone.container.common.volume.MutableVolumeSet;
+import org.apache.hadoop.ozone.container.ozoneimpl.OzoneContainer;
+
+import org.kohsuke.MetaInfServices;
+import picocli.CommandLine.Spec;
+import picocli.CommandLine.Model.CommandSpec;
+
+import picocli.CommandLine;
+
+import java.util.List;
+import java.util.concurrent.Callable;
+
+import static org.apache.hadoop.hdds.scm.ScmConfigKeys.HDDS_DATANODE_DIR_KEY;
+
+/**
+ * Parse Ratis Log CLI implementation.
+ */
[email protected](
+    name = "dnlayout",
+    description = "Shell of updating datanode layout format",
+    versionProvider = HddsVersionProvider.class,
+    mixinStandardHelpOptions = true)
+@MetaInfServices(SubcommandWithParent.class)
+public class DatanodeLayout extends GenericCli
+    implements Callable<Void>, SubcommandWithParent{
+
+  @CommandLine.Option(names = {"--path"},
+      required = true,
+      description = "File Path")
+  private String storagePath;
+
+  @CommandLine.Option(names = {"--verify"},
+      description = "Verify that the datanode layout is correct")
+  private boolean verify;
+
+  @Spec
+  private CommandSpec spec;
+
+  @Override
+  public Void call() throws Exception {
+    OzoneConfiguration conf = createOzoneConfiguration();
+
+    runUpgrade(conf, storagePath, verify);
+    return null;
+  }
+
+  public static void main(String[] args) {
+    new DatanodeLayout().run(args);
+  }
+
+  @Override
+  public Class<?> getParentType() {
+    return OzoneDebug.class;
+  }
+
+  public static List<HddsVolume> runUpgrade(OzoneConfiguration conf,
+        String storagePath, boolean verify) throws Exception {
+    conf.unset(HDDS_DATANODE_DIR_KEY);
+    conf.set(HDDS_DATANODE_DIR_KEY, storagePath);
+
+    if (verify) {
+      conf.setBoolean(
+          ScmConfigKeys.HDDS_DATANODE_UPGRADE_LAYOUT_INLINE, false);
+    }
+
+    MutableVolumeSet volumeSet = new MutableVolumeSet(conf);
+    ContainerSet containerSet = new ContainerSet();
+    OzoneContainer.buildContainerSet(volumeSet, containerSet, conf);

Review comment:
       The use of containerSet here is because the Volume reader interface 
needs it, However, this tool on itself does not rely on the container set.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to