Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* Handler for ozone getconf ozonemanagers.
*/
@Command(name = "ozonemanagers",
aliases = {"-ozonemanagers"},
description = "gets list of ozone storage container "
+ "manager nodes in the cluster",
mixinStandardHelpOptions = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* Handler for ozone getconf confKey [key].
*/
@Command(name = "confKey",
aliases = {"-confKey"},
description = "gets a specific key from the configuration",
mixinStandardHelpOptions = true,
versionProvider = HddsVersionProvider.class)
Expand All @@ -42,8 +43,9 @@ public Void call() throws Exception {
String value = tool.getConf().getTrimmed(confKey);
if (value != null) {
tool.printOut(value);
} else {
tool.printError("Configuration " + confKey + " is missing.");
Comment on lines +46 to +47
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find.

}
tool.printError("Configuration " + confKey + " is missing.");
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* Handler for ozone getconf storagecontainermanagers.
*/
@Command(name = "storagecontainermanagers",
aliases = {"-storagecontainermanagers"},
description = "gets list of ozone storage container "
+ "manager nodes in the cluster",
mixinStandardHelpOptions = true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/**
* 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.conf;

import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.scm.ScmConfigKeys;
import org.apache.hadoop.ozone.om.OMConfigKeys;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

/**
* Tests the ozone getconf command.
*/
public class TestGetConfOptions {
private static OzoneConfiguration conf;
private static ByteArrayOutputStream bout;
private static PrintStream psBackup;

@BeforeClass
public static void init() {
conf = new OzoneConfiguration();
conf.set(OMConfigKeys.OZONE_OM_NODE_ID_KEY, "1");
conf.set(OMConfigKeys.OZONE_OM_SERVICE_IDS_KEY, "service1");
conf.set(ScmConfigKeys.OZONE_SCM_NAMES, "localhost");
psBackup = System.out;
bout = new ByteArrayOutputStream();
PrintStream psOut = new PrintStream(bout);
System.setOut(psOut);
}

@After
public void setUp(){
bout.reset();
}

@AfterClass
public static void tearDown(){
System.setOut(psBackup);
}

@Test
public void testGetConfWithTheOptionConfKey() {
new OzoneGetConf(conf)
.run(new String[] {"-confKey", ScmConfigKeys.OZONE_SCM_NAMES});
Assert.assertEquals("localhost\n", bout.toString());
bout.reset();
new OzoneGetConf(conf)
.run(new String[] {"confKey", OMConfigKeys.OZONE_OM_NODE_ID_KEY});
Assert.assertEquals("1\n", bout.toString());
}

@Test
public void testGetConfWithTheOptionStorageContainerManagers() {
new OzoneGetConf(conf).run(new String[] {"-storagecontainermanagers"});
Assert.assertEquals("localhost\n", bout.toString());
bout.reset();
new OzoneGetConf(conf).run(new String[] {"storagecontainermanagers"});
Assert.assertEquals("localhost\n", bout.toString());
}

@Test
public void testGetConfWithTheOptionOzoneManagers() {
new OzoneGetConf(conf).run(new String[] {"-ozonemanagers"});
Assert.assertEquals("{service1=[]}\n", bout.toString());
bout.reset();
new OzoneGetConf(conf).run(new String[] {"ozonemanagers"});
Assert.assertEquals("{service1=[]}\n", bout.toString());
}
}