Apache Storm Component Guide
Also available as:
loading table of contents...

Implementing Custom States

Currently the only kind of State implementation supported is KeyValueState, which provides key-value mapping.

Custom state implementations should provide implementations for the methods defined in the State interface. These are the void prepareCommit(long txid), void commit(long txid), and rollback() methods. The commit() method is optional; it is useful if the bolt manages state on its own. This is currently used only by internal system bolts (such as CheckpointSpout).

KeyValueState implementations should also implement the methods defined in the KeyValueState interface.

The framework instantiates state through the corresponding StateProvider implementation. A custom state should also provide a StateProvider implementation that can load and return the state based on the namespace.

Each state belongs to a unique namespace. The namespace is typically unique to a task, so that each task can have its own state. The StateProvider and corresponding State implementation should be available in the class path of Storm, by placing them in the extlib directory.