@ThreadSafe public final class FsFailSafeManager extends FsDecoratingManager<FsManager>
FsManager.sync(de.schlichtherle.truezip.util.BitField<de.schlichtherle.truezip.fs.FsSyncOption>) 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.fs.FsSyncOption>, de.schlichtherle.truezip.util.ExceptionHandler<? super java.io.IOException, X>) isn't
called explicitly before the JVM terminates.
If any exception occurs within the shutdown hook, its stacktrace is printed to standard error - logging doesn't work in a shutdown hook.
| Modifier and Type | Class and Description |
|---|---|
private static class |
FsFailSafeManager.Shutdown
A shutdown hook thread.
|
private static class |
FsFailSafeManager.Sync
A runnable which committs all unsynchronized changes to file systems.
|
| Modifier and Type | Field and Description |
|---|---|
private static Runtime |
RUNTIME |
private FsFailSafeManager.Shutdown |
shutdown |
delegate| Constructor and Description |
|---|
FsFailSafeManager(FsManager manager) |
| Modifier and Type | Method and Description |
|---|---|
FsController<?> |
getController(FsMountPoint mountPoint,
FsCompositeDriver driver)
Returns a thread-safe file system controller for the given mount point.
|
<X extends IOException> |
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,
releases the associated resources (e.g. target archive files) for
access by third parties (e.g. other processes), cleans up any temporary
allocated resources (e.g. temporary files) and purges any cached data.
|
getSize, iterator, toStringprivate static final Runtime RUNTIME
private volatile FsFailSafeManager.Shutdown shutdown
public FsFailSafeManager(@NonNull
FsManager manager)
public FsController<?> getController(FsMountPoint mountPoint, FsCompositeDriver driver)
synchronization
operations.
If not done before, a shutdown hook is added in order to call
FsManager.sync(de.schlichtherle.truezip.util.BitField<de.schlichtherle.truezip.fs.FsSyncOption>) on the decorated file system manager when the
JVM terminates.
getController in class FsDecoratingManager<FsManager>mountPoint - the mount point of the file system.driver - the file system composite driver which shall get used to
create a new file system controller if required.public <X extends IOException> void sync(BitField<FsSyncOption> options, ExceptionHandler<? super IOException,X> handler) throws X extends IOException
If a shutdown hook for this manager is present, it's removed before synchronization of the decorated file system manager.
sync in class FsManagerX - The type of the IOException to throw at the
discretion of the exception handler.options - a bit field of synchronization options.handler - the exception handling strategy for consuming input
IOExceptions and/or assembling output
IOExceptions.X extends IOExceptionCopyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.