org.hornetq.core.asyncio.impl
Class AsynchronousFileImpl

java.lang.Object
  extended by org.hornetq.core.asyncio.impl.AsynchronousFileImpl
All Implemented Interfaces:
AsynchronousFile

public class AsynchronousFileImpl
extends java.lang.Object
implements AsynchronousFile

AsynchronousFile implementation

Author:
clebert.suconic@jboss.com Warning: Case you refactor the name or the package of this class You need to make sure you also rename the C++ native calls

Constructor Summary
AsynchronousFileImpl(java.util.concurrent.Executor writeExecutor, java.util.concurrent.Executor pollerExecutor)
           
 
Method Summary
static void addMax(int io)
           
static void clearBuffer(java.nio.ByteBuffer buffer)
           
 void close()
           
static void destroyBuffer(java.nio.ByteBuffer buffer)
           
 void fill(long position, int blocks, long size, byte fillChar)
           
protected  void finalize()
           
 int getBlockSize()
           
 java.lang.String getFileName()
           
 long getHandler()
          Return the JNI handler used on C++
static int getTotalMaxIO()
          For test purposes
static boolean isLoaded()
           
static void nanoSleep()
           
static java.nio.ByteBuffer newBuffer(int size)
          This needs to be synchronized because of http://bugs.sun.com/view_bug.do?bug_id=6791815 http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2009-January/000386.html
 void open(java.lang.String fileName, int maxIO)
          Note: If you are using a native Linux implementation, maxIO can't be higher than what's defined on /proc/sys/fs/aio-max-nr, or you would get an error
 void read(long position, long size, java.nio.ByteBuffer directByteBuffer, AIOCallback aioPackage)
           
static void resetMaxAIO()
           
 void setBufferCallback(BufferCallback callback)
           
static void setNanoSleepInterval(int nanoseconds)
          Instead of passing the nanoSeconds through the stack call every time, we set it statically inside the native method
 long size()
          Warning: This function will perform a synchronous IO, probably translating to a fstat call
 void write(long position, long size, java.nio.ByteBuffer directByteBuffer, AIOCallback aioCallback)
          Any error will be reported on the callback interface
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AsynchronousFileImpl

public AsynchronousFileImpl(java.util.concurrent.Executor writeExecutor,
                            java.util.concurrent.Executor pollerExecutor)
Parameters:
writeExecutor - It needs to be a single Thread executor. If null it will use the user thread to execute write operations
pollerExecutor - The thread pool that will initialize poller handlers
Method Detail

addMax

public static void addMax(int io)

getTotalMaxIO

public static int getTotalMaxIO()
For test purposes


resetMaxAIO

public static void resetMaxAIO()

isLoaded

public static boolean isLoaded()

open

public void open(java.lang.String fileName,
                 int maxIO)
          throws HornetQException
Description copied from interface: AsynchronousFile
Note: If you are using a native Linux implementation, maxIO can't be higher than what's defined on /proc/sys/fs/aio-max-nr, or you would get an error

Specified by:
open in interface AsynchronousFile
maxIO - The number of max concurrent asynchrnous IO operations. It has to be balanced between the size of your writes and the capacity of your disk.
Throws:
HornetQException

close

public void close()
           throws java.lang.Exception
Specified by:
close in interface AsynchronousFile
Throws:
java.lang.Exception

write

public void write(long position,
                  long size,
                  java.nio.ByteBuffer directByteBuffer,
                  AIOCallback aioCallback)
Description copied from interface: AsynchronousFile
Any error will be reported on the callback interface

Specified by:
write in interface AsynchronousFile

read

public void read(long position,
                 long size,
                 java.nio.ByteBuffer directByteBuffer,
                 AIOCallback aioPackage)
          throws HornetQException
Specified by:
read in interface AsynchronousFile
Throws:
HornetQException

size

public long size()
          throws HornetQException
Description copied from interface: AsynchronousFile
Warning: This function will perform a synchronous IO, probably translating to a fstat call

Specified by:
size in interface AsynchronousFile
Throws:
HornetQException

fill

public void fill(long position,
                 int blocks,
                 long size,
                 byte fillChar)
          throws HornetQException
Specified by:
fill in interface AsynchronousFile
Throws:
HornetQException

getBlockSize

public int getBlockSize()
Specified by:
getBlockSize in interface AsynchronousFile

getFileName

public java.lang.String getFileName()
Specified by:
getFileName in interface AsynchronousFile

newBuffer

public static java.nio.ByteBuffer newBuffer(int size)
This needs to be synchronized because of http://bugs.sun.com/view_bug.do?bug_id=6791815 http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2009-January/000386.html

Parameters:
size -
Returns:

setBufferCallback

public void setBufferCallback(BufferCallback callback)
Specified by:
setBufferCallback in interface AsynchronousFile

getHandler

public long getHandler()
Return the JNI handler used on C++


clearBuffer

public static void clearBuffer(java.nio.ByteBuffer buffer)

finalize

protected void finalize()
Overrides:
finalize in class java.lang.Object

destroyBuffer

public static void destroyBuffer(java.nio.ByteBuffer buffer)

setNanoSleepInterval

public static void setNanoSleepInterval(int nanoseconds)
Instead of passing the nanoSeconds through the stack call every time, we set it statically inside the native method


nanoSleep

public static void nanoSleep()


Copyright © 2009 Red Hat Inc. All Rights Reserved.