use of org.apache.hadoop.tools.DistCpOptions in project hadoop by apache.
the class TestOptionsParser method testCopyStrategy.
@Test
public void testCopyStrategy() {
DistCpOptions options = OptionsParser.parse(new String[] { "-strategy", "dynamic", "-f", "hdfs://localhost:9820/source/first", "hdfs://localhost:9820/target/" });
Assert.assertEquals(options.getCopyStrategy(), "dynamic");
options = OptionsParser.parse(new String[] { "-f", "hdfs://localhost:9820/source/first", "hdfs://localhost:9820/target/" });
Assert.assertEquals(options.getCopyStrategy(), DistCpConstants.UNIFORMSIZE);
}
use of org.apache.hadoop.tools.DistCpOptions in project hadoop by apache.
the class TestOptionsParser method testParseBlokcing.
@Test
public void testParseBlokcing() {
DistCpOptions options = OptionsParser.parse(new String[] { "hdfs://localhost:9820/source/first", "hdfs://localhost:9820/target/" });
Assert.assertTrue(options.shouldBlock());
options = OptionsParser.parse(new String[] { "-async", "hdfs://localhost:9820/source/first", "hdfs://localhost:9820/target/" });
Assert.assertFalse(options.shouldBlock());
}
use of org.apache.hadoop.tools.DistCpOptions in project hadoop by apache.
the class TestOptionsParser method testOptionsAppendToConfDoesntOverwriteBandwidth.
@Test
public void testOptionsAppendToConfDoesntOverwriteBandwidth() {
Configuration conf = new Configuration();
Assert.assertEquals(conf.getRaw(DistCpOptionSwitch.BANDWIDTH.getConfigLabel()), null);
DistCpOptions options = OptionsParser.parse(new String[] { "hdfs://localhost:8020/source/first", "hdfs://localhost:8020/target/" });
options.appendToConf(conf);
Assert.assertEquals(conf.getFloat(DistCpOptionSwitch.BANDWIDTH.getConfigLabel(), -1), -1.0, DELTA);
conf = new Configuration();
Assert.assertEquals(conf.getRaw(DistCpOptionSwitch.BANDWIDTH.getConfigLabel()), null);
options = OptionsParser.parse(new String[] { "-update", "-delete", "-pu", "-bandwidth", "77", "hdfs://localhost:8020/source/first", "hdfs://localhost:8020/target/" });
options.appendToConf(conf);
Assert.assertEquals(conf.getFloat(DistCpOptionSwitch.BANDWIDTH.getConfigLabel(), -1), 77.0, DELTA);
conf = new Configuration();
conf.set(DistCpOptionSwitch.BANDWIDTH.getConfigLabel(), "88");
Assert.assertEquals(conf.getRaw(DistCpOptionSwitch.BANDWIDTH.getConfigLabel()), "88");
options = OptionsParser.parse(new String[] { "hdfs://localhost:8020/source/first", "hdfs://localhost:8020/target/" });
options.appendToConf(conf);
Assert.assertEquals(conf.getFloat(DistCpOptionSwitch.BANDWIDTH.getConfigLabel(), -1), 88.0, DELTA);
conf = new Configuration();
conf.set(DistCpOptionSwitch.BANDWIDTH.getConfigLabel(), "88.0");
Assert.assertEquals(conf.getRaw(DistCpOptionSwitch.BANDWIDTH.getConfigLabel()), "88.0");
options = OptionsParser.parse(new String[] { "-bandwidth", "99", "hdfs://localhost:8020/source/first", "hdfs://localhost:8020/target/" });
options.appendToConf(conf);
Assert.assertEquals(conf.getFloat(DistCpOptionSwitch.BANDWIDTH.getConfigLabel(), -1), 99.0, DELTA);
}
use of org.apache.hadoop.tools.DistCpOptions in project hadoop by apache.
the class TestOptionsParser method testParseIgnoreFailure.
@Test
public void testParseIgnoreFailure() {
DistCpOptions options = OptionsParser.parse(new String[] { "hdfs://localhost:9820/source/first", "hdfs://localhost:9820/target/" });
Assert.assertFalse(options.shouldIgnoreFailures());
options = OptionsParser.parse(new String[] { "-i", "hdfs://localhost:9820/source/first", "hdfs://localhost:9820/target/" });
Assert.assertTrue(options.shouldIgnoreFailures());
}
use of org.apache.hadoop.tools.DistCpOptions in project hadoop by apache.
the class TestOptionsParser method testParseMaps.
@Test
public void testParseMaps() {
DistCpOptions options = OptionsParser.parse(new String[] { "hdfs://localhost:9820/source/first", "hdfs://localhost:9820/target/" });
Assert.assertEquals(options.getMaxMaps(), DistCpConstants.DEFAULT_MAPS);
options = OptionsParser.parse(new String[] { "-m", "1", "hdfs://localhost:9820/source/first", "hdfs://localhost:9820/target/" });
Assert.assertEquals(options.getMaxMaps(), 1);
options = OptionsParser.parse(new String[] { "-m", "0", "hdfs://localhost:9820/source/first", "hdfs://localhost:9820/target/" });
Assert.assertEquals(options.getMaxMaps(), 1);
try {
OptionsParser.parse(new String[] { "-m", "hello", "hdfs://localhost:9820/source/first", "hdfs://localhost:9820/target/" });
Assert.fail("Non numberic map parsed");
} catch (IllegalArgumentException ignore) {
}
try {
OptionsParser.parse(new String[] { "-mapredXslConf", "hdfs://localhost:9820/source/first", "hdfs://localhost:9820/target/" });
Assert.fail("Non numberic map parsed");
} catch (IllegalArgumentException ignore) {
}
}
Aggregations