Skip to content

HADOOP-19541. Make HadoopArchives support human-friendly units about blocksize and partsize. #7611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,8 @@ void archive(Path parentPath, List<Path> srcPaths,
int numFiles = 0;
long totalSize = 0;
FileSystem fs = parentPath.getFileSystem(conf);
this.blockSize = conf.getLong(HAR_BLOCKSIZE_LABEL, blockSize);
this.partSize = conf.getLong(HAR_PARTSIZE_LABEL, partSize);
this.blockSize = conf.getLongBytes(HAR_BLOCKSIZE_LABEL, blockSize);
this.partSize = conf.getLongBytes(HAR_PARTSIZE_LABEL, partSize);
conf.setLong(HAR_BLOCKSIZE_LABEL, blockSize);
conf.setLong(HAR_PARTSIZE_LABEL, partSize);
conf.set(DST_HAR_LABEL, archiveName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -804,5 +804,31 @@ public void testCopyToLocal() throws Exception {
localFs.delete(tmpPath, true);
}
}


@Test
public void testBlockSize() throws Exception {
conf.set(HadoopArchives.HAR_BLOCKSIZE_LABEL, "1m");

final String inputPathStr = inputPath.toUri().getPath();
System.out.println("inputPathStr = " + inputPathStr);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove it?

Copy link
Contributor Author

@fuchaohong fuchaohong Apr 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pan3793 Thank you for your review. I have already removed it, please help review it again.


final String harName = "foo.har";
final String[] args =
{ "-archiveName", harName, "-p", inputPathStr, "*",
archivePath.toString() };
System.setProperty(HadoopArchives.TEST_HADOOP_ARCHIVES_JAR_PATH,
HADOOP_ARCHIVES_JAR);
final HadoopArchives har = new HadoopArchives(conf);
assertEquals(0, ToolRunner.run(har, args));

RemoteIterator<LocatedFileStatus> listFiles =
fs.listFiles(new Path(archivePath.toString() + "/" + harName), false);
while (listFiles.hasNext()) {
LocatedFileStatus next = listFiles.next();
if (next.getPath().toString().matches(".*/part-\\d+$")) {
// compare blockSize
Assert.assertEquals(1 * 1024 * 1024, next.getBlockSize());
}
}
}
}