|
@@ -0,0 +1,59 @@
|
|
|
+/**
|
|
|
+ * 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.hdfs.tools;
|
|
|
+
|
|
|
+import org.apache.commons.logging.Log;
|
|
|
+import org.apache.commons.logging.LogFactory;
|
|
|
+import org.apache.hadoop.conf.Configuration;
|
|
|
+import org.apache.hadoop.fs.CommonConfigurationKeys;
|
|
|
+import org.apache.hadoop.ha.HAAdmin;
|
|
|
+import org.apache.hadoop.hdfs.DFSConfigKeys;
|
|
|
+import org.apache.hadoop.hdfs.HdfsConfiguration;
|
|
|
+import org.apache.hadoop.util.ToolRunner;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Class to extend HAAdmin to do a little bit of HDFS-specific configuration.
|
|
|
+ */
|
|
|
+public class DFSHAAdmin extends HAAdmin {
|
|
|
+
|
|
|
+ private static final Log LOG =
|
|
|
+ LogFactory.getLog(DFSHAAdmin.class);
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void setConf(Configuration conf) {
|
|
|
+ if (conf != null) {
|
|
|
+ // Make a copy so we don't mutate it. Also use an HdfsConfiguration to
|
|
|
+ // force loading of hdfs-site.xml.
|
|
|
+ conf = new HdfsConfiguration(conf);
|
|
|
+ String nameNodePrincipal = conf.get(
|
|
|
+ DFSConfigKeys.DFS_NAMENODE_USER_NAME_KEY, "");
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
+ LOG.debug("Using NN principal: " + nameNodePrincipal);
|
|
|
+ }
|
|
|
+
|
|
|
+ conf.set(CommonConfigurationKeys.HADOOP_SECURITY_SERVICE_USER_NAME_KEY,
|
|
|
+ nameNodePrincipal);
|
|
|
+ }
|
|
|
+ super.setConf(conf);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] argv) throws Exception {
|
|
|
+ int res = ToolRunner.run(new DFSHAAdmin(), argv);
|
|
|
+ System.exit(res);
|
|
|
+ }
|
|
|
+}
|