Skip to content

Commit 22b36dd

Browse files
S O'Donnellelek
authored andcommitted
HDDS-1660. Use Picocli for Ozone Manager
Closes #925
1 parent 304a47e commit 22b36dd

File tree

13 files changed

+366
-151
lines changed

13 files changed

+366
-151
lines changed

hadoop-ozone/common/src/main/bin/ozone

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function ozonecmd_case
129129
;;
130130
om)
131131
HADOOP_SUBCMD_SUPPORTDAEMONIZATION="true"
132-
HADOOP_CLASSNAME=org.apache.hadoop.ozone.om.OzoneManager
132+
HADOOP_CLASSNAME=org.apache.hadoop.ozone.om.OzoneManagerStarter
133133
HDFS_OM_OPTS="${HDFS_OM_OPTS} -Dlog4j.configurationFile=${HADOOP_CONF_DIR}/om-audit-log4j2.properties"
134134
HADOOP_OPTS="${HADOOP_OPTS} ${HDFS_OM_OPTS}"
135135
OZONE_RUN_ARTIFACT_NAME="hadoop-ozone-ozone-manager"

hadoop-ozone/dev-support/intellij/runConfigurations/OzoneManager.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
-->
1717
<component name="ProjectRunConfigurationManager">
1818
<configuration default="false" name="OzoneManager" type="Application" factoryName="Application">
19-
<option name="MAIN_CLASS_NAME" value="org.apache.hadoop.ozone.om.OzoneManager" />
19+
<option name="MAIN_CLASS_NAME" value="org.apache.hadoop.ozone.om.OzoneManagerStarter" />
2020
<module name="hadoop-ozone-ozone-manager" />
2121
<option name="PROGRAM_PARAMETERS" value="-conf=hadoop-ozone/dev-support/intellij/ozone-site.xml" />
2222
<option name="VM_PARAMETERS" value="-Dlog4j.configuration=file:hadoop-ozone/dev-support/intellij/log4j.properties" />
@@ -30,4 +30,4 @@
3030
<option name="Make" enabled="true" />
3131
</method>
3232
</configuration>
33-
</component>
33+
</component>

hadoop-ozone/dev-support/intellij/runConfigurations/OzoneManagerInit.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
-->
1717
<component name="ProjectRunConfigurationManager">
1818
<configuration default="false" name="OzoneManagerInit" type="Application" factoryName="Application">
19-
<option name="MAIN_CLASS_NAME" value="org.apache.hadoop.ozone.om.OzoneManager" />
19+
<option name="MAIN_CLASS_NAME" value="org.apache.hadoop.ozone.om.OzoneManagerStarter" />
2020
<module name="hadoop-ozone-ozone-manager" />
2121
<option name="PROGRAM_PARAMETERS" value="-conf=hadoop-ozone/dev-support/intellij/ozone-site.xml --init" />
2222
<option name="VM_PARAMETERS" value="-Dlog4j.configuration=file:hadoop-ozone/dev-support/intellij/log4j.properties" />
@@ -30,4 +30,4 @@
3030
<option name="Make" enabled="true" />
3131
</method>
3232
</configuration>
33-
</component>
33+
</component>

hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneClusterImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ OzoneManager createOM()
517517
configureOM();
518518
OMStorage omStore = new OMStorage(conf);
519519
initializeOmStorage(omStore);
520-
return OzoneManager.createOm(null, conf);
520+
return OzoneManager.createOm(conf);
521521
}
522522

