public abstract class FileSystem extends java.lang.Object implements PhysicalGraph
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
BLOCK_EXTENSION |
protected java.io.File |
storageDirectory |
Constructor and Description |
---|
FileSystem(java.lang.String storageRoot) |
Modifier and Type | Method and Description |
---|---|
protected void |
fullRecovery()
Does a full recovery from disk; this scans every block in the system,
reads metadata, and performs a checksum to verify integrity.
|
long |
getFreeSpace()
Reports the amount of free space (in bytes) in the root storage
directory.
|
protected void |
initialize(java.lang.String storageRoot) |
boolean |
isReadOnly()
Reports whether the Galileo filesystem is read-only.
|
Block |
loadBlock(java.lang.String blockPath)
Retrieves a
Block instance, given its path on disk. |
Metadata |
loadMetadata(java.lang.String blockPath)
|
protected java.util.List<java.lang.String> |
rebuildPaths(java.io.File storageDir)
Scans the directory structure on disk to find all the blocks stored.
|
protected void |
recover(java.util.List<java.lang.String> blockPaths)
Does a full recovery from disk on a particular Galileo partition; this
scans every block in the partition, reads its metadata, and performs a
checksum to verify block integrity.
|
protected java.util.List<java.lang.String> |
scanDirectory(java.io.File directory)
Scans a directory (and its subdirectories) for blocks.
|
abstract void |
shutdown()
Performs a clean shutdown of the FileSystem instance.
|
java.lang.String |
storeBlock(Block block)
Stores a
Block on disk. |
abstract void |
storeMetadata(Metadata metadata,
java.lang.String blockPath)
Inserts Metadata into the file system.
|
public static final java.lang.String BLOCK_EXTENSION
protected java.io.File storageDirectory
public FileSystem(java.lang.String storageRoot) throws FileSystemException, java.io.IOException
FileSystemException
java.io.IOException
protected void initialize(java.lang.String storageRoot) throws FileSystemException, java.io.IOException
FileSystemException
java.io.IOException
protected java.util.List<java.lang.String> scanDirectory(java.io.File directory)
directory
- Directory to scan for blocks.protected void fullRecovery()
protected java.util.List<java.lang.String> rebuildPaths(java.io.File storageDir)
storageDir
- the root directory to start scanning from.protected void recover(java.util.List<java.lang.String> blockPaths)
public Block loadBlock(java.lang.String blockPath) throws java.io.IOException, galileo.serialization.SerializationException
PhysicalGraph
Block
instance, given its path on disk.loadBlock
in interface PhysicalGraph
blockPath
- the physical (on-disk) location of the Block to load.java.io.IOException
galileo.serialization.SerializationException
public Metadata loadMetadata(java.lang.String blockPath) throws java.io.IOException, galileo.serialization.SerializationException
PhysicalGraph
loadMetadata
in interface PhysicalGraph
blockPath
- the physical location of the Block to load metadata
from.java.io.IOException
galileo.serialization.SerializationException
public java.lang.String storeBlock(Block block) throws FileSystemException, java.io.IOException
PhysicalGraph
Block
on disk. The location of the Block will be
determined by the particular FileSystem implementation being used rather
than as a method parameter, so only the Block itself is provided.storeBlock
in interface PhysicalGraph
block
- the Block instance to persist to disk.FileSystemException
java.io.IOException
public abstract void storeMetadata(Metadata metadata, java.lang.String blockPath) throws FileSystemException, java.io.IOException
PhysicalGraph
storeMetadata
in interface PhysicalGraph
metadata
- the Metadata
to 'store,' which may just involve
updating index structures.blockPath
- the on-disk path of the Block the Metadata being stored
belongs to.FileSystemException
java.io.IOException
public boolean isReadOnly()
public long getFreeSpace()
public abstract void shutdown()
Note that this method may be called during a signal handling operation, which may mean that the logging subsystem has already shut down, so critical errors/information should be printed to stdout or stderr. Furthermore, there is no guarantee all the shutdown operations will be executed, so time is of the essence here.