Package org.deckfour.xes.nikefs2
Class NikeFS2VirtualFileSystem
- java.lang.Object
-
- org.deckfour.xes.nikefs2.NikeFS2VirtualFileSystem
-
- All Implemented Interfaces:
NikeFS2StorageProvider
public class NikeFS2VirtualFileSystem extends java.lang.Object implements NikeFS2StorageProvider
Virtual file system authority, managing swap files and virtual file abstractions. Implements the storage provider interface for use by file abstractions, and performs cleanup after a shutdown of the host application. This class must be used as a singleton. There is no need for multiple virtual file systems per application. A single VFS instance operates with maximum efficiency, and guarantees that no data corruption or swap loss will occur.- Author:
- Christian W. Guenther (christian@deckfour.org)
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<NikeFS2BlockProvider>blockProvidersList of block providers, i.e.protected intblockSizeBlock size, in bytes, of virtual storage blocks.protected static NikeFS2VirtualFileSysteminstanceThe singleton VFS instance.protected intswapFileSizeSize of swap files which are used to provide blocks.protected booleanuseLazyCopiesFlag determining whether to use soft copies for virtual file duplication.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description NikeFS2BlockallocateBlock()Allocates a new virtual storage block from this virtual file system instance.intblockSize()Returns the block size of this VFS.NikeFS2RandomAccessStoragecreateStorage()Creates a new empty random access storage, which is suitable for storing byte sequences and primitive data types.static NikeFS2VirtualFileSysteminstance()Singleton access method.voidsetBlockSize(int bytes)Sets the block size of the virtual file system.voidsetSwapFileSize(int bytes)Sets the swap file size of the virtual file system.voidsetUseLazyCopies(boolean useLazyCopies)Sets this VFS's property of whether to use soft copies for virtual file duplication.
-
-
-
Field Detail
-
instance
protected static NikeFS2VirtualFileSystem instance
The singleton VFS instance.
-
blockSize
protected int blockSize
Block size, in bytes, of virtual storage blocks. Default value is 2048, i.e. 2kB.
-
swapFileSize
protected int swapFileSize
Size of swap files which are used to provide blocks. Default is 67108864, i.e. 64 MB.
-
useLazyCopies
protected boolean useLazyCopies
Flag determining whether to use soft copies for virtual file duplication. This greatly enhances performance with negligible memory penalties, thus the default value istrue.
-
blockProviders
protected java.util.List<NikeFS2BlockProvider> blockProviders
List of block providers, i.e. currently used swap files that serve for providing storage blocks to virtual file abstractions.
-
-
Method Detail
-
instance
public static NikeFS2VirtualFileSystem instance()
Singleton access method.- Returns:
- The singleton instance.
-
setUseLazyCopies
public void setUseLazyCopies(boolean useLazyCopies)
Sets this VFS's property of whether to use soft copies for virtual file duplication. This will only affect newly created virtual files.- Parameters:
useLazyCopies- Whether to use soft copies for virtual file duplication.
-
setSwapFileSize
public void setSwapFileSize(int bytes)
Sets the swap file size of the virtual file system. (used henceforth until successive change).- Parameters:
bytes- Size of swap files, in bytes.
-
setBlockSize
public void setBlockSize(int bytes)
Sets the block size of the virtual file system. (used henceforth until successive change).- Parameters:
bytes- Size of blocks, in bytes.
-
createStorage
public NikeFS2RandomAccessStorage createStorage() throws java.io.IOException
Description copied from interface:NikeFS2StorageProviderCreates a new empty random access storage, which is suitable for storing byte sequences and primitive data types.- Specified by:
createStoragein interfaceNikeFS2StorageProvider- Returns:
- A newly created random access storage.
- Throws:
java.io.IOException
-
blockSize
public int blockSize()
Returns the block size of this VFS.- Returns:
- The size of virtual storage blocks served by this VFS, in bytes.
-
allocateBlock
public NikeFS2Block allocateBlock() throws java.io.IOException
Allocates a new virtual storage block from this virtual file system instance. If no currently allocated swap file can provide any more storage blocks, a new swap file will be allocated.- Returns:
- An empty storage block abstraction.
- Throws:
java.io.IOException
-
-