Example usage for org.apache.hadoop.tools DistCpOptions getTargetPath

List of usage examples for org.apache.hadoop.tools DistCpOptions getTargetPath

Introduction

In this page you can find the example usage for org.apache.hadoop.tools DistCpOptions getTargetPath.

Prototype

public Path getTargetPath() 

Source Link

Usage

From source file:org.apache.falcon.repliation.FeedReplicatorTest.java

License:Apache License

@Test
public void testArguments() throws Exception {
    /*//from   www  .ja v a2  s .  com
     * <arg>-update</arg>
     * <arg>-blocking</arg><arg>true</arg> <arg>-maxMaps</arg><arg>20</arg>
     * <arg>-sourcePaths</arg><arg>${distcpSourcePaths}</arg>
     * <arg>-targetPath</arg><arg>${distcpTargetPaths}</arg>
     */
    FeedReplicator replicator = new FeedReplicator();
    DistCpOptions options = replicator.getDistCpOptions(new String[] { "true", "-maxMaps", "5", "-sourcePaths",
            "hdfs://localhost:8020/tmp/", "-targetPath", "hdfs://localhost1:8020/tmp/" });

    List<Path> srcPaths = new ArrayList<Path>();
    srcPaths.add(new Path("hdfs://localhost:8020/tmp/"));
    Assert.assertEquals(options.getSourcePaths(), srcPaths);
    Assert.assertEquals(options.getTargetPath(), new Path("hdfs://localhost1:8020/tmp/"));
}

From source file:org.apache.falcon.replication.FeedReplicator.java

License:Apache License

private void executePostProcessing(Configuration conf, DistCpOptions options)
        throws IOException, FalconException {
    Path targetPath = options.getTargetPath();
    FileSystem fs = HadoopClientFactory.get().createProxiedFileSystem(targetPath.toUri(), getConf());

    final String availabilityFlag = conf.get("falcon.feed.availability.flag");
    FileStatus[] files = fs.globStatus(targetPath);
    if (files != null) {
        for (FileStatus file : files) {
            fs.create(new Path(file.getPath(), availabilityFlag)).close();
            LOG.info("Created {}", new Path(file.getPath(), availabilityFlag));
        }/*from   w ww .jav a 2s.  c  o  m*/
    } else {
        // As distcp is not copying empty directories we are creating availabilityFlag file here
        fs.create(new Path(targetPath, availabilityFlag)).close();
        LOG.info("No files present in path: {}", targetPath);
    }
}

From source file:org.apache.falcon.replication.FeedReplicatorTest.java

License:Apache License

@Test
public void testIncludePath() throws Exception {
    // Set the include Path so that CustomReplicator is used and the source and targetPaths are modified.
    String includePath = defaultPath + "/test-colo";
    // creates jailed cluster in which DistCpOtions command can be tested.
    EmbeddedCluster cluster = EmbeddedCluster.newCluster("FeedReplicatorTest");

    final String[] args = { "true", "-maxMaps", "3", "-mapBandwidth", "4", "-sourcePaths", defaultPath,
            "-targetPath", defaultPath, "-falconFeedStorageType", Storage.TYPE.FILESYSTEM.name(), };

    FeedReplicator replicator = new FeedReplicator();
    CommandLine cmd = replicator.getCommand(args);
    Configuration conf = cluster.getConf();
    conf.set("falcon.include.path", includePath);
    replicator.setConf(conf);/*from w  w  w. j a v  a2s. c o m*/
    DistCpOptions options = replicator.getDistCpOptions(cmd, true);
    Assert.assertEquals(options.getTargetPath().toString(), includePath);
    Assert.assertEquals(options.getSourcePaths().get(0).toString(), includePath);
}

From source file:org.apache.falcon.replication.FeedReplicatorTest.java

License:Apache License

private void validateMandatoryArguments(DistCpOptions options, List<Path> srcPaths, boolean shouldSyncFolder) {
    Assert.assertEquals(options.getMaxMaps(), 3);
    Assert.assertEquals(options.getMapBandwidth(), 4);
    Assert.assertEquals(options.getSourcePaths(), srcPaths);
    Assert.assertEquals(options.getTargetPath(), new Path(defaultPath));
    Assert.assertEquals(options.shouldSyncFolder(), shouldSyncFolder);
}

From source file:org.apache.ivory.repliation.FeedReplicatorTest.java

License:Apache License

@Test
public void testArguments() throws Exception {
    /*//  w  w w . j  av  a 2 s  . c om
     * <arg>-update</arg>
     * <arg>-blocking</arg><arg>true</arg> <arg>-maxMaps</arg><arg>20</arg>
     * <arg>-sourcePaths</arg><arg>${distcpSourcePaths}</arg>
     * <arg>-targetPath</arg><arg>${distcpTargetPaths}</arg>
     */
    FeedReplicator replicator = new FeedReplicator();
    DistCpOptions options = replicator
            .getDistCpOptions(new String[] { "-update", "-blocking", "true", "-maxMaps", "5", "-sourcePaths",
                    "hdfs://localhost:8020/tmp/", "-targetPath", "hdfs://localhost1:8020/tmp/" });

    List<Path> srcPaths = new ArrayList<Path>();
    srcPaths.add(new Path("hdfs://localhost:8020/tmp/"));
    Assert.assertEquals(options.getSourcePaths(), srcPaths);
    Assert.assertEquals(options.getTargetPath(), new Path("hdfs://localhost1:8020/tmp/"));
}