com.bigdata.io
Class NOPReopener

java.lang.Object
  extended by com.bigdata.io.NOPReopener
All Implemented Interfaces:
IReopenChannel

public class NOPReopener
extends Object
implements IReopenChannel

Implementation that will not re-open the FileChannel once it has been closed. This is useful for simple things where you still want the reliability guarentees of FileChannelUtility.

Version:
$Id: NOPReopener.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson

Constructor Summary
NOPReopener(FileChannel channel)
           
NOPReopener(RandomAccessFile raf)
           
 
Method Summary
 FileChannel reopenChannel()
          Transparently re-opens the FileChannel for the backing file if it is closed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.bigdata.io.IReopenChannel
toString
 

Constructor Detail

NOPReopener

public NOPReopener(FileChannel channel)

NOPReopener

public NOPReopener(RandomAccessFile raf)
Method Detail

reopenChannel

public FileChannel reopenChannel()
                          throws IOException
Description copied from interface: IReopenChannel
Transparently re-opens the FileChannel for the backing file if it is closed.

Note: Java will close the backing FileChannel if a Thread is interrupted during an NIO operation.

Note: This method MUST NOT be invoked if the channel was closed by an interrupt in the caller's thread. The caller can detect this condition by a thrown ClosedByInterruptException rather than either an AsynchronousCloseException or an ClosedChannelException. See FileChannelUtility which knows how to handle this.

Note: This method MUST synchronized so that concurrent operations do not try to re-open the FileChannel at the same time.

Note: While the FileChannel may be open within the implementation of this method, it IS NOT possible guarenteed that it will be open by the time you try to use it except by synchronizing all activity on that FileChannel. In general, that will limit throughput.

Note: Platforms and volumes (such as NFS) which DO NOT support FileLock should re-open the file anyway without throwing an exception. This behavior is required to run in those contexts.

Specified by:
reopenChannel in interface IReopenChannel
Returns:
The FileChannel and never null.
Throws:
IOException - if a required FileLock could not be obtained on a platform and volume where FileLock is supported.


Copyright © 2006-2009 SYSTAP, LLC. All Rights Reserved.