Class LibaioFile<Callback extends SubmitInfo>

    • Field Detail

      • open

        protected boolean open
    • Method Detail

      • getBlockSize

        public int getBlockSize()
      • lock

        public boolean lock()
      • getSize

        public long getSize()
        Returns:
        The size of the file.
      • write

        public void write​(long position,
                          int size,
                          ByteBuffer buffer,
                          Callback callback)
                   throws IOException
        It will submit a write to the queue. The callback sent here will be received on the LibaioContext.poll(SubmitInfo[], int, int) In case of the libaio queue is full (e.g. returning E_AGAIN) this method will return false.
        Notice: this won't hold a global reference on buffer, callback should hold a reference towards bufferWrite. And don't free the buffer until the callback was called as this could crash the VM.
        Parameters:
        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.
        Throws:
        IOException - in case of error
      • read

        public void read​(long position,
                         int size,
                         ByteBuffer buffer,
                         Callback callback)
                  throws IOException
        It will submit a read to the queue. The callback sent here will be received on the LibaioContext.poll(SubmitInfo[], int, int). In case of the libaio queue is full (e.g. returning E_AGAIN) this method will return false.
        Notice: this won't hold a global reference on buffer, callback should hold a reference towards bufferWrite. And don't free the buffer until the callback was called as this could crash the VM. *
        Parameters:
        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.
        Throws:
        IOException - in case of error
        See Also:
        LibaioContext.poll(SubmitInfo[], int, int)
      • newBuffer

        public ByteBuffer newBuffer​(int size)
        It will allocate a buffer to be used on libaio operations. Buffers here are allocated with posix_memalign.
        You need to explicitly free the buffer created from here using the LibaioContext.freeBuffer(java.nio.ByteBuffer).
        Parameters:
        size - the size of the buffer.
        Returns:
        the buffer allocated.
      • fill

        public void fill​(int alignment,
                         long size)
        It will preallocate the file with a given size.
        Parameters:
        size - number of bytes to be filled on the file
      • fallocate

        public void fallocate​(long size)
        It will use fallocate to initialize a file.
        Parameters:
        size - number of bytes to be filled on the file