Package org.h2.store.fs.retry
Class FileRetryOnInterrupt
- java.lang.Object
-
- java.nio.channels.spi.AbstractInterruptibleChannel
-
- java.nio.channels.FileChannel
-
- org.h2.store.fs.FileBase
-
- org.h2.store.fs.retry.FileRetryOnInterrupt
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.nio.channels.ByteChannel
,java.nio.channels.Channel
,java.nio.channels.GatheringByteChannel
,java.nio.channels.InterruptibleChannel
,java.nio.channels.ReadableByteChannel
,java.nio.channels.ScatteringByteChannel
,java.nio.channels.SeekableByteChannel
,java.nio.channels.WritableByteChannel
class FileRetryOnInterrupt extends FileBase
A file object that re-opens and re-tries the operation if the file was closed.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
FileRetryOnInterrupt.FileLockRetry
A wrapped file lock.
-
Field Summary
Fields Modifier and Type Field Description private java.nio.channels.FileChannel
channel
private java.lang.String
fileName
private FileRetryOnInterrupt.FileLockRetry
lock
private java.lang.String
mode
-
Constructor Summary
Constructors Constructor Description FileRetryOnInterrupt(java.lang.String fileName, java.lang.String mode)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
force(boolean metaData)
void
implCloseChannel()
private void
open()
long
position()
java.nio.channels.FileChannel
position(long pos)
int
read(java.nio.ByteBuffer dst)
int
read(java.nio.ByteBuffer dst, long position)
private void
reLock()
private void
reopen(int i, java.io.IOException e)
long
size()
java.lang.String
toString()
java.nio.channels.FileChannel
truncate(long newLength)
java.nio.channels.FileLock
tryLock(long position, long size, boolean shared)
int
write(java.nio.ByteBuffer src)
int
write(java.nio.ByteBuffer src, long position)
-
Methods inherited from class org.h2.store.fs.FileBase
lock, map, read, transferFrom, transferTo, write
-
Methods inherited from class java.nio.channels.spi.AbstractInterruptibleChannel
begin, close, end, isOpen
-
-
-
-
Field Detail
-
fileName
private final java.lang.String fileName
-
mode
private final java.lang.String mode
-
channel
private java.nio.channels.FileChannel channel
-
lock
private FileRetryOnInterrupt.FileLockRetry lock
-
-
Method Detail
-
open
private void open() throws java.io.IOException
- Throws:
java.io.IOException
-
reopen
private void reopen(int i, java.io.IOException e) throws java.io.IOException
- Throws:
java.io.IOException
-
reLock
private void reLock() throws java.io.IOException
- Throws:
java.io.IOException
-
implCloseChannel
public void implCloseChannel() throws java.io.IOException
- Overrides:
implCloseChannel
in classFileBase
- Throws:
java.io.IOException
-
position
public long position() throws java.io.IOException
- Specified by:
position
in interfacejava.nio.channels.SeekableByteChannel
- Specified by:
position
in classjava.nio.channels.FileChannel
- Throws:
java.io.IOException
-
size
public long size() throws java.io.IOException
- Specified by:
size
in interfacejava.nio.channels.SeekableByteChannel
- Specified by:
size
in classjava.nio.channels.FileChannel
- Throws:
java.io.IOException
-
read
public int read(java.nio.ByteBuffer dst) throws java.io.IOException
- Specified by:
read
in interfacejava.nio.channels.ReadableByteChannel
- Specified by:
read
in interfacejava.nio.channels.SeekableByteChannel
- Specified by:
read
in classjava.nio.channels.FileChannel
- Throws:
java.io.IOException
-
read
public int read(java.nio.ByteBuffer dst, long position) throws java.io.IOException
-
position
public java.nio.channels.FileChannel position(long pos) throws java.io.IOException
- Specified by:
position
in interfacejava.nio.channels.SeekableByteChannel
- Specified by:
position
in classjava.nio.channels.FileChannel
- Throws:
java.io.IOException
-
truncate
public java.nio.channels.FileChannel truncate(long newLength) throws java.io.IOException
- Specified by:
truncate
in interfacejava.nio.channels.SeekableByteChannel
- Specified by:
truncate
in classjava.nio.channels.FileChannel
- Throws:
java.io.IOException
-
force
public void force(boolean metaData) throws java.io.IOException
-
write
public int write(java.nio.ByteBuffer src) throws java.io.IOException
- Specified by:
write
in interfacejava.nio.channels.SeekableByteChannel
- Specified by:
write
in interfacejava.nio.channels.WritableByteChannel
- Specified by:
write
in classjava.nio.channels.FileChannel
- Throws:
java.io.IOException
-
write
public int write(java.nio.ByteBuffer src, long position) throws java.io.IOException
-
tryLock
public java.nio.channels.FileLock tryLock(long position, long size, boolean shared) throws java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-