org.apache.s4.core.ft
Class DefaultFileSystemStateStorage

java.lang.Object
  extended by org.apache.s4.core.ft.DefaultFileSystemStateStorage
All Implemented Interfaces:
StateStorage

public class DefaultFileSystemStateStorage
extends java.lang.Object
implements StateStorage

Implementation of a file system backend storage to persist checkpoints.

The file system may be the default local file system when running on a single machine, but should be a distributed file system such as NFS when running on a cluster.

Checkpoints are stored in individual files (1 file = 1 checkpointId) in directories according to the following structure: (storageRootpath)/prototypeId/checkpointId


Constructor Summary
DefaultFileSystemStateStorage()
           
 
Method Summary
 void checkStorageDir()
           
 byte[] fetchState(CheckpointId key)
          Fetches data for a stored checkpoint.
 java.util.Set<CheckpointId> fetchStoredKeys()
          Fetches all stored safeKeeper Ids.
 void init()
           Called by the dependency injection framework, after construction.
 void saveState(CheckpointId key, byte[] state, StorageCallback callback)
          Stores a checkpoint.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultFileSystemStateStorage

public DefaultFileSystemStateStorage()
Method Detail

init

@Inject
public void init()

Called by the dependency injection framework, after construction.


fetchState

public byte[] fetchState(CheckpointId key)
Description copied from interface: StateStorage
Fetches data for a stored checkpoint.

Must return null if storage does not contain this key.

Specified by:
fetchState in interface StateStorage
Parameters:
key - safeKeeperId for this checkpoint
Returns:
stored checkpoint data, or null if the storage does not contain data for the given key

fetchStoredKeys

public java.util.Set<CheckpointId> fetchStoredKeys()
Description copied from interface: StateStorage
Fetches all stored safeKeeper Ids.

Specified by:
fetchStoredKeys in interface StateStorage
Returns:
all stored safeKeeper Ids.

checkStorageDir

public void checkStorageDir()

saveState

public void saveState(CheckpointId key,
                      byte[] state,
                      StorageCallback callback)
Description copied from interface: StateStorage
Stores a checkpoint.

NOTE: we don't handle any failure/success return value, because all failure/success notifications go through the StorageCallback reference

Specified by:
saveState in interface StateStorage
Parameters:
key - safeKeeperId
state - checkpoint data as a byte array
callback - callback for receiving notifications of storage operations. This callback is configurable