2017-08-08 123 views
0

我正在研究Java代碼到SFTP文件以遠離HDFS文件系統。它適用於小於200 MB的文件。對於大文件,我收到以下錯誤。SFTP Mule客戶端Java API - 用戶登錄超時問題

 17/08/08 02:44:49 ERROR sftp.SftpClient: Error writing data over SFTP service, error was: Failure 
4: Failure 
    at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2289) 
    at com.jcraft.jsch.ChannelSftp.checkStatus(ChannelSftp.java:1937) 
    at com.jcraft.jsch.ChannelSftp._put(ChannelSftp.java:541) 
    at com.jcraft.jsch.ChannelSftp.put(ChannelSftp.java:439) 
    at com.jcraft.jsch.ChannelSftp.put(ChannelSftp.java:406) 

我的代碼如下:

  public static void sendFile(String targetDirectory, String sourceFileWithFullPath) throws IOException { 
    SftpClient client = new SftpClient("karthick"); 
    BufferedInputStream bis = null; 
    Configuration conf = new Configuration(); 
    FileSystem fs = FileSystem.get(conf); 
    FSDataInputStream fsdisPath = null; 
    String filePath = null; 
    try { 

     filePath=sourceFileWithFullPath; 
     Path inputPath = new Path(filePath); 
     fsdisPath = fs.open(inputPath); 
     bis = new BufferedInputStream(fsdisPath); 
     client.login("karthick","/karthick/id_rsa", null); 
     client.changeWorkingDirectory(targetDirectory); 
     client.storeFile(inputPath.getName(), bis); 
     System.out.println("The actual path is" + client.getAbsolutePath(sourceFileWithFullPath)); 

    } 
    finally { 
     if (client != null) { 
      client.disconnect(); 
     } 
     if (bis != null) { 
      bis.close(); 
     } 
    } 
} 

我確保我有足夠的磁盤空間,無記憶問題以及所有必需的權限。什麼可能是其他可能的方法來避免這個問題。我打算有這個實用程序來複制500GB文件。我現在開始學Java並學習基礎知識。任何建議將不勝感激。

更新:我收到此錯誤以及com.jcraft.jsch.JSchException:驗證:錯誤。我已經在必要時添加了鑰匙。我該如何解決這個問題

ERROR sftp.SftpClient: Error during login to [email protected] 
    com.jcraft.jsch.JSchException: verify: false 
    at com.jcraft.jsch.Session.connect(Session.java:295) 
    at com.jcraft.jsch.Session.connect(Session.java:150) 
    at org.mule.transport.sftp.SftpClient.login(SftpClient.java:178) 

回答

1

它看起來像4個原因:
1)你寫
2)文件路徑(或名稱)在空間上的文件夾的權限。
3)文件路徑中有斜槓。同時讀取或寫入大文件
4)超時問題發生..

+0

我也去它..如何處理第四選項... – Karthi

+0

我歌廳用戶超時會話,因爲我已經更新了我的問題的內容和我如何解決它。 – Karthi

+0

請檢查jsch 0.1.50修復了這個問題。 jsch下載頁面 - http://www.jcraft.com/jsch/ – siranjeevi