HADOOP-16018. DistCp won't reassemble chunks when blocks per chunk > 0.

Contributed by Kai Xie.
This commit is contained in:
Kai Xie 2019-02-27 20:09:11 +00:00 committed by Steve Loughran
parent bae607f734
commit a49cb4465e
No known key found for this signature in database
GPG Key ID: D22CF846DBB162A0
3 changed files with 33 additions and 1 deletions

View File

@ -118,6 +118,10 @@ public class DistCpConstants {
public static final String CONF_LABEL_COPY_BUFFER_SIZE =
"distcp.copy.buffer.size";
/** DistCp Blocks Per Chunk: {@value}. */
public static final String CONF_LABEL_BLOCKS_PER_CHUNK =
"distcp.blocks.per.chunk";
/**
* Conf label for SSL Trust-store location.
*/

View File

@ -186,7 +186,7 @@ public enum DistCpOptionSwitch {
new Option("sizelimit", true, "(Deprecated!) Limit number of files " +
"copied to <= n bytes")),
BLOCKS_PER_CHUNK("",
BLOCKS_PER_CHUNK(DistCpConstants.CONF_LABEL_BLOCKS_PER_CHUNK,
new Option("blocksperchunk", true, "If set to a positive value, files"
+ "with more blocks than this value will be split into chunks of "
+ "<blocksperchunk> blocks to be transferred in parallel, and "

View File

@ -21,6 +21,7 @@ package org.apache.hadoop.tools;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.tools.DistCpOptions.FileAttribute;
import org.apache.hadoop.conf.Configuration;
import org.junit.Assert;
import org.junit.Test;
@ -530,4 +531,31 @@ public class TestDistCpOptions {
options.setVerboseLog(true);
Assert.assertTrue(options.shouldVerboseLog());
}
@Test
public void testAppendToConf() {
final int expectedBlocksPerChunk = 999;
final String expectedValForEmptyConfigKey = "VALUE_OF_EMPTY_CONFIG_KEY";
DistCpOptions options = new DistCpOptions(
Collections.singletonList(
new Path("hdfs://localhost:8020/source")),
new Path("hdfs://localhost:8020/target/"));
options.setBlocksPerChunk(expectedBlocksPerChunk);
Configuration config = new Configuration();
config.set("", expectedValForEmptyConfigKey);
options.appendToConf(config);
Assert.assertEquals(expectedBlocksPerChunk,
config.getInt(
DistCpOptionSwitch
.BLOCKS_PER_CHUNK
.getConfigLabel(), 0));
Assert.assertEquals(
"Some DistCpOptionSwitch's config label is empty! " +
"Pls ensure the config label is provided when apply to config, " +
"otherwise it may not be fetched properly",
expectedValForEmptyConfigKey, config.get(""));
}
}