use of org.apache.flink.contrib.streaming.state.RocksDBStateUploader in project flink by apache.
the class RocksIncrementalSnapshotStrategyTest method createSnapshotStrategy.
public RocksIncrementalSnapshotStrategy createSnapshotStrategy(CloseableRegistry closeableRegistry) throws IOException, RocksDBException {
ColumnFamilyHandle columnFamilyHandle = rocksDBResource.createNewColumnFamily("test");
RocksDB rocksDB = rocksDBResource.getRocksDB();
byte[] key = "checkpoint".getBytes();
byte[] val = "incrementalTest".getBytes();
rocksDB.put(columnFamilyHandle, key, val);
// construct RocksIncrementalSnapshotStrategy
long lastCompletedCheckpointId = -1L;
ResourceGuard rocksDBResourceGuard = new ResourceGuard();
SortedMap<Long, Map<StateHandleID, StreamStateHandle>> materializedSstFiles = new TreeMap<>();
LinkedHashMap<String, RocksDBKeyedStateBackend.RocksDbKvStateInfo> kvStateInformation = new LinkedHashMap<>();
RocksDBStateUploader rocksDBStateUploader = new RocksDBStateUploader(RocksDBOptions.CHECKPOINT_TRANSFER_THREAD_NUM.defaultValue());
int keyGroupPrefixBytes = CompositeKeySerializationUtils.computeRequiredBytesInKeyGroupPrefix(2);
RegisteredKeyValueStateBackendMetaInfo<Integer, ArrayList<Integer>> metaInfo = new RegisteredKeyValueStateBackendMetaInfo<>(StateDescriptor.Type.VALUE, "test", IntSerializer.INSTANCE, new ArrayListSerializer<>(IntSerializer.INSTANCE));
RocksDBKeyedStateBackend.RocksDbKvStateInfo rocksDbKvStateInfo = new RocksDBKeyedStateBackend.RocksDbKvStateInfo(columnFamilyHandle, metaInfo);
kvStateInformation.putIfAbsent("test", rocksDbKvStateInfo);
return new RocksIncrementalSnapshotStrategy<>(rocksDB, rocksDBResourceGuard, IntSerializer.INSTANCE, kvStateInformation, new KeyGroupRange(0, 1), keyGroupPrefixBytes, TestLocalRecoveryConfig.disabled(), closeableRegistry, tmp.newFolder(), UUID.randomUUID(), materializedSstFiles, rocksDBStateUploader, lastCompletedCheckpointId);
}
Aggregations