Class SftpInputStreamAsync

java.lang.Object
java.io.InputStream
org.apache.sshd.common.util.io.input.InputStreamWithChannel
org.apache.sshd.sftp.client.impl.SftpInputStreamAsync
All Implemented Interfaces:
Closeable, AutoCloseable, Channel, SftpClientHolder

public class SftpInputStreamAsync extends org.apache.sshd.common.util.io.input.InputStreamWithChannel implements SftpClientHolder
  • Field Details

    • log

      protected final org.slf4j.Logger log
    • bb

      protected final byte[] bb
    • fileSize

      protected final long fileSize
    • buffer

      protected org.apache.sshd.common.util.buffer.Buffer buffer
    • handle

      protected SftpClient.CloseableHandle handle
    • requestOffset

      protected long requestOffset
    • clientOffset

      protected long clientOffset
    • pendingReads

      protected final Deque<SftpAckData> pendingReads
    • eofIndicator

      protected boolean eofIndicator
    • bufferSize

      protected int bufferSize
    • maxReceived

      protected int maxReceived
    • shortReads

      protected long shortReads
    • bufferAdjusted

      protected boolean bufferAdjusted
  • Constructor Details

  • Method Details

    • getClient

      public final AbstractSftpClient getClient()
      Specified by:
      getClient in interface SftpClientHolder
    • getPath

      public final String getPath()
      The remotely accessed file path
      Returns:
      Remote file path
    • isEof

      public boolean isEof()
      Check if the stream is at EOF
      Returns:
      true if all the data has been consumer
    • isOpen

      public boolean isOpen()
      Specified by:
      isOpen in interface Channel
    • read

      public int read() throws IOException
      Specified by:
      read in class InputStream
      Throws:
      IOException
    • read

      public int read(byte[] b, int off, int len) throws IOException
      Overrides:
      read in class InputStream
      Throws:
      IOException
    • transferTo

      public long transferTo(long len, WritableByteChannel out) throws IOException
      Throws:
      IOException
    • transferTo

      public long transferTo(OutputStream out) throws IOException
      Throws:
      IOException
    • skip

      public long skip(long n) throws IOException
      Overrides:
      skip in class InputStream
      Throws:
      IOException
    • hasNoData

      protected boolean hasNoData()
    • sendRequests

      protected void sendRequests() throws IOException
      Throws:
      IOException
    • fillData

      protected boolean fillData() throws IOException
      Throws:
      IOException
    • adjustBufferIfNeeded

      protected int adjustBufferIfNeeded(int currentBufferSize, long nOfShortReads, int maxBufferReceived, long gap)
      Dynamically adjust the SFTP buffer size, if it is too large. Although it is possible to reduce the buffer size to a single byte, in practice some sane lower limit (like, 8kB) should be maintained.
      Parameters:
      currentBufferSize - the current SFTP buffer size
      nOfShortReads - the number of short reads so far
      maxBufferReceived - the maximum number of bytes the server returned in any previous read request
      gap - the size of the gap just filled
      Returns:
      a new buffer size in the range [1..currentBufferSize].
    • pollBuffer

      protected void pollBuffer(SftpAckData ack) throws IOException
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Channel
      Specified by:
      close in interface Closeable
      Overrides:
      close in class InputStream
      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class Object