Search in sources :

Example 26 with DistCpOptions

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);
}
Also used : DistCpOptions(org.apache.hadoop.tools.DistCpOptions) Test(org.junit.Test)

Example 27 with DistCpOptions

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());
}
Also used : DistCpOptions(org.apache.hadoop.tools.DistCpOptions) Test(org.junit.Test)

Example 28 with DistCpOptions

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);
}
Also used : DistCpOptions(org.apache.hadoop.tools.DistCpOptions) Configuration(org.apache.hadoop.conf.Configuration) Test(org.junit.Test)

Example 29 with DistCpOptions

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());
}
Also used : DistCpOptions(org.apache.hadoop.tools.DistCpOptions) Test(org.junit.Test)

Example 30 with DistCpOptions

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) {
    }
}
Also used : DistCpOptions(org.apache.hadoop.tools.DistCpOptions) Test(org.junit.Test)

Aggregations

DistCpOptions (org.apache.hadoop.tools.DistCpOptions)34 Test (org.junit.Test)22 Path (org.apache.hadoop.fs.Path)13 Configuration (org.apache.hadoop.conf.Configuration)10 IOException (java.io.IOException)6 FileSystem (org.apache.hadoop.fs.FileSystem)5 JobContextImpl (org.apache.hadoop.mapreduce.task.JobContextImpl)5 CopyListing (org.apache.hadoop.tools.CopyListing)4 DistCp (org.apache.hadoop.tools.DistCp)4 GlobbedCopyListing (org.apache.hadoop.tools.GlobbedCopyListing)4 FileNotFoundException (java.io.FileNotFoundException)3 ArrayList (java.util.ArrayList)3 Text (org.apache.hadoop.io.Text)3 CopyListingFileStatus (org.apache.hadoop.tools.CopyListingFileStatus)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 MalformedURLException (java.net.MalformedURLException)2 AccessControlException (java.security.AccessControlException)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 StubContext (org.apache.hadoop.tools.StubContext)2 NoSuchElementException (java.util.NoSuchElementException)1