HDFS-9503. Use generic option -fs for NNThroughputBenchmark instead of -namenode. Contributed by Mingliang Liu.
This commit is contained in:
parent
5fd4bd1d8c
commit
3f178be0bd
|
@ -897,6 +897,9 @@ Release 2.8.0 - UNRELEASED
|
||||||
HDFS-9721. Allow Delimited PB OIV tool to run upon fsimage that contains
|
HDFS-9721. Allow Delimited PB OIV tool to run upon fsimage that contains
|
||||||
INodeReference. (Xiao Chen via lei)
|
INodeReference. (Xiao Chen via lei)
|
||||||
|
|
||||||
|
HDFS-9503. Use generic option -fs for NNThroughputBenchmark instead of
|
||||||
|
-namenode. (Mingliang Liu via shv)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than
|
HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than
|
||||||
|
|
|
@ -75,6 +75,8 @@ import org.apache.hadoop.security.Groups;
|
||||||
import org.apache.hadoop.security.RefreshUserMappingsProtocol;
|
import org.apache.hadoop.security.RefreshUserMappingsProtocol;
|
||||||
import org.apache.hadoop.security.UserGroupInformation;
|
import org.apache.hadoop.security.UserGroupInformation;
|
||||||
import org.apache.hadoop.test.GenericTestUtils;
|
import org.apache.hadoop.test.GenericTestUtils;
|
||||||
|
import org.apache.hadoop.util.ExitUtil;
|
||||||
|
import org.apache.hadoop.util.GenericOptionsParser;
|
||||||
import org.apache.hadoop.util.StringUtils;
|
import org.apache.hadoop.util.StringUtils;
|
||||||
import org.apache.hadoop.util.Time;
|
import org.apache.hadoop.util.Time;
|
||||||
import org.apache.hadoop.util.Tool;
|
import org.apache.hadoop.util.Tool;
|
||||||
|
@ -94,6 +96,12 @@ import org.apache.log4j.LogManager;
|
||||||
* by calling directly the respective name-node method.
|
* by calling directly the respective name-node method.
|
||||||
* The name-node here is real all other components are simulated.
|
* The name-node here is real all other components are simulated.
|
||||||
*
|
*
|
||||||
|
* This benchmark supports
|
||||||
|
* <a href="{@docRoot}/../hadoop-project-dist/hadoop-common/CommandsManual.html#Generic_Options">
|
||||||
|
* standard command-line options</a>. If you use remote namenode by <tt>-fs</tt>
|
||||||
|
* option, its config <tt>dfs.namenode.fs-limits.min-block-size</tt> should be
|
||||||
|
* set as 16.
|
||||||
|
*
|
||||||
* Command line arguments for the benchmark include:
|
* Command line arguments for the benchmark include:
|
||||||
* <ol>
|
* <ol>
|
||||||
* <li>total number of operations to be performed,</li>
|
* <li>total number of operations to be performed,</li>
|
||||||
|
@ -107,9 +115,6 @@ import org.apache.log4j.LogManager;
|
||||||
* By default the refresh is never called.</li>
|
* By default the refresh is never called.</li>
|
||||||
* <li>-keepResults do not clean up the name-space after execution.</li>
|
* <li>-keepResults do not clean up the name-space after execution.</li>
|
||||||
* <li>-useExisting do not recreate the name-space, use existing data.</li>
|
* <li>-useExisting do not recreate the name-space, use existing data.</li>
|
||||||
* <li>-namenode will run the test (except {@link ReplicationStats}) against a
|
|
||||||
* namenode in another process or on another host. If you use this option,
|
|
||||||
* the namenode must have dfs.namenode.fs-limits.min-block-size set to 16.</li>
|
|
||||||
* </ol>
|
* </ol>
|
||||||
*
|
*
|
||||||
* The benchmark first generates inputs for each thread so that the
|
* The benchmark first generates inputs for each thread so that the
|
||||||
|
@ -124,12 +129,8 @@ import org.apache.log4j.LogManager;
|
||||||
public class NNThroughputBenchmark implements Tool {
|
public class NNThroughputBenchmark implements Tool {
|
||||||
private static final Log LOG = LogFactory.getLog(NNThroughputBenchmark.class);
|
private static final Log LOG = LogFactory.getLog(NNThroughputBenchmark.class);
|
||||||
private static final int BLOCK_SIZE = 16;
|
private static final int BLOCK_SIZE = 16;
|
||||||
private static final String GENERAL_OPTIONS_USAGE =
|
private static final String GENERAL_OPTIONS_USAGE =
|
||||||
" [-keepResults] | [-logLevel L] | [-UGCacheRefreshCount G] |" +
|
"[-keepResults] | [-logLevel L] | [-UGCacheRefreshCount G]";
|
||||||
" [-namenode <namenode URI>]\n" +
|
|
||||||
" If using -namenode, set the namenode's " +
|
|
||||||
"dfs.namenode.fs-limits.min-block-size to 16. Replication test does not " +
|
|
||||||
"support -namenode.";
|
|
||||||
|
|
||||||
static Configuration config;
|
static Configuration config;
|
||||||
static NameNode nameNode;
|
static NameNode nameNode;
|
||||||
|
@ -139,8 +140,6 @@ public class NNThroughputBenchmark implements Tool {
|
||||||
static RefreshUserMappingsProtocol refreshUserMappingsProto;
|
static RefreshUserMappingsProtocol refreshUserMappingsProto;
|
||||||
static String bpid = null;
|
static String bpid = null;
|
||||||
|
|
||||||
private String namenodeUri = null; // NN URI to use, if specified
|
|
||||||
|
|
||||||
NNThroughputBenchmark(Configuration conf) throws IOException {
|
NNThroughputBenchmark(Configuration conf) throws IOException {
|
||||||
config = conf;
|
config = conf;
|
||||||
// We do not need many handlers, since each thread simulates a handler
|
// We do not need many handlers, since each thread simulates a handler
|
||||||
|
@ -384,14 +383,6 @@ public class NNThroughputBenchmark implements Tool {
|
||||||
args.remove(ugrcIndex);
|
args.remove(ugrcIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.indexOf("-namenode") >= 0) {
|
|
||||||
try {
|
|
||||||
namenodeUri = StringUtils.popOptionWithArgument("-namenode", args);
|
|
||||||
} catch (IllegalArgumentException iae) {
|
|
||||||
printUsage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String type = args.get(1);
|
String type = args.get(1);
|
||||||
if(OP_ALL_NAME.equals(type)) {
|
if(OP_ALL_NAME.equals(type)) {
|
||||||
type = getOpName();
|
type = getOpName();
|
||||||
|
@ -1443,15 +1434,19 @@ public class NNThroughputBenchmark implements Tool {
|
||||||
+ " | \n\t" + CleanAllStats.OP_CLEAN_USAGE
|
+ " | \n\t" + CleanAllStats.OP_CLEAN_USAGE
|
||||||
+ " | \n\t" + GENERAL_OPTIONS_USAGE
|
+ " | \n\t" + GENERAL_OPTIONS_USAGE
|
||||||
);
|
);
|
||||||
System.exit(-1);
|
System.err.println();
|
||||||
|
GenericOptionsParser.printGenericCommandUsage(System.err);
|
||||||
|
System.err.println("If connecting to a remote NameNode with -fs option, " +
|
||||||
|
"dfs.namenode.fs-limits.min-block-size should be set to 16.");
|
||||||
|
ExitUtil.terminate(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void runBenchmark(Configuration conf, List<String> args)
|
public static void runBenchmark(Configuration conf, String[] args)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
NNThroughputBenchmark bench = null;
|
NNThroughputBenchmark bench = null;
|
||||||
try {
|
try {
|
||||||
bench = new NNThroughputBenchmark(conf);
|
bench = new NNThroughputBenchmark(conf);
|
||||||
bench.run(args.toArray(new String[]{}));
|
ToolRunner.run(bench, args);
|
||||||
} finally {
|
} finally {
|
||||||
if(bench != null)
|
if(bench != null)
|
||||||
bench.close();
|
bench.close();
|
||||||
|
@ -1471,6 +1466,7 @@ public class NNThroughputBenchmark implements Tool {
|
||||||
String type = args.get(1);
|
String type = args.get(1);
|
||||||
boolean runAll = OperationStatsBase.OP_ALL_NAME.equals(type);
|
boolean runAll = OperationStatsBase.OP_ALL_NAME.equals(type);
|
||||||
|
|
||||||
|
final URI nnUri = FileSystem.getDefaultUri(config);
|
||||||
// Start the NameNode
|
// Start the NameNode
|
||||||
String[] argv = new String[] {};
|
String[] argv = new String[] {};
|
||||||
|
|
||||||
|
@ -1506,10 +1502,9 @@ public class NNThroughputBenchmark implements Tool {
|
||||||
ops.add(opStat);
|
ops.add(opStat);
|
||||||
}
|
}
|
||||||
if(runAll || ReplicationStats.OP_REPLICATION_NAME.equals(type)) {
|
if(runAll || ReplicationStats.OP_REPLICATION_NAME.equals(type)) {
|
||||||
if (namenodeUri != null || args.contains("-namenode")) {
|
if (nnUri.getScheme() != null && nnUri.getScheme().equals("hdfs")) {
|
||||||
LOG.warn("The replication test is ignored as it does not support " +
|
LOG.warn("The replication test is ignored as it does not support " +
|
||||||
"standalone namenode in another process or on another host. " +
|
"standalone namenode in another process or on another host. ");
|
||||||
"Please run replication test without -namenode argument.");
|
|
||||||
} else {
|
} else {
|
||||||
opStat = new ReplicationStats(args);
|
opStat = new ReplicationStats(args);
|
||||||
ops.add(opStat);
|
ops.add(opStat);
|
||||||
|
@ -1523,7 +1518,10 @@ public class NNThroughputBenchmark implements Tool {
|
||||||
printUsage();
|
printUsage();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (namenodeUri == null) {
|
if (nnUri.getScheme() == null || nnUri.getScheme().equals("file")) {
|
||||||
|
LOG.info("Remote NameNode is not specified. Creating one.");
|
||||||
|
FileSystem.setDefaultUri(config, "hdfs://localhost:0");
|
||||||
|
config.set(DFSConfigKeys.DFS_NAMENODE_HTTP_ADDRESS_KEY, "0.0.0.0:0");
|
||||||
nameNode = NameNode.createNameNode(argv, config);
|
nameNode = NameNode.createNameNode(argv, config);
|
||||||
NamenodeProtocols nnProtos = nameNode.getRpcServer();
|
NamenodeProtocols nnProtos = nameNode.getRpcServer();
|
||||||
nameNodeProto = nnProtos;
|
nameNodeProto = nnProtos;
|
||||||
|
@ -1532,10 +1530,8 @@ public class NNThroughputBenchmark implements Tool {
|
||||||
refreshUserMappingsProto = nnProtos;
|
refreshUserMappingsProto = nnProtos;
|
||||||
bpid = nameNode.getNamesystem().getBlockPoolId();
|
bpid = nameNode.getNamesystem().getBlockPoolId();
|
||||||
} else {
|
} else {
|
||||||
FileSystem.setDefaultUri(getConf(), namenodeUri);
|
|
||||||
DistributedFileSystem dfs = (DistributedFileSystem)
|
DistributedFileSystem dfs = (DistributedFileSystem)
|
||||||
FileSystem.get(getConf());
|
FileSystem.get(getConf());
|
||||||
final URI nnUri = new URI(namenodeUri);
|
|
||||||
nameNodeProto = DFSTestUtil.getNamenodeProtocolProxy(config, nnUri,
|
nameNodeProto = DFSTestUtil.getNamenodeProtocolProxy(config, nnUri,
|
||||||
UserGroupInformation.getCurrentUser());
|
UserGroupInformation.getCurrentUser());
|
||||||
clientProto = dfs.getClient().getNamenode();
|
clientProto = dfs.getClient().getNamenode();
|
||||||
|
@ -1570,14 +1566,7 @@ public class NNThroughputBenchmark implements Tool {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
NNThroughputBenchmark bench = null;
|
runBenchmark(new HdfsConfiguration(), args);
|
||||||
try {
|
|
||||||
bench = new NNThroughputBenchmark(new HdfsConfiguration());
|
|
||||||
ToolRunner.run(bench, args);
|
|
||||||
} finally {
|
|
||||||
if(bench != null)
|
|
||||||
bench.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // Configurable
|
@Override // Configurable
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
package org.apache.hadoop.hdfs.server.namenode;
|
package org.apache.hadoop.hdfs.server.namenode;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.fs.FileSystem;
|
import org.apache.hadoop.fs.FileSystem;
|
||||||
|
@ -27,11 +26,18 @@ import org.apache.hadoop.hdfs.DFSConfigKeys;
|
||||||
import org.apache.hadoop.hdfs.DFSTestUtil;
|
import org.apache.hadoop.hdfs.DFSTestUtil;
|
||||||
import org.apache.hadoop.hdfs.HdfsConfiguration;
|
import org.apache.hadoop.hdfs.HdfsConfiguration;
|
||||||
import org.apache.hadoop.hdfs.MiniDFSCluster;
|
import org.apache.hadoop.hdfs.MiniDFSCluster;
|
||||||
|
import org.apache.hadoop.util.ExitUtil;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TestNNThroughputBenchmark {
|
public class TestNNThroughputBenchmark {
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUp() {
|
||||||
|
ExitUtil.disableSystemExit();
|
||||||
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void cleanUp() {
|
public void cleanUp() {
|
||||||
FileUtil.fullyDeleteContents(new File(MiniDFSCluster.getBaseDirectory()));
|
FileUtil.fullyDeleteContents(new File(MiniDFSCluster.getBaseDirectory()));
|
||||||
|
@ -46,10 +52,66 @@ public class TestNNThroughputBenchmark {
|
||||||
File nameDir = new File(MiniDFSCluster.getBaseDirectory(), "name");
|
File nameDir = new File(MiniDFSCluster.getBaseDirectory(), "name");
|
||||||
conf.set(DFSConfigKeys.DFS_NAMENODE_NAME_DIR_KEY,
|
conf.set(DFSConfigKeys.DFS_NAMENODE_NAME_DIR_KEY,
|
||||||
nameDir.getAbsolutePath());
|
nameDir.getAbsolutePath());
|
||||||
FileSystem.setDefaultUri(conf, "hdfs://localhost:" + 0);
|
|
||||||
conf.set(DFSConfigKeys.DFS_NAMENODE_HTTP_ADDRESS_KEY, "0.0.0.0:0");
|
|
||||||
DFSTestUtil.formatNameNode(conf);
|
DFSTestUtil.formatNameNode(conf);
|
||||||
String[] args = new String[] {"-op", "all"};
|
NNThroughputBenchmark.runBenchmark(conf, new String[] {"-op", "all"});
|
||||||
NNThroughputBenchmark.runBenchmark(conf, Arrays.asList(args));
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This test runs all benchmarks defined in {@link NNThroughputBenchmark},
|
||||||
|
* with explicit local -fs option.
|
||||||
|
*/
|
||||||
|
@Test(timeout = 120000)
|
||||||
|
public void testNNThroughputWithFsOption() throws Exception {
|
||||||
|
Configuration conf = new HdfsConfiguration();
|
||||||
|
File nameDir = new File(MiniDFSCluster.getBaseDirectory(), "name");
|
||||||
|
conf.set(DFSConfigKeys.DFS_NAMENODE_NAME_DIR_KEY,
|
||||||
|
nameDir.getAbsolutePath());
|
||||||
|
DFSTestUtil.formatNameNode(conf);
|
||||||
|
NNThroughputBenchmark.runBenchmark(conf,
|
||||||
|
new String[] {"-fs", "file:///", "-op", "all"});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This test runs {@link NNThroughputBenchmark} against a mini DFS cluster.
|
||||||
|
*/
|
||||||
|
@Test(timeout = 120000)
|
||||||
|
public void testNNThroughputAgainstRemoteNN() throws Exception {
|
||||||
|
final Configuration conf = new HdfsConfiguration();
|
||||||
|
conf.setInt(DFSConfigKeys.DFS_NAMENODE_MIN_BLOCK_SIZE_KEY, 16);
|
||||||
|
MiniDFSCluster cluster = null;
|
||||||
|
try {
|
||||||
|
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(0).build();
|
||||||
|
cluster.waitActive();
|
||||||
|
|
||||||
|
final Configuration benchConf = new HdfsConfiguration();
|
||||||
|
FileSystem.setDefaultUri(benchConf, cluster.getURI());
|
||||||
|
NNThroughputBenchmark.runBenchmark(benchConf, new String[]{"-op", "all"});
|
||||||
|
} finally {
|
||||||
|
if (cluster != null) {
|
||||||
|
cluster.shutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This test runs {@link NNThroughputBenchmark} against a mini DFS cluster
|
||||||
|
* with explicit -fs option.
|
||||||
|
*/
|
||||||
|
@Test(timeout = 120000)
|
||||||
|
public void testNNThroughputRemoteAgainstNNWithFsOption() throws Exception {
|
||||||
|
final Configuration conf = new HdfsConfiguration();
|
||||||
|
conf.setInt(DFSConfigKeys.DFS_NAMENODE_MIN_BLOCK_SIZE_KEY, 16);
|
||||||
|
MiniDFSCluster cluster = null;
|
||||||
|
try {
|
||||||
|
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(0).build();
|
||||||
|
cluster.waitActive();
|
||||||
|
|
||||||
|
NNThroughputBenchmark.runBenchmark(new HdfsConfiguration(),
|
||||||
|
new String[]{"-fs", cluster.getURI().toString(), "-op", "all"});
|
||||||
|
} finally {
|
||||||
|
if (cluster != null) {
|
||||||
|
cluster.shutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue