use of org.apache.flink.contrib.streaming.state.RocksDBKeyedStateBackend.RocksDbKvStateInfo in project flink by apache.
the class RocksDBHeapTimersFullRestoreOperation method applyRestoreResult.
private void applyRestoreResult(SavepointRestoreResult savepointRestoreResult) throws IOException, RocksDBException, StateMigrationException {
List<StateMetaInfoSnapshot> restoredMetaInfos = savepointRestoreResult.getStateMetaInfoSnapshots();
Map<Integer, ColumnFamilyHandle> columnFamilyHandles = new HashMap<>();
Map<Integer, HeapPriorityQueueSnapshotRestoreWrapper<?>> restoredPQStates = new HashMap<>();
for (int i = 0; i < restoredMetaInfos.size(); i++) {
StateMetaInfoSnapshot restoredMetaInfo = restoredMetaInfos.get(i);
if (restoredMetaInfo.getBackendStateType() == BackendStateType.PRIORITY_QUEUE) {
String stateName = restoredMetaInfo.getName();
HeapPriorityQueueSnapshotRestoreWrapper<?> queueWrapper = registeredPQStates.computeIfAbsent(stateName, key -> createInternal(new RegisteredPriorityQueueStateBackendMetaInfo<>(restoredMetaInfo)));
restoredPQStates.put(i, queueWrapper);
} else {
RocksDbKvStateInfo registeredStateCFHandle = this.rocksHandle.getOrRegisterStateColumnFamilyHandle(null, restoredMetaInfo);
columnFamilyHandles.put(i, registeredStateCFHandle.columnFamilyHandle);
}
}
try (ThrowingIterator<KeyGroup> keyGroups = savepointRestoreResult.getRestoredKeyGroups()) {
restoreKVStateData(keyGroups, columnFamilyHandles, restoredPQStates);
}
}
use of org.apache.flink.contrib.streaming.state.RocksDBKeyedStateBackend.RocksDbKvStateInfo in project flink by apache.
the class RocksDBFullRestoreOperation method applyRestoreResult.
private void applyRestoreResult(SavepointRestoreResult savepointRestoreResult) throws IOException, RocksDBException, StateMigrationException {
List<StateMetaInfoSnapshot> restoredMetaInfos = savepointRestoreResult.getStateMetaInfoSnapshots();
Map<Integer, ColumnFamilyHandle> columnFamilyHandles = new HashMap<>();
for (int i = 0; i < restoredMetaInfos.size(); i++) {
StateMetaInfoSnapshot restoredMetaInfo = restoredMetaInfos.get(i);
RocksDbKvStateInfo registeredStateCFHandle = this.rocksHandle.getOrRegisterStateColumnFamilyHandle(null, restoredMetaInfo);
columnFamilyHandles.put(i, registeredStateCFHandle.columnFamilyHandle);
}
try (ThrowingIterator<KeyGroup> keyGroups = savepointRestoreResult.getRestoredKeyGroups()) {
restoreKVStateData(keyGroups, columnFamilyHandles);
}
}
use of org.apache.flink.contrib.streaming.state.RocksDBKeyedStateBackend.RocksDbKvStateInfo in project flink by apache.
the class RocksDBHandle method getOrRegisterStateColumnFamilyHandle.
RocksDbKvStateInfo getOrRegisterStateColumnFamilyHandle(ColumnFamilyHandle columnFamilyHandle, StateMetaInfoSnapshot stateMetaInfoSnapshot) {
RocksDbKvStateInfo registeredStateMetaInfoEntry = kvStateInformation.get(stateMetaInfoSnapshot.getName());
if (null == registeredStateMetaInfoEntry) {
// create a meta info for the state on restore;
// this allows us to retain the state in future snapshots even if it wasn't accessed
RegisteredStateMetaInfoBase stateMetaInfo = RegisteredStateMetaInfoBase.fromMetaInfoSnapshot(stateMetaInfoSnapshot);
if (columnFamilyHandle == null) {
registeredStateMetaInfoEntry = RocksDBOperationUtils.createStateInfo(stateMetaInfo, db, columnFamilyOptionsFactory, ttlCompactFiltersManager, writeBufferManagerCapacity);
} else {
registeredStateMetaInfoEntry = new RocksDbKvStateInfo(columnFamilyHandle, stateMetaInfo);
}
RocksDBOperationUtils.registerKvStateInformation(kvStateInformation, nativeMetricMonitor, stateMetaInfoSnapshot.getName(), registeredStateMetaInfoEntry);
} else {
// TODO with eager state registration in place, check here for serializer migration
// strategies
}
return registeredStateMetaInfoEntry;
}
Aggregations