public class RocksDBKeyedStateBackend<K>
extends org.apache.flink.runtime.state.AbstractKeyedStateBackend<K>
AbstractKeyedStateBackend that stores its state in RocksDB and will serialize state to
streams provided by a CheckpointStreamFactory upon
checkpointing. This state backend can store very large state that exceeds memory and spills
to disk. Except for the snapshotting, this class should be accessed as if it is not threadsafe.| Modifier and Type | Field and Description |
|---|---|
protected org.rocksdb.RocksDB |
db
Our RocksDB data base, this is used by the actual subclasses of
AbstractRocksDBState
to store state. |
| Constructor and Description |
|---|
RocksDBKeyedStateBackend(org.apache.flink.api.common.JobID jobId,
String operatorIdentifier,
ClassLoader userCodeClassLoader,
File instanceBasePath,
org.rocksdb.DBOptions dbOptions,
org.rocksdb.ColumnFamilyOptions columnFamilyOptions,
org.apache.flink.runtime.query.TaskKvStateRegistry kvStateRegistry,
org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer,
int numberOfKeyGroups,
org.apache.flink.runtime.state.KeyGroupRange keyGroupRange) |
| Modifier and Type | Method and Description |
|---|---|
protected <N,T,ACC> org.apache.flink.api.common.state.FoldingState<T,ACC> |
createFoldingState(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
org.apache.flink.api.common.state.FoldingStateDescriptor<T,ACC> stateDesc) |
protected <N,T> org.apache.flink.api.common.state.ListState<T> |
createListState(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
org.apache.flink.api.common.state.ListStateDescriptor<T> stateDesc) |
protected <N,T> org.apache.flink.api.common.state.ReducingState<T> |
createReducingState(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
org.apache.flink.api.common.state.ReducingStateDescriptor<T> stateDesc) |
protected <N,T> org.apache.flink.api.common.state.ValueState<T> |
createValueState(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
org.apache.flink.api.common.state.ValueStateDescriptor<T> stateDesc) |
void |
dispose()
Should only be called by one thread, and only after all accesses to the DB happened.
|
protected <N,S> org.rocksdb.ColumnFamilyHandle |
getColumnFamily(org.apache.flink.api.common.state.StateDescriptor<?,S> descriptor,
org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer)
Creates a column family handle for use with a k/v state.
|
File |
getInstanceBasePath()
Only visible for testing, DO NOT USE.
|
int |
getKeyGroupPrefixBytes() |
void |
restore(Collection<org.apache.flink.runtime.state.KeyGroupsStateHandle> restoreState) |
RunnableFuture<org.apache.flink.runtime.state.KeyGroupsStateHandle> |
snapshot(long checkpointId,
long timestamp,
org.apache.flink.runtime.state.CheckpointStreamFactory streamFactory)
Triggers an asynchronous snapshot of the keyed state backend from RocksDB.
|
protected org.rocksdb.RocksDB db
AbstractRocksDBState
to store state. The different k/v states that we have don't each have their own RocksDB
instance. They all write to this instance but to their own column family.public RocksDBKeyedStateBackend(org.apache.flink.api.common.JobID jobId,
String operatorIdentifier,
ClassLoader userCodeClassLoader,
File instanceBasePath,
org.rocksdb.DBOptions dbOptions,
org.rocksdb.ColumnFamilyOptions columnFamilyOptions,
org.apache.flink.runtime.query.TaskKvStateRegistry kvStateRegistry,
org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer,
int numberOfKeyGroups,
org.apache.flink.runtime.state.KeyGroupRange keyGroupRange)
throws IOException
IOExceptionpublic void dispose()
public int getKeyGroupPrefixBytes()
public RunnableFuture<org.apache.flink.runtime.state.KeyGroupsStateHandle> snapshot(long checkpointId, long timestamp, org.apache.flink.runtime.state.CheckpointStreamFactory streamFactory) throws Exception
dispose(). For each backend, this method must always
be called by the same thread.checkpointId - The Id of the checkpoint.timestamp - The timestamp of the checkpoint.streamFactory - The factory that we can use for writing our state to streams.Exceptionpublic void restore(Collection<org.apache.flink.runtime.state.KeyGroupsStateHandle> restoreState) throws Exception
Exceptionprotected <N,S> org.rocksdb.ColumnFamilyHandle getColumnFamily(org.apache.flink.api.common.state.StateDescriptor<?,S> descriptor,
org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer)
throws IOException
This also checks whether the StateDescriptor for a state matches the one
that we checkpointed, i.e. is already in the map of column families.
IOExceptionprotected <N,T> org.apache.flink.api.common.state.ValueState<T> createValueState(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
org.apache.flink.api.common.state.ValueStateDescriptor<T> stateDesc)
throws Exception
protected <N,T> org.apache.flink.api.common.state.ListState<T> createListState(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
org.apache.flink.api.common.state.ListStateDescriptor<T> stateDesc)
throws Exception
protected <N,T> org.apache.flink.api.common.state.ReducingState<T> createReducingState(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
org.apache.flink.api.common.state.ReducingStateDescriptor<T> stateDesc)
throws Exception
protected <N,T,ACC> org.apache.flink.api.common.state.FoldingState<T,ACC> createFoldingState(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
org.apache.flink.api.common.state.FoldingStateDescriptor<T,ACC> stateDesc)
throws Exception
public File getInstanceBasePath()
Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.