Package org.apache.storm.redis.state
Class RedisKeyValueState<K,V> 
java.lang.Object
org.apache.storm.redis.state.RedisKeyValueState<K,V> 
- All Implemented Interfaces:
- Iterable<Map.Entry<K,,- V>> - KeyValueState<K,,- V> - State
A redis based implementation that persists the state in Redis.
- 
Field SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionRedisKeyValueState(String namespace) RedisKeyValueState(String namespace, JedisClusterConfig jedisClusterConfig, Serializer<K> keySerializer, Serializer<V> valueSerializer) RedisKeyValueState(String namespace, JedisPoolConfig poolConfig) RedisKeyValueState(String namespace, JedisPoolConfig poolConfig, Serializer<K> keySerializer, Serializer<V> valueSerializer) RedisKeyValueState(String namespace, RedisCommandsInstanceContainer container, Serializer<K> keySerializer, Serializer<V> valueSerializer) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidcommit()Persist the current state.voidcommit(long txid) Commit a previously prepared transaction.Deletes the value mapped to the key, if there is any.Returns the value mapped to the key.Returns the value mapped to the key or defaultValue if no mapping is found.iterator()voidprepareCommit(long txid) Invoked by the framework to prepare a transaction for commit.voidMaps the value with the key.voidrollback()Rollback a prepared transaction to the previously committed state.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.IterableforEach, spliterator
- 
Field Details- 
ITERATOR_CHUNK_SIZEpublic static final int ITERATOR_CHUNK_SIZE- See Also:
 
- 
EMPTY_PENDING_COMMIT_MAP
 
- 
- 
Constructor Details- 
RedisKeyValueState
- 
RedisKeyValueState
- 
RedisKeyValueStatepublic RedisKeyValueState(String namespace, JedisPoolConfig poolConfig, Serializer<K> keySerializer, Serializer<V> valueSerializer) 
- 
RedisKeyValueStatepublic RedisKeyValueState(String namespace, JedisClusterConfig jedisClusterConfig, Serializer<K> keySerializer, Serializer<V> valueSerializer) 
- 
RedisKeyValueStatepublic RedisKeyValueState(String namespace, RedisCommandsInstanceContainer container, Serializer<K> keySerializer, Serializer<V> valueSerializer) 
 
- 
- 
Method Details- 
putDescription copied from interface:KeyValueStateMaps the value with the key.- Specified by:
- putin interface- KeyValueState<K,- V> 
- Parameters:
- key- the key
- value- the value
 
- 
getDescription copied from interface:KeyValueStateReturns the value mapped to the key.- Specified by:
- getin interface- KeyValueState<K,- V> 
- Parameters:
- key- the key
- Returns:
- the value or null if no mapping is found
 
- 
getDescription copied from interface:KeyValueStateReturns the value mapped to the key or defaultValue if no mapping is found.- Specified by:
- getin interface- KeyValueState<K,- V> 
- Parameters:
- key- the key
- defaultValue- the value to return if no mapping is found
- Returns:
- the value or defaultValue if no mapping is found
 
- 
deleteDescription copied from interface:KeyValueStateDeletes the value mapped to the key, if there is any.- Specified by:
- deletein interface- KeyValueState<K,- V> 
- Parameters:
- key- the key
 
- 
iterator
- 
prepareCommitpublic void prepareCommit(long txid) Description copied from interface:StateInvoked by the framework to prepare a transaction for commit. It should be possible to commit the prepared state later.The same txid can be prepared again, but the next txid cannot be prepared when previous one is not yet committed. - Specified by:
- prepareCommitin interface- State
- Parameters:
- txid- the transaction id
 
- 
commitpublic void commit(long txid) Description copied from interface:StateCommit a previously prepared transaction. It should be possible to retrieve a committed state later.
- 
commitpublic void commit()Description copied from interface:StatePersist the current state. This is used when the component manages the state.
- 
rollbackpublic void rollback()Description copied from interface:StateRollback a prepared transaction to the previously committed state.
 
-