org.apache.s4.core.ft
Interface StateStorage

All Known Implementing Classes:
DefaultFileSystemStateStorage

public interface StateStorage

Defines the methods that must be implemented by a backend storage for checkpoints.

NOTE: the backend implementation usually needs some kind of initialization. The recommended place to do this is in a custom method annotated with Inject annotation, which will be called after the instance is constructed.


Method Summary
 byte[] fetchState(CheckpointId key)
          Fetches data for a stored checkpoint.
 java.util.Set<CheckpointId> fetchStoredKeys()
          Fetches all stored safeKeeper Ids.
 void saveState(CheckpointId key, byte[] state, StorageCallback callback)
          Stores a checkpoint.
 

Method Detail

saveState

void saveState(CheckpointId key,
               byte[] state,
               StorageCallback callback)
Stores a checkpoint.

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

Parameters:
key - safeKeeperId
state - checkpoint data as a byte array
callback - callback for receiving notifications of storage operations. This callback is configurable

fetchState

byte[] fetchState(CheckpointId key)
Fetches data for a stored checkpoint.

Must return null if storage does not contain this key.

Parameters:
key - safeKeeperId for this checkpoint
Returns:
stored checkpoint data, or null if the storage does not contain data for the given key

fetchStoredKeys

java.util.Set<CheckpointId> fetchStoredKeys()
Fetches all stored safeKeeper Ids.

Returns:
all stored safeKeeper Ids.