HDFS-13632. Randomize baseDir for MiniJournalCluster in MiniQJMHACluster for TestDFSAdminWithHA. Contributed by Anbang Hu.

This commit is contained in:
Inigo Goiri 2018-05-30 10:02:19 -07:00
parent e44c0849d7
commit 8197b9b560
2 changed files with 11 additions and 3 deletions

View File

@ -49,6 +49,7 @@ public static class Builder {
private int numNNs = 2;
private final MiniDFSCluster.Builder dfsBuilder;
private boolean forceRemoteEditsOnly = false;
private String baseDir;
public Builder(Configuration conf) {
this.conf = conf;
@ -69,6 +70,11 @@ public void startupOption(StartupOption startOpt) {
this.startOpt = startOpt;
}
public Builder baseDir(String d) {
this.baseDir = d;
return this;
}
public Builder setNumNameNodes(int nns) {
this.numNNs = nns;
return this;
@ -104,8 +110,8 @@ private MiniQJMHACluster(Builder builder) throws IOException {
basePort = 10000 + RANDOM.nextInt(1000) * 4;
LOG.info("Set MiniQJMHACluster basePort to " + basePort);
// start 3 journal nodes
journalCluster = new MiniJournalCluster.Builder(conf).format(true)
.build();
journalCluster = new MiniJournalCluster.Builder(conf)
.baseDir(builder.baseDir).format(true).build();
journalCluster.waitActive();
journalCluster.setNamenodeSharedEditsConf(NAMESERVICE);
URI journalURI = journalCluster.getQuorumJournalURI(NAMESERVICE);

View File

@ -32,6 +32,7 @@
import org.apache.hadoop.hdfs.qjournal.MiniQJMHACluster;
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants;
import org.apache.hadoop.hdfs.server.namenode.ha.BootstrapStandby;
import org.apache.hadoop.test.GenericTestUtils;
import org.junit.After;
import org.junit.Test;
@ -85,7 +86,8 @@ private void setUpHaCluster(boolean security) throws Exception {
conf = new Configuration();
conf.setBoolean(CommonConfigurationKeys.HADOOP_SECURITY_AUTHORIZATION,
security);
cluster = new MiniQJMHACluster.Builder(conf).build();
String baseDir = GenericTestUtils.getRandomizedTempPath();
cluster = new MiniQJMHACluster.Builder(conf).baseDir(baseDir).build();
setHAConf(conf, cluster.getDfsCluster().getNameNode(0).getHostAndPort(),
cluster.getDfsCluster().getNameNode(1).getHostAndPort());
cluster.getDfsCluster().getNameNode(0).getHostAndPort();