Changeset 2520


Ignore:
Timestamp:
Jun 25, 2014, 8:45:56 AM (9 years ago)
Author:
Nicklas Nordborg
Message:

References #611: Create package for supporting external files via SFTP

Wrap remote stream in a BufferedInputStream for increased performance. Without the buffer a typical download speed was 0.5MB/s. With the buffer it went up to 10MB/s.

Location:
extensions/net.sf.basedb.xfiles/trunk/src/net/sf/basedb/xfiles
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.xfiles/trunk/src/net/sf/basedb/xfiles/XFiles.java

    r2518 r2520  
    3939  */
    4040  public static final int DEFAULT_SSH_PORT = 22;
    41  
     41
     42  /**
     43    Default size of internal buffer when downloading files is 1MB.
     44  */
     45  public static final int DEFAULT_BUFFER_SIZE = 1024*1024;
    4246}
  • extensions/net.sf.basedb.xfiles/trunk/src/net/sf/basedb/xfiles/sftp/SftpConnectionManager.java

    r2519 r2520  
    2222package net.sf.basedb.xfiles.sftp;
    2323
     24import java.io.BufferedInputStream;
    2425import java.io.IOException;
    2526import java.io.InputStream;
     
    8788      sftp = ssh.newSFTPClient();
    8889      remote = sftp.open(uri.getPath(), EnumSet.of(OpenMode.READ));
    89       stream = new CloseResourceInputStream(remote.new RemoteFileInputStream(), new MultiCloseable(remote, sftp, ssh));
     90      stream = new CloseResourceInputStream(
     91        new BufferedInputStream(remote.new RemoteFileInputStream(), XFiles.DEFAULT_BUFFER_SIZE),
     92        new MultiCloseable(remote, sftp, ssh));
    9093    }
    9194    finally
Note: See TracChangeset for help on using the changeset viewer.