1 Star 0 Fork 1

Kunpeng/hadoop

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
hdfs-testdfsio-0001.patch 2.68 KB
一键复制 编辑 原始数据 按行查看 历史
包旻晨 提交于 6个月前 . generate patch
From 0717110dd94de064d6e57d32f9e1913d0d701326 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=8C=85=E6=97=BB=E6=99=A8?= <minchen_bao_dev@163.com>
Date: Mon, 4 Nov 2024 19:22:50 +0800
Subject: [PATCH] testDFSIO
---
.../java/org/apache/hadoop/fs/TestDFSIO.java | 31 ++++++++++++-------
1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/fs/TestDFSIO.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/fs/TestDFSIO.java
index 10709bec0fe..8b01fe3248b 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/fs/TestDFSIO.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/fs/TestDFSIO.java
@@ -28,6 +28,8 @@
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.text.DecimalFormat;
import java.util.Collection;
import java.util.Date;
@@ -430,17 +432,24 @@ public Long doIO(Reporter reporter,
String name,
long totalSize // in bytes
) throws IOException {
- OutputStream out = (OutputStream)this.stream;
- // write to the file
- long nrRemaining;
- for (nrRemaining = totalSize; nrRemaining > 0; nrRemaining -= bufferSize) {
- int curSize = (bufferSize < nrRemaining) ? bufferSize : (int)nrRemaining;
- out.write(buffer, 0, curSize);
- reporter.setStatus("writing " + name + "@" +
- (totalSize - nrRemaining) + "/" + totalSize
- + " ::host = " + hostName);
- }
- return Long.valueOf(totalSize);
+ OutputStream out = (OutputStream) this.stream;
+ // write to the file
+ long nrRemaining;
+ byte[] ioTestData = getIoTestDataFromLocal();
+ long delta = Math.min(totalSize, ioTestData.length);
+ for (nrRemaining = totalSize; nrRemaining > 0; nrRemaining -= delta) {
+ long curSize = (delta < nrRemaining) ? delta : (int) nrRemaining;
+ out.write(ioTestData, 0, (int) curSize);
+ reporter.setStatus("writing " + name + "@" +
+ (totalSize - nrRemaining) + "/" + totalSize
+ + " ::host = " + hostName);
+ }
+ return Long.valueOf(totalSize);
+ }
+
+ private byte[] getIoTestDataFromLocal() throws IOException {
+ java.nio.file.Path path = Paths.get("/usr/local/hadoop/testFiles/test_io_file");
+ return Files.readAllBytes(path);
}
}
--
2.47.0.windows.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/kunpeng_compute/hadoop.git
git@gitee.com:kunpeng_compute/hadoop.git
kunpeng_compute
hadoop
hadoop
hdfs-ec-24.0.0

搜索帮助