Search in sources :

Example 1 with HeapPriorityQueueStateSnapshot

use of org.apache.flink.runtime.state.heap.HeapPriorityQueueStateSnapshot in project flink by apache.

the class RocksDBFullSnapshotResources method create.

public static <K> RocksDBFullSnapshotResources<K> create(final LinkedHashMap<String, RocksDBKeyedStateBackend.RocksDbKvStateInfo> kvStateInformation, // TODO: was it important that this is a LinkedHashMap
final Map<String, HeapPriorityQueueSnapshotRestoreWrapper<?>> registeredPQStates, final RocksDB db, final ResourceGuard rocksDBResourceGuard, final KeyGroupRange keyGroupRange, final TypeSerializer<K> keySerializer, final int keyGroupPrefixBytes, final StreamCompressionDecorator keyGroupCompressionDecorator) throws IOException {
    final List<StateMetaInfoSnapshot> stateMetaInfoSnapshots = new ArrayList<>(kvStateInformation.size());
    final List<RocksDBKeyedStateBackend.RocksDbKvStateInfo> metaDataCopy = new ArrayList<>(kvStateInformation.size());
    for (RocksDBKeyedStateBackend.RocksDbKvStateInfo stateInfo : kvStateInformation.values()) {
        // snapshot meta info
        stateMetaInfoSnapshots.add(stateInfo.metaInfo.snapshot());
        metaDataCopy.add(stateInfo);
    }
    List<HeapPriorityQueueStateSnapshot<?>> heapPriorityQueuesSnapshots = new ArrayList<>(registeredPQStates.size());
    for (HeapPriorityQueueSnapshotRestoreWrapper<?> stateInfo : registeredPQStates.values()) {
        stateMetaInfoSnapshots.add(stateInfo.getMetaInfo().snapshot());
        heapPriorityQueuesSnapshots.add(stateInfo.stateSnapshot());
    }
    final ResourceGuard.Lease lease = rocksDBResourceGuard.acquireResource();
    final Snapshot snapshot = db.getSnapshot();
    return new RocksDBFullSnapshotResources<>(lease, snapshot, metaDataCopy, heapPriorityQueuesSnapshots, stateMetaInfoSnapshots, db, keyGroupPrefixBytes, keyGroupRange, keySerializer, keyGroupCompressionDecorator);
}
Also used : HeapPriorityQueueStateSnapshot(org.apache.flink.runtime.state.heap.HeapPriorityQueueStateSnapshot) ResourceGuard(org.apache.flink.util.ResourceGuard) ArrayList(java.util.ArrayList) StateMetaInfoSnapshot(org.apache.flink.runtime.state.metainfo.StateMetaInfoSnapshot) RocksDBKeyedStateBackend(org.apache.flink.contrib.streaming.state.RocksDBKeyedStateBackend) HeapPriorityQueueStateSnapshot(org.apache.flink.runtime.state.heap.HeapPriorityQueueStateSnapshot) StateMetaInfoSnapshot(org.apache.flink.runtime.state.metainfo.StateMetaInfoSnapshot) Snapshot(org.rocksdb.Snapshot)

Aggregations

ArrayList (java.util.ArrayList)1 RocksDBKeyedStateBackend (org.apache.flink.contrib.streaming.state.RocksDBKeyedStateBackend)1 HeapPriorityQueueStateSnapshot (org.apache.flink.runtime.state.heap.HeapPriorityQueueStateSnapshot)1 StateMetaInfoSnapshot (org.apache.flink.runtime.state.metainfo.StateMetaInfoSnapshot)1 ResourceGuard (org.apache.flink.util.ResourceGuard)1 Snapshot (org.rocksdb.Snapshot)1