HDFS-3284. bootstrapStandby fails in secure cluster. Contributed by Todd Lipcon.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1326812 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Todd Lipcon 2012-04-16 21:51:42 +00:00
parent 27cdd16a50
commit fdffec2f25
3 changed files with 28 additions and 14 deletions

View File

@ -400,6 +400,8 @@ Release 2.0.0 - UNRELEASED
HDFS-3268. FileContext API mishandles token service and incompatible with
HA (Daryn Sharp via todd)
HDFS-3284. bootstrapStandby fails in secure cluster (todd)
BREAKDOWN OF HDFS-1623 SUBTASKS
HDFS-2179. Add fencing framework and mechanisms for NameNode HA. (todd)

View File

@ -51,6 +51,7 @@
import org.apache.hadoop.hdfs.server.namenode.TransferFsImage;
import org.apache.hadoop.hdfs.server.protocol.NamenodeProtocol;
import org.apache.hadoop.hdfs.server.protocol.NamespaceInfo;
import org.apache.hadoop.hdfs.tools.DFSHAAdmin;
import org.apache.hadoop.hdfs.tools.NNHAServiceTarget;
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.io.MD5Hash;
@ -144,8 +145,8 @@ private NamenodeProtocol createNNProtocolProxy()
private HAServiceProtocol createHAProtocolProxy()
throws IOException {
return new NNHAServiceTarget(new HdfsConfiguration(conf),
nsId, otherNNId).getProxy(conf, 15000);
return new NNHAServiceTarget(new HdfsConfiguration(conf), nsId, otherNNId)
.getProxy(conf, 15000);
}
private int doRun() throws IOException {
@ -334,7 +335,7 @@ private void parseConfAndFindOtherNN() throws IOException {
@Override
public void setConf(Configuration conf) {
this.conf = conf;
this.conf = DFSHAAdmin.addSecurityConfiguration(conf);
}
@Override

View File

@ -46,6 +46,18 @@ protected void setErrOut(PrintStream errOut) {
@Override
public void setConf(Configuration conf) {
if (conf != null) {
conf = addSecurityConfiguration(conf);
}
super.setConf(conf);
}
/**
* Add the requisite security principal settings to the given Configuration,
* returning a copy.
* @param conf the original config
* @return a copy with the security settings added
*/
public static Configuration addSecurityConfiguration(Configuration conf) {
// Make a copy so we don't mutate it. Also use an HdfsConfiguration to
// force loading of hdfs-site.xml.
conf = new HdfsConfiguration(conf);
@ -57,8 +69,7 @@ public void setConf(Configuration conf) {
conf.set(CommonConfigurationKeys.HADOOP_SECURITY_SERVICE_USER_NAME_KEY,
nameNodePrincipal);
}
super.setConf(conf);
return conf;
}
/**