Changeset 2574


Ignore:
Timestamp:
Aug 14, 2014, 9:41:05 AM (7 years ago)
Author:
Nicklas Nordborg
Message:

References #595: Confirm alignment

Better progress reporting during file transfer. Improved performance of file transfer by using a BufferedInputStream.

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

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/ssh/CopyFilesToBase.java

    r2512 r2574  
    22
    33import java.io.InputStream;
     4import java.io.OutputStream;
    45import java.util.Arrays;
    56
     
    910import net.schmizz.sshj.SSHClient;
    1011import net.schmizz.sshj.sftp.SFTPClient;
     12import net.sf.basedb.core.AbsoluteProgressReporter;
    1113import net.sf.basedb.core.AnyToAny;
    1214import net.sf.basedb.core.Application;
     
    1921import net.sf.basedb.core.ProgressReporter;
    2022import net.sf.basedb.core.SessionControl;
     23import net.sf.basedb.core.SimpleAbsoluteProgressReporter;
     24import net.sf.basedb.util.FileUtil;
    2125
    2226/**
     
    108112      String toPath = to.getPath().toString();
    109113      ProgressReporter progress = null;
     114      SimpleAbsoluteProgressReporter aprogress = null;
    110115      if (jobId != 0)
    111116      {
     
    127132          totalSize += ((Number)jsonFile.get("size")).longValue();
    128133        }
     134        if (progress != null)
     135        {
     136          aprogress = new SimpleAbsoluteProgressReporter(progress, totalSize);
     137        }
     138       
    129139        long copiedSoFar = 0;
    130140        int numCopiedFiles = 0;
     
    159169          {
    160170            numSkippedFiles++;
    161             if (progress != null)
    162             {
    163               progress.display((int)(100*copiedSoFar / totalSize), "Skipping " + path);
     171            if (aprogress != null)
     172            {
     173              aprogress.setAbsolute(copiedSoFar, "Skipping " + path);
    164174            }
    165175          }
     
    167177          {
    168178            numCopiedFiles++;
    169             if (progress != null)
    170             {
    171               progress.display((int)(100*copiedSoFar / totalSize), "Copying " + path);
     179            if (aprogress != null)
     180            {
     181              aprogress.setAbsolute(copiedSoFar, "Copying " + path);
    172182            }
    173183            file.setMimeTypeAuto(null, null);
     
    175185           
    176186            InputStream in = from.readFile(sftp, rootFolder+"/"+path);
     187            OutputStream out = file.getUploadStream(false);
    177188            try
    178189            {
    179               file.upload(in, false);
     190              FileUtil.copy(in, out, aprogress);
    180191            }
    181192            finally
    182193            {
    183               in.close();
     194              FileUtil.close(in);
     195              FileUtil.close(out);
    184196            }
    185197          }
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/ssh/SshHost.java

    r2563 r2574  
    11package net.sf.basedb.reggie.ssh;
    22
     3import java.io.BufferedInputStream;
    34import java.io.ByteArrayOutputStream;
    45import java.io.IOException;
     
    401402    {
    402403      RemoteFile rf = sftp.open(fromPath, EnumSet.of(OpenMode.READ));
    403       return new CloseResourceInputStream(rf.new RemoteFileInputStream(), rf);
     404      return new CloseResourceInputStream(
     405        new BufferedInputStream(rf.new RemoteFileInputStream(), 1000000),
     406        rf);
    404407    }
    405408    catch (IOException ex)
Note: See TracChangeset for help on using the changeset viewer.