523523
/**

hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneHAClusterImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ private Map<String, OzoneManager> createOMService() throws IOException,
211211
OMStorage omStore = new OMStorage(conf);
212212
initializeOmStorage(omStore);
213213

214-
OzoneManager om = OzoneManager.createOm(null, conf);
214+
OzoneManager om = OzoneManager.createOm(conf);
215215
om.setCertClient(certClient);
216216
omMap.put(nodeId, om);
217217

hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestSecureOzoneCluster.java

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ public void testSecureOMInitializationFailure() throws Exception {
383383
setupOm(conf);
384384
conf.set(OMConfigKeys.OZONE_OM_KERBEROS_PRINCIPAL_KEY,
385385
386-
testCommonKerberosFailures(() -> OzoneManager.createOm(null, conf));
386+
testCommonKerberosFailures(() -> OzoneManager.createOm(conf));
387387
}
388388

389389
/**
@@ -662,7 +662,7 @@ private void setupOm(OzoneConfiguration config) throws Exception {
662662
// writes the version file properties
663663
omStore.initialize();
664664
OzoneManager.setTestSecureOmFlag(true);
665-
om = OzoneManager.createOm(null, config);
665+
om = OzoneManager.createOm(config);
666666
}
667667

668668
@Test
@@ -717,6 +717,26 @@ public void testSecureOmReInit() throws Exception {
717717
LogCapturer omLogs =
718718
LogCapturer.captureLogs(OzoneManager.getLogger());
719719
omLogs.clearOutput();
720+
721+
/**
722+
* As all these processes run inside the same JVM, there are issues around
723+
* the Hadoop UGI if different processes run with different principals.
724+
* In this test, the OM has to contact the SCM to download certs. SCM runs
725+
* as scm/host@REALM, but the OM logs in as om/host@REALM, and then the test
726+
* fails, and the OM is unable to contact the SCM due to kerberos login
727+
* issues. To work around that, have the OM run as the same principal as the
728+
* SCM, and then the test passes.
729+
*
730+
* TODO: Need to look into this further to see if there is a better way to
731+
* address this problem.
732+
*/
733+
String realm = miniKdc.getRealm();
734+
conf.set(OMConfigKeys.OZONE_OM_KERBEROS_PRINCIPAL_KEY,
735+
"scm/" + host + "@" + realm);
736+
omKeyTab = new File(workDir, "scm.keytab");
737+
conf.set(OMConfigKeys.OZONE_OM_KERBEROS_KEYTAB_FILE_KEY,
738+
omKeyTab.getAbsolutePath());
739+
720740
initSCM();
721741
try {
722742
scm = StorageContainerManager.createSCM(conf);
@@ -725,7 +745,7 @@ public void testSecureOmReInit() throws Exception {
725745
OMStorage omStore = new OMStorage(conf);
726746
initializeOmStorage(omStore);
727747
OzoneManager.setTestSecureOmFlag(true);
728-
om = OzoneManager.createOm(null, conf);
748+
om = OzoneManager.createOm(conf);
729749

730750
assertNull(om.getCertificateClient());
731751
assertFalse(omLogs.getOutput().contains("Init response: GETCERT"));
@@ -735,7 +755,7 @@ public void testSecureOmReInit() throws Exception {
735755
conf.setBoolean(OZONE_SECURITY_ENABLED_KEY, true);
736756
OzoneManager.omInit(conf);
737757
om.stop();
738-
om = OzoneManager.createOm(null, conf);
758+
om = OzoneManager.createOm(conf);
739759

740760
Assert.assertNotNull(om.getCertificateClient());
741761
Assert.assertNotNull(om.getCertificateClient().getPublicKey());
@@ -771,7 +791,7 @@ public void testSecureOmInitSuccess() throws Exception {
771791
OMStorage omStore = new OMStorage(conf);
772792
initializeOmStorage(omStore);
773793
OzoneManager.setTestSecureOmFlag(true);
774-
om = OzoneManager.createOm(null, conf);
794+
om = OzoneManager.createOm(conf);
775795

776796
Assert.assertNotNull(om.getCertificateClient());
777797
Assert.assertNotNull(om.getCertificateClient().getPublicKey());

hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOmInit.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.apache.hadoop.ozone.web.handlers.UserArgs;
2424
import org.apache.hadoop.ozone.web.interfaces.StorageHandler;
2525
import org.apache.hadoop.ozone.web.utils.OzoneUtils;
26+
import org.apache.hadoop.security.authentication.client.AuthenticationException;
2627
import org.junit.AfterClass;
2728
import org.junit.Assert;
2829
import org.junit.BeforeClass;
@@ -90,10 +91,11 @@ public static void shutdown() {
9091

9192
/**
9293
* Tests the OM Initialization.
93-
* @throws IOException
94+
* @throws IOException, AuthenticationException
9495
*/
9596
@Test
96-
public void testOmInitAgain() throws IOException {
97+
public void testOmInitAgain() throws IOException,
98+
AuthenticationException {
9799
// Stop the Ozone Manager
98100
cluster.getOzoneManager().stop();
99101
// Now try to init the OM again. It should succeed

hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,7 @@ public void testOmInitializationFailure() throws Exception {
13261326
conf.get(ScmConfigKeys.OZONE_SCM_BLOCK_CLIENT_ADDRESS_KEY));
13271327

13281328
OzoneTestUtils.expectOmException(ResultCodes.OM_NOT_INITIALIZED, () -> {
1329-
OzoneManager.createOm(null, config);
1329+
OzoneManager.createOm(config);
13301330
});
13311331

13321332
OzoneTestUtils
@@ -1336,7 +1336,7 @@ public void testOmInitializationFailure() throws Exception {
13361336
omStore.setScmId("testScmId");
13371337
// writes the version file properties
13381338
omStore.initialize();
1339-
OzoneManager.createOm(null, config);
1339+
OzoneManager.createOm(config);
13401340
});
13411341
}
13421342

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with this
4+
* work for additional information regarding copyright ownership. The ASF
5+
* licenses this file to you under the Apache License, Version 2.0 (the
6+
* "License"); you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
* <p>
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
* <p>
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
* License for the specific language governing permissions and limitations under
15+
* the License.
16+
*/
17+
18+
package org.apache.hadoop.ozone.om;
19+
20+
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
21+
import org.apache.hadoop.security.authentication.client.AuthenticationException;
22+
import java.io.IOException;
23+
24+
/**
25+
* This interface is used by the OzoneManagerStarter class to allow the
26+
* dependencies to be injected to the CLI class.
27+
*/
28+
public interface OMStarterInterface {
29+
void start(OzoneConfiguration conf) throws IOException,
30+
AuthenticationException;
31+
boolean init(OzoneConfiguration conf) throws IOException,
32+
AuthenticationException;
33+
}

0 commit comments

Comments
 (0)