TrueZIP Kernel 7.0-rc2

de.schlichtherle.truezip.fs
Class FsCachingController

java.lang.Object
  extended by de.schlichtherle.truezip.fs.FsController<M>
      extended by de.schlichtherle.truezip.fs.FsDecoratingController<FsConcurrentModel,FsController<? extends FsConcurrentModel>>
          extended by de.schlichtherle.truezip.fs.FsCachingController

@NotThreadSafe
@DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class)
public final class FsCachingController
extends FsDecoratingController<FsConcurrentModel,FsController<? extends FsConcurrentModel>>

A content caching file system controller implements a combined caching and buffering strategy for entry data. Decorating a concurrent file system controller with this class has the following effects:

Author:
Christian Schlichtherle

Nested Class Summary
private static class FsCachingController.CacheEntry
          A proxy entry for hiding socket connections.
private  class FsCachingController.EntryCache
          A cache for the contents of an individual file system entry.
private  class FsCachingController.Input
           
private  class FsCachingController.Output
           
 
Field Summary
private  Map<FsEntryName,FsCachingController.EntryCache> caches
           
private  IOPool<?> pool
           
private static IOCache.Strategy STRATEGY
           
 
Fields inherited from class de.schlichtherle.truezip.fs.FsDecoratingController
delegate
 
Constructor Summary
FsCachingController(FsController<? extends FsConcurrentModel> controller, IOPool<?> pool)
          Constructs a new content caching file system controller.
 
Method Summary
private
<X extends IOException>
void
beforeSync(BitField<FsSyncOption> options, ExceptionHandler<? super FsSyncException,X> handler)
           
 FsEntry getEntry(FsEntryName name)
           
 InputSocket<?> getInputSocket(FsEntryName name, BitField<FsInputOption> options)
          Returns an input socket for reading the contents of the entry addressed by the given name from the file system.
 OutputSocket<?> getOutputSocket(FsEntryName name, BitField<FsOutputOption> options, Entry template)
          Returns an output socket for writing the contents of the entry addressed by the given name to the file system.
 void mknod(FsEntryName name, Entry.Type type, BitField<FsOutputOption> options, Entry template)
          Creates or replaces and finally links a chain of one or more entries for the given entry name into the file system.
<X extends IOException>
void
sync(BitField<FsSyncOption> options, ExceptionHandler<? super FsSyncException,X> handler)
          Commits all unsynchronized changes to the contents of this file system to its parent file system.
 void unlink(FsEntryName name)
           
 
Methods inherited from class de.schlichtherle.truezip.fs.FsDecoratingController
getClosedIcon, getModel, getOpenIcon, getParent, isReadable, isReadOnly, isWritable, setReadOnly, setTime, toString
 
Methods inherited from class de.schlichtherle.truezip.fs.FsController
equals, hashCode, sync
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

STRATEGY

private static final IOCache.Strategy STRATEGY

pool

private final IOPool<?> pool

caches

private final Map<FsEntryName,FsCachingController.EntryCache> caches
Constructor Detail

FsCachingController

public FsCachingController(FsController<? extends FsConcurrentModel> controller,
                           IOPool<?> pool)
Constructs a new content caching file system controller.

Parameters:
controller - the decorated file system controller.
pool - the pool of temporary entries to hold the copied entry data.
Method Detail

getEntry

public FsEntry getEntry(FsEntryName name)
                 throws IOException
Overrides:
getEntry in class FsDecoratingController<FsConcurrentModel,FsController<? extends FsConcurrentModel>>
Throws:
IOException

getInputSocket

public InputSocket<?> getInputSocket(FsEntryName name,
                                     BitField<FsInputOption> options)
Description copied from class: FsController
Returns an input socket for reading the contents of the entry addressed by the given name from the file system.

Overrides:
getInputSocket in class FsDecoratingController<FsConcurrentModel,FsController<? extends FsConcurrentModel>>
Parameters:
name - a file system entry name.
Returns:
An InputSocket.

getOutputSocket

public OutputSocket<?> getOutputSocket(FsEntryName name,
                                       BitField<FsOutputOption> options,
                                       Entry template)
Description copied from class: FsController
Returns an output socket for writing the contents of the entry addressed by the given name to the file system. If template is not null, then the output entry shall have as many of its properties copied as reasonable, e.g. the last modification time.

Overrides:
getOutputSocket in class FsDecoratingController<FsConcurrentModel,FsController<? extends FsConcurrentModel>>
Parameters:
name - a file system entry name.
template - a nullable template for the properties of the output entry.
Returns:
An OutputSocket.

mknod

public void mknod(FsEntryName name,
                  Entry.Type type,
                  BitField<FsOutputOption> options,
                  Entry template)
           throws IOException
Description copied from class: FsController
Creates or replaces and finally links a chain of one or more entries for the given entry name into the file system.

Overrides:
mknod in class FsDecoratingController<FsConcurrentModel,FsController<? extends FsConcurrentModel>>
Parameters:
name - the file system entry name.
type - the file system entry type.
options - the file system output options. If CREATE_PARENTS is set, any missing parent directories will be created and linked into this file system with its last modification time set to the system's current time.
template - if not null, then the file system entry at the end of the chain shall inherit as much properties from this entry as possible - with the exception of its name and type.
Throws:
IOException - for some other I/O related reason, including but not exclusively upon one or more of the following conditions:
  • The file system is read only.
  • name contains characters which are not supported by the file system.
  • The entry already exists and either the option FsOutputOption.EXCLUSIVE is set or the entry is a directory.
  • The entry exists as a different type.
  • A parent entry exists but is not a directory.
  • A parent entry is missing and createParents is false.

unlink

public void unlink(FsEntryName name)
            throws IOException
Overrides:
unlink in class FsDecoratingController<FsConcurrentModel,FsController<? extends FsConcurrentModel>>
Throws:
IOException

sync

public <X extends IOException> void sync(BitField<FsSyncOption> options,
                                         ExceptionHandler<? super FsSyncException,X> handler)
          throws X extends IOException
Description copied from class: FsController
Commits all unsynchronized changes to the contents of this file system to its parent file system. If this is not a federated file system, i.e. if its not a member of a parent file system, then nothing happens. Otherwise, the state of this file system controller is reset.

Overrides:
sync in class FsDecoratingController<FsConcurrentModel,FsController<? extends FsConcurrentModel>>
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 FsSyncExceptions which may trigger an X.
Throws:
X extends IOException

beforeSync

private <X extends IOException> void beforeSync(BitField<FsSyncOption> options,
                                                ExceptionHandler<? super FsSyncException,X> handler)
                 throws X extends IOException
Throws:
X extends IOException

TrueZIP Kernel 7.0-rc2

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