2017-10-14 1 views
0

ftp 서버에서 hdfs로 파일을 전송하고 싶습니다. 나는이 방법을 시도 : 그것은 아무것도 표시되지 않습니다,Hadoop FTPFileSystem.listStatus (경로 경로)가 작동하지 않는 이유는 무엇입니까?

Configuration conf = new Configuration(); 
    FTPFileSystem ftpfs = new FTPFileSystem(); 
    ftpfs.setConf(conf); 
    ftpfs.initialize(new URI(ftpConnectStr), conf); 

    Path homeDirectory = ftpfs.getHomeDirectory(); 
    System.out.println(homeDirectory.toString()); 

    FileStatus[] fileStatuses = ftpfs.listStatus(new Path("/")); 
    for(FileStatus fileStatus : fileStatuses){ 
     System.out.println(fileStatuses.length); 
     System.out.println(fileStatus.toString()); 
    } 

    boolean test = ftpfs.mkdirs(new Path("test")); 
    System.out.println(test); 

ftpfs.listStatus(new Path("/"))이 작동하지 않지만, FTP 서버는 두 개의 디렉토리와 ftpfs.mkdirs(new Path("test")) 잘 작동, 다음과 같은 결과를 실행하는 프로그램이 있습니다 FTP TO HDFS를, 데모 코드는 다음과 같습니다 :

enter image description here

및 FTP 서버 dirctory는 다음과 같이

enter image description here

,

Google에서 검색했지만 정보가 조금 있습니다. 나는 이유를 모른다. 당신이 나를 도울 수 있다면, 나는 매우 감사 할 것입니다, 감사합니다

+1

@MartinPrikryl https://hadoop.apache.org/docs/r2.4.1/api/org/apache/hadoop/fs/ftp/FTPFileSystem.html#listStatus(org.apache.hadoop.fs. 경로) – Smittey

+0

Hadoop 로그 파일을 보여줄 수 있습니까? –

+0

ftp 폴더의 파일에 대한 파일 사용 권한은 무엇입니까? 소프트웨어를 실행하는 프로세스에서 볼 수 있습니까? 올바른 권한을 가지고 있습니까? chmod 777 또는 확인할 내용이있는 더미 파일을 넣어 빠른 테스트를하십시오. – Smittey

답변

0

마지막으로, 나는 그것이 어디에 문제인지를 발견했습니다. FTP 서버에서 데이터 전송 모드는 수동으로 설정됩니다.

enter image description here

은 그 때 나는 FTPFileSystem의 소스 코드를 디버그하는, 그리고 난 그것이 FTP 수동 모드를 설정하지 않은 것을 발견;

enter image description here

다시 실행 프로그램 :

enter image description here

그래서,이에 FTPFileSystem의 관련 코드를 수정

enter image description here

을하고 그것을 잘 작동합니다 :

enter image description here

관련 문제