“尝试从Java HDFS中的CopyFromLocalFile文件中错误的FS ... expected:file:///” [英] “Wrong FS… expected: file:///” when trying to copyFromLocalFile from HDFS in Java

查看:1053
本文介绍了“尝试从Java HDFS中的CopyFromLocalFile文件中错误的FS ... expected:file:///”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将 abc.json port / example_File / 2017 复制到HDFS中的另一个位置 / port / example_File / 2018
by below code

 字符串exampleFile =hdfs://port/example_File/2017/abc.json
String targetFile =hdfs:// port / example_File / 2018
hdfs.copyFromLocalFile(new Path(exampleFile),new Path(targetFile))

我得到的是异常

  org.jboss.resteasy .spi.UnhandledException:
java.lang.IllegalArgumentException:错误的FS:
hdfs://port/example_File/2017/abc.json,预计:file:///

如何在HDFS中将文件从一个位置复制到另一个位置




解决方案> copyFromLocal 是将文件从本地文件系统复制到HDFS。

要在HDFS集群中复制文件,请使用 FileUtil.copy() 并指定相同的文件系统对于 srcFS dstFs



使用 DistCp 在HDFS群集内或两个不同的HDFS群集之间复制大量文件时。请参阅DistCp Java API 此处


I am trying to copy abc.json from port/example_File/2017 to another location /port/example_File/2018 in HDFS, by below code

String exampleFile= "hdfs://port/example_File/2017/abc.json"
String targetFile="hdfs://port/example_File/2018"
hdfs.copyFromLocalFile(new Path(exampleFile),new Path(targetFile))

I am getting below exception

    org.jboss.resteasy.spi.UnhandledException: 
java.lang.IllegalArgumentException: Wrong FS:
 hdfs://port/example_File/2017/abc.json, expected: file:///

How to copy file from one location to another in HDFS

Thanks,

解决方案

copyFromLocal is to copy files from Local Filesystem to HDFS.

To copy files within an HDFS cluster, use FileUtil.copy() and specify same Filesystem for both srcFS and dstFs.

Use DistCp when copying large number of files within a HDFS cluster or between two different HDFS clusters. Refer DistCp Java API here.

这篇关于“尝试从Java HDFS中的CopyFromLocalFile文件中错误的FS ... expected:file:///”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