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, isOpen
public 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.IOException
public java.lang.String getRemotePath()
public int read(java.nio.ByteBuffer dst) throws java.io.IOException
read
in interface java.nio.channels.ReadableByteChannel
read
in interface java.nio.channels.SeekableByteChannel
read
in class java.nio.channels.FileChannel
java.io.IOException
public int read(java.nio.ByteBuffer dst, long position) throws java.io.IOException
read
in class java.nio.channels.FileChannel
java.io.IOException
public long read(java.nio.ByteBuffer[] dsts, int offset, int length) throws java.io.IOException
read
in interface java.nio.channels.ScatteringByteChannel
read
in class java.nio.channels.FileChannel
java.io.IOException
protected long doRead(java.util.Collection<? extends java.nio.ByteBuffer> buffers, long position) throws java.io.IOException
java.io.IOException
public int write(java.nio.ByteBuffer src) throws java.io.IOException
write
in interface java.nio.channels.SeekableByteChannel
write
in interface java.nio.channels.WritableByteChannel
write
in class java.nio.channels.FileChannel
java.io.IOException
public int write(java.nio.ByteBuffer src, long position) throws java.io.IOException
write
in class java.nio.channels.FileChannel
java.io.IOException
public long write(java.nio.ByteBuffer[] srcs, int offset, int length) throws java.io.IOException
write
in interface java.nio.channels.GatheringByteChannel
write
in class java.nio.channels.FileChannel
java.io.IOException
protected long doWrite(java.util.Collection<? extends java.nio.ByteBuffer> buffers, long position) throws java.io.IOException
java.io.IOException
public long position() throws java.io.IOException
position
in interface java.nio.channels.SeekableByteChannel
position
in class java.nio.channels.FileChannel
java.io.IOException
public java.nio.channels.FileChannel position(long newPosition) throws java.io.IOException
position
in interface java.nio.channels.SeekableByteChannel
position
in class java.nio.channels.FileChannel
java.io.IOException
public long size() throws java.io.IOException
size
in interface java.nio.channels.SeekableByteChannel
size
in class java.nio.channels.FileChannel
java.io.IOException
public java.nio.channels.FileChannel truncate(long size) throws java.io.IOException
truncate
in interface java.nio.channels.SeekableByteChannel
truncate
in class java.nio.channels.FileChannel
java.io.IOException
public void force(boolean metaData) throws java.io.IOException
force
in class java.nio.channels.FileChannel
java.io.IOException
public long transferTo(long position, long count, java.nio.channels.WritableByteChannel target) throws java.io.IOException
transferTo
in class java.nio.channels.FileChannel
java.io.IOException
public long transferFrom(java.nio.channels.ReadableByteChannel src, long position, long count) throws java.io.IOException
transferFrom
in class java.nio.channels.FileChannel
java.io.IOException
public java.nio.MappedByteBuffer map(java.nio.channels.FileChannel.MapMode mode, long position, long size) throws java.io.IOException
map
in class java.nio.channels.FileChannel
java.io.IOException
public java.nio.channels.FileLock lock(long position, long size, boolean shared) throws java.io.IOException
lock
in class java.nio.channels.FileChannel
java.io.IOException
public java.nio.channels.FileLock tryLock(long position, long size, boolean shared) throws java.io.IOException
tryLock
in class java.nio.channels.FileChannel
java.io.IOException
protected void implCloseChannel() throws java.io.IOException
implCloseChannel
in class java.nio.channels.spi.AbstractInterruptibleChannel
java.io.IOException
protected void beginBlocking(java.lang.Object actionHint)
protected void endBlocking(java.lang.Object actionHint, boolean completed) throws java.nio.channels.AsynchronousCloseException
java.nio.channels.AsynchronousCloseException
private 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