Skip to content

Commit

Permalink
HDFS-16269. [Fix] Improve NNThroughputBenchmark#blockReport operation. (
Browse files Browse the repository at this point in the history
#3544)

Reviewed-by: Fei Hui <feihui.ustc@gmail.com>
Reviewed-by: Wei-Chiu Chuang <weichiu@apache.org>
Signed-off-by: Akira Ajisaka <aajisaka@apache.org>
(cherry picked from commit 618fea2)

 Conflicts:
	hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNNThroughputBenchmark.java
  • Loading branch information
jianghuazhu authored and aajisaka committed Nov 1, 2021
1 parent 7e57fc0 commit 5fbd9d3
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
Expand Up @@ -1173,10 +1173,28 @@ void generateInputs(int[] ignore) throws IOException {

private ExtendedBlock addBlocks(String fileName, String clientName)
throws IOException {
DatanodeInfo[] excludeNodes = null;
DatanodeInfo[] dnInfos = clientProto.getDatanodeReport(
HdfsConstants.DatanodeReportType.LIVE);
if (dnInfos != null && dnInfos.length > 0) {
List<DatanodeInfo> tmpNodes = new ArrayList<>();
String localHost = DNS.getDefaultHost("default", "default");
for (DatanodeInfo dnInfo : dnInfos) {
if (!localHost.equals(dnInfo.getHostName()) ||
(dnInfo.getXferPort() > datanodes.length)) {
tmpNodes.add(dnInfo);
}
}

if (tmpNodes.size() > 0) {
excludeNodes = tmpNodes.toArray(new DatanodeInfo[tmpNodes.size()]);
}
}

ExtendedBlock prevBlock = null;
for(int jdx = 0; jdx < blocksPerFile; jdx++) {
LocatedBlock loc = addBlock(fileName, clientName,
prevBlock, null, HdfsConstants.GRANDFATHER_INODE_ID, null);
prevBlock, excludeNodes, HdfsConstants.GRANDFATHER_INODE_ID, null);
prevBlock = loc.getBlock();
for(DatanodeInfo dnInfo : loc.getLocations()) {
int dnIdx = dnInfo.getXferPort() - 1;
Expand Down
Expand Up @@ -120,4 +120,25 @@ public void testNNThroughputRemoteAgainstNNWithFsOption() throws Exception {
}
}
}

/**
* This test runs {@link NNThroughputBenchmark} against a mini DFS cluster
* for block report operation.
*/
@Test(timeout = 120000)
public void testNNThroughputForBlockReportOp() throws Exception {
final Configuration conf = new HdfsConfiguration();
conf.setInt(DFSConfigKeys.DFS_NAMENODE_MIN_BLOCK_SIZE_KEY, 16);
conf.setInt(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, 16);
try (MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).
numDataNodes(3).build()) {
cluster.waitActive();
final Configuration benchConf = new HdfsConfiguration();
benchConf.setInt(DFSConfigKeys.DFS_NAMENODE_MIN_BLOCK_SIZE_KEY, 16);
benchConf.setInt(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, 16);
NNThroughputBenchmark.runBenchmark(benchConf,
new String[]{"-fs", cluster.getURI().toString(), "-op",
"blockReport", "-datanodes", "3", "-reports", "2"});
}
}
}

0 comments on commit 5fbd9d3

Please sign in to comment.