Package org.apache.sshd.sftp.client.impl
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 Summary
FieldsModifier and TypeFieldDescriptionprotected final byte[]protected org.apache.sshd.common.util.buffer.Bufferprotected booleanprotected intprotected longprotected booleanprotected final longprotected SftpClient.CloseableHandleprotected final org.slf4j.Loggerprotected intprotected final Deque<SftpAckData> protected longprotected long -
Constructor Summary
ConstructorsConstructorDescriptionSftpInputStreamAsync(AbstractSftpClient client, int bufferSize, long clientOffset, long fileSize, String path, SftpClient.CloseableHandle handle) SftpInputStreamAsync(AbstractSftpClient client, int bufferSize, long clientOffset, long fileSize, String path, SftpClient.CloseableHandle handle, boolean closeHandle) SftpInputStreamAsync(AbstractSftpClient client, int bufferSize, String path, Collection<SftpClient.OpenMode> mode) -
Method Summary
Modifier and TypeMethodDescriptionprotected intadjustBufferIfNeeded(int currentBufferSize, long nOfShortReads, int maxBufferReceived, long gap) Dynamically adjust the SFTP buffer size, if it is too large.voidclose()protected booleanfillData()final AbstractSftpClientfinal StringgetPath()The remotely accessed file pathprotected booleanbooleanisEof()Check if the stream is at EOFbooleanisOpen()protected voidpollBuffer(SftpAckData ack) intread()intread(byte[] b, int off, int len) protected voidlongskip(long n) toString()longtransferTo(long len, WritableByteChannel out) longtransferTo(OutputStream out) Methods inherited from class java.io.InputStream
available, mark, markSupported, read, reset
-
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
-
requestOffset
protected long requestOffset -
clientOffset
protected long clientOffset -
pendingReads
-
eofIndicator
protected boolean eofIndicator -
bufferSize
protected int bufferSize -
maxReceived
protected int maxReceived -
shortReads
protected long shortReads -
bufferAdjusted
protected boolean bufferAdjusted
-
-
Constructor Details
-
SftpInputStreamAsync
public SftpInputStreamAsync(AbstractSftpClient client, int bufferSize, String path, Collection<SftpClient.OpenMode> mode) throws IOException - Throws:
IOException
-
SftpInputStreamAsync
public SftpInputStreamAsync(AbstractSftpClient client, int bufferSize, long clientOffset, long fileSize, String path, SftpClient.CloseableHandle handle) -
SftpInputStreamAsync
public SftpInputStreamAsync(AbstractSftpClient client, int bufferSize, long clientOffset, long fileSize, String path, SftpClient.CloseableHandle handle, boolean closeHandle)
-
-
Method Details
-
getClient
- Specified by:
getClientin interfaceSftpClientHolder
-
getPath
The remotely accessed file path- Returns:
- Remote file path
-
isEof
public boolean isEof()Check if the stream is at EOF- Returns:
trueif all the data has been consumer
-
isOpen
public boolean isOpen() -
read
- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
transferTo
- Throws:
IOException
-
transferTo
- Throws:
IOException
-
skip
- Overrides:
skipin classInputStream- Throws:
IOException
-
hasNoData
protected boolean hasNoData() -
sendRequests
- Throws:
IOException
-
fillData
- 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 sizenOfShortReads- the number of short reads so farmaxBufferReceived- the maximum number of bytes the server returned in any previous read requestgap- the size of the gap just filled- Returns:
- a new buffer size in the range [1..currentBufferSize].
-
pollBuffer
- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceChannel- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
toString
-