public final class LibaioFile<Callback extends SubmitInfo> extends Object implements AutoCloseable
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
open |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
fallocate(long size)
It will use fallocate to initialize a file.
|
void |
fill(long size)
It will preallocate the file with a given size.
|
int |
getBlockSize() |
long |
getSize() |
boolean |
lock() |
ByteBuffer |
newBuffer(int size)
It will allocate a buffer to be used on libaio operations.
|
void |
read(long position,
int size,
ByteBuffer buffer,
Callback callback)
It will submit a read to the queue.
|
void |
write(long position,
int size,
ByteBuffer buffer,
Callback callback)
It will submit a write to the queue.
|
public int getBlockSize()
public boolean lock()
public void close()
throws IOException
close in interface AutoCloseableIOExceptionpublic long getSize()
public void write(long position,
int size,
ByteBuffer buffer,
Callback callback)
throws IOException
LibaioContext.poll(SubmitInfo[], int, int)
In case of the libaio queue is full (e.g. returning E_AGAIN) this method will return false.
position - The position on the file to write. Notice this has to be a multiple of 512.size - The size of the buffer to use while writing.buffer - if you are using O_DIRECT the buffer here needs to be allocated by newBuffer(int).callback - A callback to be returned on the poll method.IOException - in case of errorpublic void read(long position,
int size,
ByteBuffer buffer,
Callback callback)
throws IOException
LibaioContext.poll(SubmitInfo[], int, int).
In case of the libaio queue is full (e.g. returning E_AGAIN) this method will return false.
position - The position on the file to read. Notice this has to be a multiple of 512.size - The size of the buffer to use while reading.buffer - if you are using O_DIRECT the buffer here needs to be allocated by newBuffer(int).callback - A callback to be returned on the poll method.IOException - in case of errorLibaioContext.poll(SubmitInfo[], int, int)public ByteBuffer newBuffer(int size)
LibaioContext.freeBuffer(java.nio.ByteBuffer).size - the size of the buffer.public void fill(long size)
size - number of bytes to be filled on the filepublic void fallocate(long size)
size - number of bytes to be filled on the fileCopyright © 2017 JBoss by Red Hat. All rights reserved.