使用Distcp java API时的NoSuchMethodError

时间:2016-12-15 04:52:59

标签: java hadoop distcp

我正在尝试使用Distcp Java API将数据从一个hadoop集群复制到另一个集群。

但是我得到以下例外:

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.hadoop.util.StringUtils.toLowerCase(Ljava/lang/String;)Ljava/lang/String;
at org.apache.hadoop.tools.util.DistCpUtils.getStrategy(DistCpUtils.java:126)
at org.apache.hadoop.tools.DistCp.createJob(DistCp.java:235)
at org.apache.hadoop.tools.DistCp.createAndSubmitJob(DistCp.java:174)
at org.apache.hadoop.tools.DistCp.execute(DistCp.java:153)
at com.monitor.BackupUtil.doBackup(BackupUtil.java:72)
at com.monitor.BackupUtil.main(BackupUtil.java:45)

我使用以下代码:

    public void doBackup() throws Exception {

    System.out.println("Beginning Distcp");
    DistCpOptions options = new DistCpOptions(
            new Path(prop.getProperty("sourceClusterDirectory") + "/" + prop.getProperty("tablename")
                    + "/distcp.txt"),
            new Path(prop.getProperty("targetCluster") + prop.getProperty("targetClusterDirectory")));

    System.out.println("Disctp between--->" + prop.getProperty("sourceClusterDirectory")+ "/distcp.txt" + "AND" + prop.getProperty("targetCluster")
            + prop.getProperty("targetClusterDirectory"));
    DistCp distcp = new DistCp(new Configuration(), options);
    Job job = distcp.execute();

    job.waitForCompletion(true);

    System.out.println("DistCp Completed Successfully");


}

我使用的是hadoop 2.7.1,而distcp依赖是这样的:

<dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-distcp</artifactId>
        <version>2.7.1</version>
</dependency>

0 个答案:

没有答案