public class SftpRemotePathChannel
extends java.nio.channels.FileChannel
| Modifier and Type | Field and Description |
|---|---|
protected java.util.concurrent.atomic.AtomicReference<java.lang.Thread> |
blockingThreadHolder |
protected boolean |
closeOnExit |
static java.lang.String |
COPY_BUFSIZE_PROP
Internal allocate buffer size when copying data to/from the channel
|
static int |
DEFAULT_TRANSFER_BUFFER_SIZE
Default value for "sftp-channel-copy-buf-size" setting
|
protected SftpClient.CloseableHandle |
handle |
protected java.lang.Object |
lock |
protected org.slf4j.Logger |
log |
protected java.util.Collection<SftpClient.OpenMode> |
modes |
private java.lang.String |
path |
protected java.util.concurrent.atomic.AtomicLong |
posTracker |
static java.util.Set<SftpClient.OpenMode> |
READ_MODES |
protected SftpClient |
sftp |
static java.util.Set<SftpClient.OpenMode> |
WRITE_MODES |
| Constructor and Description |
|---|
SftpRemotePathChannel(java.lang.String path,
SftpClient sftp,
boolean closeOnExit,
java.util.Collection<SftpClient.OpenMode> modes) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
beginBlocking(java.lang.Object actionHint) |
protected long |
doRead(java.util.Collection<? extends java.nio.ByteBuffer> buffers,
long position) |
protected long |
doWrite(java.util.Collection<? extends java.nio.ByteBuffer> buffers,
long position) |
protected void |
endBlocking(java.lang.Object actionHint,
boolean completed) |
private void |
ensureOpen(java.util.Collection<SftpClient.OpenMode> reqModes)
Checks that the channel is open and that its current mode contains at least one of the required ones
|
void |
force(boolean metaData) |
java.lang.String |
getRemotePath() |
protected void |
implCloseChannel() |
java.nio.channels.FileLock |
lock(long position,
long size,
boolean shared) |
java.nio.MappedByteBuffer |
map(java.nio.channels.FileChannel.MapMode mode,
long position,
long size) |
long |
position() |
java.nio.channels.FileChannel |
position(long newPosition) |
int |
read(java.nio.ByteBuffer dst) |
long |
read(java.nio.ByteBuffer[] dsts,
int offset,
int length) |
int |
read(java.nio.ByteBuffer dst,
long position) |
long |
size() |
java.lang.String |
toString() |
long |
transferFrom(java.nio.channels.ReadableByteChannel src,
long position,
long count) |
long |
transferTo(long position,
long count,
java.nio.channels.WritableByteChannel target) |
java.nio.channels.FileChannel |
truncate(long size) |
java.nio.channels.FileLock |
tryLock(long position,
long size,
boolean shared) |
int |
write(java.nio.ByteBuffer src) |
long |
write(java.nio.ByteBuffer[] srcs,
int offset,
int length) |
int |
write(java.nio.ByteBuffer src,
long position) |
begin, close, end, isOpenpublic static final java.lang.String COPY_BUFSIZE_PROP
public static final int DEFAULT_TRANSFER_BUFFER_SIZE
public static final java.util.Set<SftpClient.OpenMode> READ_MODES
public static final java.util.Set<SftpClient.OpenMode> WRITE_MODES
protected final org.slf4j.Logger log
protected final java.util.Collection<SftpClient.OpenMode> modes
protected final boolean closeOnExit
protected final SftpClient sftp
protected final SftpClient.CloseableHandle handle
protected final java.lang.Object lock
protected final java.util.concurrent.atomic.AtomicLong posTracker
protected final java.util.concurrent.atomic.AtomicReference<java.lang.Thread> blockingThreadHolder
private final java.lang.String path
public SftpRemotePathChannel(java.lang.String path,
SftpClient sftp,
boolean closeOnExit,
java.util.Collection<SftpClient.OpenMode> modes)
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getRemotePath()
public int read(java.nio.ByteBuffer dst)
throws java.io.IOException
read in interface java.nio.channels.ReadableByteChannelread in interface java.nio.channels.SeekableByteChannelread in class java.nio.channels.FileChanneljava.io.IOExceptionpublic int read(java.nio.ByteBuffer dst,
long position)
throws java.io.IOException
read in class java.nio.channels.FileChanneljava.io.IOExceptionpublic long read(java.nio.ByteBuffer[] dsts,
int offset,
int length)
throws java.io.IOException
read in interface java.nio.channels.ScatteringByteChannelread in class java.nio.channels.FileChanneljava.io.IOExceptionprotected long doRead(java.util.Collection<? extends java.nio.ByteBuffer> buffers,
long position)
throws java.io.IOException
java.io.IOExceptionpublic int write(java.nio.ByteBuffer src)
throws java.io.IOException
write in interface java.nio.channels.SeekableByteChannelwrite in interface java.nio.channels.WritableByteChannelwrite in class java.nio.channels.FileChanneljava.io.IOExceptionpublic int write(java.nio.ByteBuffer src,
long position)
throws java.io.IOException
write in class java.nio.channels.FileChanneljava.io.IOExceptionpublic long write(java.nio.ByteBuffer[] srcs,
int offset,
int length)
throws java.io.IOException
write in interface java.nio.channels.GatheringByteChannelwrite in class java.nio.channels.FileChanneljava.io.IOExceptionprotected long doWrite(java.util.Collection<? extends java.nio.ByteBuffer> buffers,
long position)
throws java.io.IOException
java.io.IOExceptionpublic long position()
throws java.io.IOException
position in interface java.nio.channels.SeekableByteChannelposition in class java.nio.channels.FileChanneljava.io.IOExceptionpublic java.nio.channels.FileChannel position(long newPosition)
throws java.io.IOException
position in interface java.nio.channels.SeekableByteChannelposition in class java.nio.channels.FileChanneljava.io.IOExceptionpublic long size()
throws java.io.IOException
size in interface java.nio.channels.SeekableByteChannelsize in class java.nio.channels.FileChanneljava.io.IOExceptionpublic java.nio.channels.FileChannel truncate(long size)
throws java.io.IOException
truncate in interface java.nio.channels.SeekableByteChanneltruncate in class java.nio.channels.FileChanneljava.io.IOExceptionpublic void force(boolean metaData)
throws java.io.IOException
force in class java.nio.channels.FileChanneljava.io.IOExceptionpublic long transferTo(long position,
long count,
java.nio.channels.WritableByteChannel target)
throws java.io.IOException
transferTo in class java.nio.channels.FileChanneljava.io.IOExceptionpublic long transferFrom(java.nio.channels.ReadableByteChannel src,
long position,
long count)
throws java.io.IOException
transferFrom in class java.nio.channels.FileChanneljava.io.IOExceptionpublic java.nio.MappedByteBuffer map(java.nio.channels.FileChannel.MapMode mode,
long position,
long size)
throws java.io.IOException
map in class java.nio.channels.FileChanneljava.io.IOExceptionpublic java.nio.channels.FileLock lock(long position,
long size,
boolean shared)
throws java.io.IOException
lock in class java.nio.channels.FileChanneljava.io.IOExceptionpublic java.nio.channels.FileLock tryLock(long position,
long size,
boolean shared)
throws java.io.IOException
tryLock in class java.nio.channels.FileChanneljava.io.IOExceptionprotected void implCloseChannel()
throws java.io.IOException
implCloseChannel in class java.nio.channels.spi.AbstractInterruptibleChanneljava.io.IOExceptionprotected void beginBlocking(java.lang.Object actionHint)
protected void endBlocking(java.lang.Object actionHint,
boolean completed)
throws java.nio.channels.AsynchronousCloseException
java.nio.channels.AsynchronousCloseExceptionprivate void ensureOpen(java.util.Collection<SftpClient.OpenMode> reqModes) throws java.io.IOException
reqModes - The required modes - ignored if null/emptyjava.io.IOException - If channel not open or the required modes are not satisfiedpublic java.lang.String toString()
toString in class java.lang.Object