HDFS-13459. Ozone: Clean-up of ozone related change from MiniDFSCluste. Contributed by Nandakumar.

This commit is contained in:
Anu Engineer 2018-04-16 16:18:06 -07:00 committed by Owen O'Malley
parent ae8ac7f082
commit 3d18ca4926
3 changed files with 22 additions and 31 deletions

View File

@ -556,14 +556,6 @@ public class MiniDFSCluster implements AutoCloseable {
this.ipcPort = ipcPort; this.ipcPort = ipcPort;
} }
public Configuration getConf() {
return conf;
}
public DataNode getDatanode() {
return datanode;
}
public void setDnArgs(String ... args) { public void setDnArgs(String ... args) {
dnArgs = args; dnArgs = args;
} }
@ -1103,6 +1095,9 @@ public class MiniDFSCluster implements AutoCloseable {
*/ */
public static void configureNameNodes(MiniDFSNNTopology nnTopology, boolean federation, public static void configureNameNodes(MiniDFSNNTopology nnTopology, boolean federation,
Configuration conf) throws IOException { Configuration conf) throws IOException {
Preconditions.checkArgument(nnTopology.countNameNodes() > 0,
"empty NN topology: no namenodes specified!");
if (!federation && nnTopology.countNameNodes() == 1) { if (!federation && nnTopology.countNameNodes() == 1) {
NNConf onlyNN = nnTopology.getOnlyNameNode(); NNConf onlyNN = nnTopology.getOnlyNameNode();
// we only had one NN, set DEFAULT_NAME for it. If not explicitly // we only had one NN, set DEFAULT_NAME for it. If not explicitly
@ -1617,7 +1612,7 @@ public class MiniDFSCluster implements AutoCloseable {
dnConf.addResource(dnConfOverlays[i]); dnConf.addResource(dnConfOverlays[i]);
} }
// Set up datanode address // Set up datanode address
setupDatanodeAddress(i, dnConf, setupHostsFile, checkDataNodeAddrConfig); setupDatanodeAddress(dnConf, setupHostsFile, checkDataNodeAddrConfig);
if (manageDfsDirs) { if (manageDfsDirs) {
String dirs = makeDataNodeDirs(i, storageTypes == null ? String dirs = makeDataNodeDirs(i, storageTypes == null ?
null : storageTypes[i - curDatanodesNum]); null : storageTypes[i - curDatanodesNum]);
@ -2919,19 +2914,16 @@ public class MiniDFSCluster implements AutoCloseable {
/** /**
* Get a storage directory for a datanode. * Get a storage directory for a datanode.
* For examples,
* <ol> * <ol>
* <li><base directory>/data/dn0_data0</li> * <li><base directory>/data/data<2*dnIndex + 1></li>
* <li><base directory>/data/dn0_data1</li> * <li><base directory>/data/data<2*dnIndex + 2></li>
* <li><base directory>/data/dn1_data0</li>
* <li><base directory>/data/dn1_data1</li>
* </ol> * </ol>
* *
* @param dnIndex datanode index (starts from 0) * @param dnIndex datanode index (starts from 0)
* @param dirIndex directory index. * @param dirIndex directory index.
* @return Storage directory * @return Storage directory
*/ */
public static File getStorageDir(int dnIndex, int dirIndex) { public File getStorageDir(int dnIndex, int dirIndex) {
return new File(getBaseDirectory(), getStorageDirPath(dnIndex, dirIndex)); return new File(getBaseDirectory(), getStorageDirPath(dnIndex, dirIndex));
} }
@ -2942,8 +2934,8 @@ public class MiniDFSCluster implements AutoCloseable {
* @param dirIndex directory index. * @param dirIndex directory index.
* @return storage directory path * @return storage directory path
*/ */
private static String getStorageDirPath(int dnIndex, int dirIndex) { private String getStorageDirPath(int dnIndex, int dirIndex) {
return "data/dn" + dnIndex + "_data" + dirIndex; return "data/data" + (storagesPerDatanode * dnIndex + 1 + dirIndex);
} }
/** /**
@ -3208,36 +3200,35 @@ public class MiniDFSCluster implements AutoCloseable {
} }
} }
protected void setupDatanodeAddress( protected void setupDatanodeAddress(Configuration conf, boolean setupHostsFile,
int i, Configuration dnConf, boolean setupHostsFile, boolean checkDataNodeAddrConfig) throws IOException {
boolean checkDataNodeAddrConfig) throws IOException {
if (setupHostsFile) { if (setupHostsFile) {
String hostsFile = dnConf.get(DFS_HOSTS, "").trim(); String hostsFile = conf.get(DFS_HOSTS, "").trim();
if (hostsFile.length() == 0) { if (hostsFile.length() == 0) {
throw new IOException("Parameter dfs.hosts is not setup in conf"); throw new IOException("Parameter dfs.hosts is not setup in conf");
} }
// Setup datanode in the include file, if it is defined in the conf // Setup datanode in the include file, if it is defined in the conf
String address = "127.0.0.1:" + NetUtils.getFreeSocketPort(); String address = "127.0.0.1:" + NetUtils.getFreeSocketPort();
if (checkDataNodeAddrConfig) { if (checkDataNodeAddrConfig) {
dnConf.setIfUnset(DFS_DATANODE_ADDRESS_KEY, address); conf.setIfUnset(DFS_DATANODE_ADDRESS_KEY, address);
} else { } else {
dnConf.set(DFS_DATANODE_ADDRESS_KEY, address); conf.set(DFS_DATANODE_ADDRESS_KEY, address);
} }
addToFile(hostsFile, address); addToFile(hostsFile, address);
LOG.info("Adding datanode " + address + " to hosts file " + hostsFile); LOG.info("Adding datanode " + address + " to hosts file " + hostsFile);
} else { } else {
if (checkDataNodeAddrConfig) { if (checkDataNodeAddrConfig) {
dnConf.setIfUnset(DFS_DATANODE_ADDRESS_KEY, "127.0.0.1:0"); conf.setIfUnset(DFS_DATANODE_ADDRESS_KEY, "127.0.0.1:0");
} else { } else {
dnConf.set(DFS_DATANODE_ADDRESS_KEY, "127.0.0.1:0"); conf.set(DFS_DATANODE_ADDRESS_KEY, "127.0.0.1:0");
} }
} }
if (checkDataNodeAddrConfig) { if (checkDataNodeAddrConfig) {
dnConf.setIfUnset(DFS_DATANODE_HTTP_ADDRESS_KEY, "127.0.0.1:0"); conf.setIfUnset(DFS_DATANODE_HTTP_ADDRESS_KEY, "127.0.0.1:0");
dnConf.setIfUnset(DFS_DATANODE_IPC_ADDRESS_KEY, "127.0.0.1:0"); conf.setIfUnset(DFS_DATANODE_IPC_ADDRESS_KEY, "127.0.0.1:0");
} else { } else {
dnConf.set(DFS_DATANODE_HTTP_ADDRESS_KEY, "127.0.0.1:0"); conf.set(DFS_DATANODE_HTTP_ADDRESS_KEY, "127.0.0.1:0");
dnConf.set(DFS_DATANODE_IPC_ADDRESS_KEY, "127.0.0.1:0"); conf.set(DFS_DATANODE_IPC_ADDRESS_KEY, "127.0.0.1:0");
} }
} }

View File

@ -117,7 +117,7 @@ public class MiniDFSClusterWithNodeGroup extends MiniDFSCluster {
for (int i = curDatanodesNum; i < curDatanodesNum+numDataNodes; i++) { for (int i = curDatanodesNum; i < curDatanodesNum+numDataNodes; i++) {
Configuration dnConf = new HdfsConfiguration(conf); Configuration dnConf = new HdfsConfiguration(conf);
// Set up datanode address // Set up datanode address
setupDatanodeAddress(i, dnConf, setupHostsFile, checkDataNodeAddrConfig); setupDatanodeAddress(dnConf, setupHostsFile, checkDataNodeAddrConfig);
if (manageDfsDirs) { if (manageDfsDirs) {
String dirs = makeDataNodeDirs(i, storageTypes == null ? null : storageTypes[i]); String dirs = makeDataNodeDirs(i, storageTypes == null ? null : storageTypes[i]);
dnConf.set(DFSConfigKeys.DFS_DATANODE_DATA_DIR_KEY, dirs); dnConf.set(DFSConfigKeys.DFS_DATANODE_DATA_DIR_KEY, dirs);