org.entityfs.ram
Class RamFileSystemBuilder

java.lang.Object
  extended by org.entityfs.impl.AbstractFileSystemBuilder<T>
      extended by org.entityfs.impl.impl.AbstractFileSystemBuilderImpl<RamFileSystemBuilder>
          extended by org.entityfs.ram.RamFileSystemBuilder
All Implemented Interfaces:
FileSystemBuilder<RamFileSystemBuilder>

public class RamFileSystemBuilder
extends AbstractFileSystemBuilderImpl<RamFileSystemBuilder>
implements FileSystemBuilder<RamFileSystemBuilder>

This is a builder object for building read/write Ram file systems. A Ram file system keeps all file system data in-memory. It can have an optional size limit (other than the Java process' max heap space...).

File data in the Ram file system is partitioned into file segments. The default size of a file segment is 4096 bytes. A file can never occupy less space in memory than its segment size (plus other internal file data (instance variables)).

Since:
1.0
Author:
Karl Gustafsson

Field Summary
static int DEFAULT_FILE_SEGMENT_SIZE_BYTES
          The default file segment size is 4096 bytes.
static long DEFAULT_MAX_FILE_SYSTEM_SIZE_BYTES
          The default maximum file system size is -1 bytes (unlimited size).
 
Fields inherited from interface org.entityfs.FileSystemBuilder
DEFAULT_BUFFER_SIZE
 
Constructor Summary
RamFileSystemBuilder()
          Create a builder with default settings: LogAdapter: DefaultLogAdapter.DEFAULT_ADAPTER EntityValidityControlStrategy: null (the backend is only accessible through the file system)
 
Method Summary
protected  AdapterFactory createAdapterFactory()
           
protected  ChildEntityManagerFactory<EntityImplementation> createDefaultChildEntityManagerFactory(FileSystemAdapter fsa, LogAdapterHolder lah)
           
protected  FileSystemImplementation createFileSystem(SupportObjects fso, FileSystemDelegate fsd)
           
protected  FileSystemDelegate createFileSystemDelegate(FileSystemAdapter fsa)
           
 int getFileSegmentSizeBytes()
          Get the Ram file segment size in bytes.
 long getMaxFileSystemSizeBytes()
          Get the maximum size of the file system data in bytes.
 boolean isLockingSupported()
          Does the file system being built support locking?
protected  boolean isReadOnly()
           
 RamFileSystemBuilder setFileSegmentSizeBytes(int noBytes)
          Set the size of a Ram file segment.
 RamFileSystemBuilder setMaxFileSystemSizeBytes(long size)
          Set the maximum size of the file system data in bytes.
protected  Collection<String> validate()
           
 
Methods inherited from class org.entityfs.impl.impl.AbstractFileSystemBuilderImpl
create, enableEvents, getChildEntityManagerFactory, getEventManager, isFileSystemSupportedByAllCapabilities, setChildEntityManagerFactory, setEventManager
 
Methods inherited from class org.entityfs.impl.AbstractFileSystemBuilder
addCapabilityProvider, addCapabilityProviders, disableAccessControls, disableEntityValidityControls, enableLocking, getAccessController, getBufferSize, getCapabilityProviders, getCapabilityProvidersInternal, getEntityValidityControlStrategy, getLockAcquiringStrategy, getLockAdapterFactory, getLockCommandExecutor, getLogAdapter, getName, getThis, setAccessController, setBufferSize, setEntityValidityControlStrategy, setLockAcquiringStrategy, setLockAdapterFactory, setLockCommandExecutor, setLogAdapter, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.entityfs.FileSystemBuilder
addCapabilityProvider, addCapabilityProviders, create, disableAccessControls, disableEntityValidityControls, enableEvents, enableLocking, getAccessController, getBufferSize, getCapabilityProviders, getEntityValidityControlStrategy, getLockAcquiringStrategy, getLockAdapterFactory, getLogAdapter, getName, setAccessController, setBufferSize, setEntityValidityControlStrategy, setLockAcquiringStrategy, setLockAdapterFactory, setLogAdapter, setName
 

Field Detail

DEFAULT_FILE_SEGMENT_SIZE_BYTES

public static final int DEFAULT_FILE_SEGMENT_SIZE_BYTES
The default file segment size is 4096 bytes.

See Also:
Constant Field Values

DEFAULT_MAX_FILE_SYSTEM_SIZE_BYTES

public static final long DEFAULT_MAX_FILE_SYSTEM_SIZE_BYTES
The default maximum file system size is -1 bytes (unlimited size).

See Also:
Constant Field Values
Constructor Detail

RamFileSystemBuilder

public RamFileSystemBuilder()
Create a builder with default settings:

Method Detail

setFileSegmentSizeBytes

public RamFileSystemBuilder setFileSegmentSizeBytes(int noBytes)
Set the size of a Ram file segment. The default value is 4096 bytes.

Parameters:
noBytes - The Ram file segment in bytes.
Returns:
The builder object (this).

getFileSegmentSizeBytes

public int getFileSegmentSizeBytes()
Get the Ram file segment size in bytes.

Returns:
The Ram file segment size in bytes.

setMaxFileSystemSizeBytes

public RamFileSystemBuilder setMaxFileSystemSizeBytes(long size)
Set the maximum size of the file system data in bytes. The size set here does not take the memory size of file system objects into account, only the accumulated size of allocated file segments. Set the max size to -1 to have "unlimited" maximum size. (The available heap space for the Java process sets the effective limit.)

The default max file system size is set to -1 ("unlimited" size).

Parameters:
size - The maximum size for the file system. Set to -1 for "unlimited" size.
Returns:
The builder object (this).

getMaxFileSystemSizeBytes

public long getMaxFileSystemSizeBytes()
Get the maximum size of the file system data in bytes.

Returns:
The maximum size of the file system data in bytes, or -1 if the file system can have "unlimited" size.

createAdapterFactory

protected AdapterFactory createAdapterFactory()
Specified by:
createAdapterFactory in class AbstractFileSystemBuilderImpl<RamFileSystemBuilder>

createDefaultChildEntityManagerFactory

protected ChildEntityManagerFactory<EntityImplementation> createDefaultChildEntityManagerFactory(FileSystemAdapter fsa,
                                                                                                 LogAdapterHolder lah)
Overrides:
createDefaultChildEntityManagerFactory in class AbstractFileSystemBuilderImpl<RamFileSystemBuilder>

createFileSystemDelegate

protected FileSystemDelegate createFileSystemDelegate(FileSystemAdapter fsa)
Specified by:
createFileSystemDelegate in class AbstractFileSystemBuilderImpl<RamFileSystemBuilder>

createFileSystem

protected FileSystemImplementation createFileSystem(SupportObjects fso,
                                                    FileSystemDelegate fsd)
Specified by:
createFileSystem in class AbstractFileSystemBuilderImpl<RamFileSystemBuilder>

validate

protected Collection<String> validate()
Overrides:
validate in class AbstractFileSystemBuilder<RamFileSystemBuilder>

isLockingSupported

public boolean isLockingSupported()
Description copied from interface: FileSystemBuilder
Does the file system being built support locking?

Specified by:
isLockingSupported in interface FileSystemBuilder<RamFileSystemBuilder>
Returns:
true.
See Also:
FileSystemBuilder.enableLocking()

isReadOnly

protected boolean isReadOnly()
Specified by:
isReadOnly in class AbstractFileSystemBuilderImpl<RamFileSystemBuilder>
Returns:
false, always.