com.bigdata.io
Interface IReopenChannel

All Known Implementing Classes:
NOPReopener

public interface IReopenChannel

Interface for objects which know how to re-open the backing FileChannel for some resource and also understand when the resource has been closed and therefore should not be reopened. This is used in combination with FileChannelUtility to support the transparent re-opening of a file whose channel was closed asynchronously by an interrupt in another thread during an NIO operation.

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

Method Summary
 FileChannel reopenChannel()
          Transparently re-opens the FileChannel for the backing file if it is closed.
 String toString()
          Should include the name of the backing file (if known).
 

Method Detail

reopenChannel

FileChannel reopenChannel()
                          throws IOException
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.

Returns:
The FileChannel and never null.
Throws:
IllegalStateException - if the resource has been closed and is therefore no longer permitting reads or writes on the file.
IOException - if a required FileLock could not be obtained on a platform and volume where FileLock is supported.

toString

String toString()
Should include the name of the backing file (if known).

Overrides:
toString in class Object


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