TrueZIP Kernel 7.0-rc2

de.schlichtherle.truezip.fs
Class FsFailSafeManager

java.lang.Object
  extended by de.schlichtherle.truezip.fs.FsManager
      extended by de.schlichtherle.truezip.fs.FsDecoratingManager<FsManager>
          extended by de.schlichtherle.truezip.fs.FsFailSafeManager
All Implemented Interfaces:
Iterable<FsController<?>>

@ThreadSafe
public final class FsFailSafeManager
extends FsDecoratingManager<FsManager>

Uses a JVM shutdown hook to call FsManager.sync(de.schlichtherle.truezip.util.BitField) on the decorated file system manager when the JVM terminates. This is to protect an application from loss of data if sync(de.schlichtherle.truezip.util.BitField, de.schlichtherle.truezip.util.ExceptionHandler) isn't called explicitly before the JVM terminates.

Author:
Christian Schlichtherle
See Also:
getController(FsMountPoint, FsCompositeDriver), sync(de.schlichtherle.truezip.util.BitField, de.schlichtherle.truezip.util.ExceptionHandler)

Nested Class Summary
private static class FsFailSafeManager.Shutdown
          A shutdown hook thread.
private static class FsFailSafeManager.Sync
          A runnable which committs all unsynchronized changes to file systems.
 
Field Summary
private static Runtime RUNTIME
           
private  FsFailSafeManager.Shutdown shutdown
           
 
Fields inherited from class de.schlichtherle.truezip.fs.FsDecoratingManager
delegate
 
Fields inherited from class de.schlichtherle.truezip.fs.FsManager
UMOUNT
 
Constructor Summary
FsFailSafeManager(FsManager manager)
           
 
Method Summary
 FsController<?> getController(FsMountPoint mountPoint, FsCompositeDriver driver)
          Returns a thread-safe file system controller for the given mount point.
<X extends IOException>
void
sync(BitField<FsSyncOption> options, ExceptionHandler<? super IOException,X> handler)
          Commits all unsynchronized changes to the contents of all federated file systems managed by this instance to their respective parent file system.
 
Methods inherited from class de.schlichtherle.truezip.fs.FsDecoratingManager
getSize, iterator, toString
 
Methods inherited from class de.schlichtherle.truezip.fs.FsManager
equals, hashCode, sync
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

RUNTIME

private static final Runtime RUNTIME

shutdown

private volatile FsFailSafeManager.Shutdown shutdown
Constructor Detail

FsFailSafeManager

public FsFailSafeManager(@NonNull
                         FsManager manager)
Method Detail

getController

public FsController<?> getController(FsMountPoint mountPoint,
                                     FsCompositeDriver driver)
Returns a thread-safe file system controller for the given mount point. If and only if the given mount point addresses a federated file system, the returned file system controller is remembered for life cycle management, i.e. future lookup and synchronization operations.

If not done before, a shutdown hook is added in order to call FsManager.sync(de.schlichtherle.truezip.util.BitField) on the decorated file system manager when the JVM terminates.

Overrides:
getController in class FsDecoratingManager<FsManager>
Parameters:
mountPoint - the mount point of the file system.
driver - the file system composite driver which will be used to create a new file system controller if required.
Returns:
A file system controller.

sync

public <X extends IOException> void sync(BitField<FsSyncOption> options,
                                         ExceptionHandler<? super IOException,X> handler)
          throws X extends IOException
Commits all unsynchronized changes to the contents of all federated file systems managed by this instance to their respective parent file system. This will reset the state of the respective file system controllers.

If a shutdown hook for this manager is present, it's removed before synchronization of the decorated file system manager.

Overrides:
sync in class FsDecoratingManager<FsManager>
Type Parameters:
X - the type of the IOException to throw at the discretion of the exception handler.
Parameters:
options - the synchronization options.
handler - the exception handling strategy for dealing with one or more input SyncExceptions which may trigger an X.
Throws:
X extends IOException

TrueZIP Kernel 7.0-rc2

Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.