|
@@ -157,6 +157,7 @@ public class MiniDFSCluster {
|
|
private boolean checkExitOnShutdown = true;
|
|
private boolean checkExitOnShutdown = true;
|
|
private boolean checkDataNodeAddrConfig = false;
|
|
private boolean checkDataNodeAddrConfig = false;
|
|
private boolean checkDataNodeHostConfig = false;
|
|
private boolean checkDataNodeHostConfig = false;
|
|
|
|
+ private Configuration[] dnConfOverlays;
|
|
|
|
|
|
public Builder(Configuration conf) {
|
|
public Builder(Configuration conf) {
|
|
this.conf = conf;
|
|
this.conf = conf;
|
|
@@ -333,6 +334,19 @@ public class MiniDFSCluster {
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Default: null
|
|
|
|
+ *
|
|
|
|
+ * An array of {@link Configuration} objects that will overlay the
|
|
|
|
+ * global MiniDFSCluster Configuration for the corresponding DataNode.
|
|
|
|
+ *
|
|
|
|
+ * Useful for setting specific per-DataNode configuration parameters.
|
|
|
|
+ */
|
|
|
|
+ public Builder dataNodeConfOverlays(Configuration[] dnConfOverlays) {
|
|
|
|
+ this.dnConfOverlays = dnConfOverlays;
|
|
|
|
+ return this;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Construct the actual MiniDFSCluster
|
|
* Construct the actual MiniDFSCluster
|
|
*/
|
|
*/
|
|
@@ -375,7 +389,8 @@ public class MiniDFSCluster {
|
|
builder.nnTopology,
|
|
builder.nnTopology,
|
|
builder.checkExitOnShutdown,
|
|
builder.checkExitOnShutdown,
|
|
builder.checkDataNodeAddrConfig,
|
|
builder.checkDataNodeAddrConfig,
|
|
- builder.checkDataNodeHostConfig);
|
|
|
|
|
|
+ builder.checkDataNodeHostConfig,
|
|
|
|
+ builder.dnConfOverlays);
|
|
}
|
|
}
|
|
|
|
|
|
public class DataNodeProperties {
|
|
public class DataNodeProperties {
|
|
@@ -621,7 +636,7 @@ public class MiniDFSCluster {
|
|
manageNameDfsDirs, true, manageDataDfsDirs, manageDataDfsDirs,
|
|
manageNameDfsDirs, true, manageDataDfsDirs, manageDataDfsDirs,
|
|
operation, null, racks, hosts,
|
|
operation, null, racks, hosts,
|
|
simulatedCapacities, null, true, false,
|
|
simulatedCapacities, null, true, false,
|
|
- MiniDFSNNTopology.simpleSingleNN(nameNodePort, 0), true, false, false);
|
|
|
|
|
|
+ MiniDFSNNTopology.simpleSingleNN(nameNodePort, 0), true, false, false, null);
|
|
}
|
|
}
|
|
|
|
|
|
private void initMiniDFSCluster(
|
|
private void initMiniDFSCluster(
|
|
@@ -634,7 +649,8 @@ public class MiniDFSCluster {
|
|
boolean waitSafeMode, boolean setupHostsFile,
|
|
boolean waitSafeMode, boolean setupHostsFile,
|
|
MiniDFSNNTopology nnTopology, boolean checkExitOnShutdown,
|
|
MiniDFSNNTopology nnTopology, boolean checkExitOnShutdown,
|
|
boolean checkDataNodeAddrConfig,
|
|
boolean checkDataNodeAddrConfig,
|
|
- boolean checkDataNodeHostConfig)
|
|
|
|
|
|
+ boolean checkDataNodeHostConfig,
|
|
|
|
+ Configuration[] dnConfOverlays)
|
|
throws IOException {
|
|
throws IOException {
|
|
ExitUtil.disableSystemExit();
|
|
ExitUtil.disableSystemExit();
|
|
|
|
|
|
@@ -699,7 +715,7 @@ public class MiniDFSCluster {
|
|
startDataNodes(conf, numDataNodes, storageType, manageDataDfsDirs,
|
|
startDataNodes(conf, numDataNodes, storageType, manageDataDfsDirs,
|
|
dnStartOpt != null ? dnStartOpt : startOpt,
|
|
dnStartOpt != null ? dnStartOpt : startOpt,
|
|
racks, hosts, simulatedCapacities, setupHostsFile,
|
|
racks, hosts, simulatedCapacities, setupHostsFile,
|
|
- checkDataNodeAddrConfig, checkDataNodeHostConfig);
|
|
|
|
|
|
+ checkDataNodeAddrConfig, checkDataNodeHostConfig, dnConfOverlays);
|
|
waitClusterUp();
|
|
waitClusterUp();
|
|
//make sure ProxyUsers uses the latest conf
|
|
//make sure ProxyUsers uses the latest conf
|
|
ProxyUsers.refreshSuperUserGroupsConfiguration(conf);
|
|
ProxyUsers.refreshSuperUserGroupsConfiguration(conf);
|
|
@@ -1102,7 +1118,7 @@ public class MiniDFSCluster {
|
|
long[] simulatedCapacities,
|
|
long[] simulatedCapacities,
|
|
boolean setupHostsFile) throws IOException {
|
|
boolean setupHostsFile) throws IOException {
|
|
startDataNodes(conf, numDataNodes, StorageType.DEFAULT, manageDfsDirs, operation, racks, hosts,
|
|
startDataNodes(conf, numDataNodes, StorageType.DEFAULT, manageDfsDirs, operation, racks, hosts,
|
|
- simulatedCapacities, setupHostsFile, false, false);
|
|
|
|
|
|
+ simulatedCapacities, setupHostsFile, false, false, null);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1116,7 +1132,7 @@ public class MiniDFSCluster {
|
|
boolean setupHostsFile,
|
|
boolean setupHostsFile,
|
|
boolean checkDataNodeAddrConfig) throws IOException {
|
|
boolean checkDataNodeAddrConfig) throws IOException {
|
|
startDataNodes(conf, numDataNodes, StorageType.DEFAULT, manageDfsDirs, operation, racks, hosts,
|
|
startDataNodes(conf, numDataNodes, StorageType.DEFAULT, manageDfsDirs, operation, racks, hosts,
|
|
- simulatedCapacities, setupHostsFile, checkDataNodeAddrConfig, false);
|
|
|
|
|
|
+ simulatedCapacities, setupHostsFile, checkDataNodeAddrConfig, false, null);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1143,7 +1159,8 @@ public class MiniDFSCluster {
|
|
* @param setupHostsFile add new nodes to dfs hosts files
|
|
* @param setupHostsFile add new nodes to dfs hosts files
|
|
* @param checkDataNodeAddrConfig if true, only set DataNode port addresses if not already set in config
|
|
* @param checkDataNodeAddrConfig if true, only set DataNode port addresses if not already set in config
|
|
* @param checkDataNodeHostConfig if true, only set DataNode hostname key if not already set in config
|
|
* @param checkDataNodeHostConfig if true, only set DataNode hostname key if not already set in config
|
|
- *
|
|
|
|
|
|
+ * @param dnConfOverlays An array of {@link Configuration} objects that will overlay the
|
|
|
|
+ * global MiniDFSCluster Configuration for the corresponding DataNode.
|
|
* @throws IllegalStateException if NameNode has been shutdown
|
|
* @throws IllegalStateException if NameNode has been shutdown
|
|
*/
|
|
*/
|
|
public synchronized void startDataNodes(Configuration conf, int numDataNodes,
|
|
public synchronized void startDataNodes(Configuration conf, int numDataNodes,
|
|
@@ -1152,7 +1169,8 @@ public class MiniDFSCluster {
|
|
long[] simulatedCapacities,
|
|
long[] simulatedCapacities,
|
|
boolean setupHostsFile,
|
|
boolean setupHostsFile,
|
|
boolean checkDataNodeAddrConfig,
|
|
boolean checkDataNodeAddrConfig,
|
|
- boolean checkDataNodeHostConfig) throws IOException {
|
|
|
|
|
|
+ boolean checkDataNodeHostConfig,
|
|
|
|
+ Configuration[] dnConfOverlays) throws IOException {
|
|
if (operation == StartupOption.RECOVER) {
|
|
if (operation == StartupOption.RECOVER) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -1192,6 +1210,13 @@ public class MiniDFSCluster {
|
|
+ simulatedCapacities.length
|
|
+ simulatedCapacities.length
|
|
+ "] is less than the number of datanodes [" + numDataNodes + "].");
|
|
+ "] is less than the number of datanodes [" + numDataNodes + "].");
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if (dnConfOverlays != null
|
|
|
|
+ && numDataNodes > dnConfOverlays.length) {
|
|
|
|
+ throw new IllegalArgumentException( "The length of dnConfOverlays ["
|
|
|
|
+ + dnConfOverlays.length
|
|
|
|
+ + "] is less than the number of datanodes [" + numDataNodes + "].");
|
|
|
|
+ }
|
|
|
|
|
|
String [] dnArgs = (operation == null ||
|
|
String [] dnArgs = (operation == null ||
|
|
operation != StartupOption.ROLLBACK) ?
|
|
operation != StartupOption.ROLLBACK) ?
|
|
@@ -1200,6 +1225,9 @@ public class 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);
|
|
|
|
+ if (dnConfOverlays != null) {
|
|
|
|
+ dnConf.addResource(dnConfOverlays[i]);
|
|
|
|
+ }
|
|
// Set up datanode address
|
|
// Set up datanode address
|
|
setupDatanodeAddress(dnConf, setupHostsFile, checkDataNodeAddrConfig);
|
|
setupDatanodeAddress(dnConf, setupHostsFile, checkDataNodeAddrConfig);
|
|
if (manageDfsDirs) {
|
|
if (manageDfsDirs) {
|