2016-07-19 38 views
0

FTPClientの1つのスレッドで最大ダウンロード速度はどのくらいですか?FTPClient Javaの高速化ダウンロード

FPTSClient接続(AUTH SSL)で約6MB /秒を超えることはできません。 FTPラッシュのようなFtpツールを使用して接続すると、150Mb/s以上を取得できます! 6.97で

1,000.0Mバイト(S)(150,376.60 kbpsの)

私はすでに* 10 * 1024 1024 * 1024 1024の間ftpBufferSizeを高めるためにしようとしましたが、何も変わっていません。

これは私がFTPに接続するだけの小さな断片です:

 ftp.setConnectTimeout(8000); 
     ftp.setDefaultPort(this.port); 
     try { 
      ftp.connect(this.host); 
     } catch (Exception e) { 
      LogController.logMessage("Connect::tryConnect -> Exception: "+e.getMessage()); 
      LogController.logMessage(e); 
     } 

     if(ftp.isConnected()) { 

      if(this.ssl) { 
       ((FTPSClient) ftp).execPBSZ(0); 
      } 

      LogController.logMessage("Connect::tryConnect -> Open new connection."); 
      if(!ftp.login(this.username, this.password)) { 
       LogController.logMessage("Connect::tryConnect -> "+getReplyString()); 
       ftp.logout(); 
      } else { 
       LogController.logMessage("Connect::tryConnect -> User login correct."); 
       if(this.ssl) { 
        ((FTPSClient) ftp).execPROT("P"); 
        LogController.logMessage("Connect::tryConnect -> "+getReplyString()); 
       } 

       if(ftp.getSystemType().toLowerCase().contains("win") == false) 
        ftp.configure(new FTPClientConfig(FTPClientConfig.SYST_UNIX)); 


       int reply = ftp.getReplyCode(); 
       if (!FTPReply.isPositiveCompletion(reply)) { 
        ftp.disconnect(); 
        LogController.logMessage(getReplyString()); 
       } else { 

        ftp.enterLocalPassiveMode(); 
        ftp.setBufferSize(10485760); 
        ftp.setRemoteVerificationEnabled(false); 
        ftp.setListHiddenFiles(true); 

そしてここでは、最終的なダウンロードスニペットです:

 if (download) {     
      OutputStream output; 
      output = new FileOutputStream(tmpPath); 

      if(!ftp.setFileType(FTP.BINARY_FILE_TYPE)) 
       LogController.logMessage("Connect::downloadFiles -> Could'nt set binary file type."); 

      DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); 
      Date d = new Date(); 
      String date = dateFormat.format(d); 
      LogController.logMessage("Connect::downloadFiles -> Start downloading "+file+", "+date+", Buffersize: "+ftp.getBufferSize()); 

      if(!ftp.retrieveFile(ftpFilePath, output)) { 
       LogController.logMessage("Connect::downloadFiles -> Could'nt download the file: "+file); 
       output.close(); 
       return false; 
      } else { 
       output.close(); 
       d = new Date(); 
       date = dateFormat.format(d); 
       LogController.logMessage("Connect::downloadFiles -> Download finished. "+date); 
       return true; 
      } 
     } 

私が100MB程度の大容量ファイルを転送する必要があります。ダウンロードをスピードアップする方法はありますか? ありがとうございました。

+0

インターフェイス 'OutputStream'の代わりに' BufferedOutputStream'を使用してください。 –

+0

'OutputStream output;'を 'BufferedOutputStream output = new BufferedOutputStream(new FileOutputStream(tmpPath));に変更すると、 48MBファイル。だから、これはほぼ6MB/s程度です。変化はありません。 – pnk

答えて

0

最後に解決策を得ました。 この行を削除した後:

((FTPSClient) ftp).execPROT("P"); 

100Mbpsの+に到達しても問題ありませんでした。このラインでは、6-7MBpsより高いレートを得る方法はありませんでした。