本文整理了Java中org.rocksdb.RocksDB.getSnapshot
方法的一些代码示例,展示了RocksDB.getSnapshot
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RocksDB.getSnapshot
方法的具体详情如下:
包路径:org.rocksdb.RocksDB
类名称:RocksDB
方法名:getSnapshot
[英]Return a handle to the current DB state. Iterators created with this handle will all observe a stable snapshot of the current DB state. The caller must call ReleaseSnapshot(result) when the snapshot is no longer needed.
nullptr will be returned if the DB fails to take a snapshot or does not support snapshot.
[中]将句柄返回到当前DB状态。使用此句柄创建的迭代器都将观察当前数据库状态的稳定快照。当不再需要快照时,调用方必须调用ReleaseSnapshot(结果)。
如果数据库无法获取快照或不支持快照,则会返回nullptr。
代码示例来源:origin: apache/flink
@Nonnull
@Override
public RunnableFuture<SnapshotResult<KeyedStateHandle>> doSnapshot(
long checkpointId,
long timestamp,
@Nonnull CheckpointStreamFactory primaryStreamFactory,
@Nonnull CheckpointOptions checkpointOptions) throws Exception {
final SupplierWithException<CheckpointStreamWithResultProvider, Exception> checkpointStreamSupplier =
createCheckpointStreamSupplier(checkpointId, primaryStreamFactory, checkpointOptions);
final List<StateMetaInfoSnapshot> stateMetaInfoSnapshots = new ArrayList<>(kvStateInformation.size());
final List<Tuple2<ColumnFamilyHandle, RegisteredStateMetaInfoBase>> metaDataCopy =
new ArrayList<>(kvStateInformation.size());
for (Tuple2<ColumnFamilyHandle, RegisteredStateMetaInfoBase> tuple2 : kvStateInformation.values()) {
// snapshot meta info
stateMetaInfoSnapshots.add(tuple2.f1.snapshot());
metaDataCopy.add(tuple2);
}
final ResourceGuard.Lease lease = rocksDBResourceGuard.acquireResource();
final Snapshot snapshot = db.getSnapshot();
final SnapshotAsynchronousPartCallable asyncSnapshotCallable =
new SnapshotAsynchronousPartCallable(
checkpointStreamSupplier,
lease,
snapshot,
stateMetaInfoSnapshots,
metaDataCopy,
primaryStreamFactory.toString());
return asyncSnapshotCallable.toAsyncSnapshotFutureTask(cancelStreamRegistry);
}
代码示例来源:origin: apache/flink
AbstractRocksDBState<?, ?, SV> rocksDBState = (AbstractRocksDBState<?, ?, SV>) state;
Snapshot rocksDBSnapshot = db.getSnapshot();
try (
RocksIteratorWrapper iterator = getRocksIterator(db, stateMetaInfo.f0);
代码示例来源:origin: org.jsimpledb/jsimpledb-kv-rocksdb
/**
* Constructor.
*
* @param db RocksDB database to snapshot
* @throws NullPointerException if {@code db} is null
*/
public SnapshotRocksDBKVStore(RocksDB db) {
this(db, db.getSnapshot());
}
代码示例来源:origin: org.apache.flink/flink-statebackend-rocksdb_2.10
/**
* 1) Create a snapshot object from RocksDB.
*
* @param checkpointId id of the checkpoint for which we take the snapshot
* @param checkpointTimeStamp timestamp of the checkpoint for which we take the snapshot
*/
public void takeDBSnapShot(long checkpointId, long checkpointTimeStamp) {
Preconditions.checkArgument(snapshot == null, "Only one ongoing snapshot allowed!");
this.kvStateIterators = new ArrayList<>(stateBackend.kvStateInformation.size());
this.checkpointId = checkpointId;
this.checkpointTimeStamp = checkpointTimeStamp;
this.snapshot = stateBackend.db.getSnapshot();
}
代码示例来源:origin: org.rocksdb/rocksdbjni
/**
* <p>Return a handle to the current DB state. Iterators created with
* this handle will all observe a stable snapshot of the current DB
* state. The caller must call ReleaseSnapshot(result) when the
* snapshot is no longer needed.</p>
*
* <p>nullptr will be returned if the DB fails to take a snapshot or does
* not support snapshot.</p>
*
* @return Snapshot {@link Snapshot} instance
*/
public Snapshot getSnapshot() {
long snapshotHandle = getSnapshot(nativeHandle_);
if (snapshotHandle != 0) {
return new Snapshot(snapshotHandle);
}
return null;
}
代码示例来源:origin: org.apache.flink/flink-statebackend-rocksdb
@Nonnull
@Override
public RunnableFuture<SnapshotResult<KeyedStateHandle>> doSnapshot(
long checkpointId,
long timestamp,
@Nonnull CheckpointStreamFactory primaryStreamFactory,
@Nonnull CheckpointOptions checkpointOptions) throws Exception {
final SupplierWithException<CheckpointStreamWithResultProvider, Exception> checkpointStreamSupplier =
createCheckpointStreamSupplier(checkpointId, primaryStreamFactory, checkpointOptions);
final List<StateMetaInfoSnapshot> stateMetaInfoSnapshots = new ArrayList<>(kvStateInformation.size());
final List<Tuple2<ColumnFamilyHandle, RegisteredStateMetaInfoBase>> metaDataCopy =
new ArrayList<>(kvStateInformation.size());
for (Tuple2<ColumnFamilyHandle, RegisteredStateMetaInfoBase> tuple2 : kvStateInformation.values()) {
// snapshot meta info
stateMetaInfoSnapshots.add(tuple2.f1.snapshot());
metaDataCopy.add(tuple2);
}
final ResourceGuard.Lease lease = rocksDBResourceGuard.acquireResource();
final Snapshot snapshot = db.getSnapshot();
final SnapshotAsynchronousPartCallable asyncSnapshotCallable =
new SnapshotAsynchronousPartCallable(
checkpointStreamSupplier,
lease,
snapshot,
stateMetaInfoSnapshots,
metaDataCopy,
primaryStreamFactory.toString());
return asyncSnapshotCallable.toAsyncSnapshotFutureTask(cancelStreamRegistry);
}
代码示例来源:origin: org.apache.flink/flink-statebackend-rocksdb_2.11
@Nonnull
@Override
public RunnableFuture<SnapshotResult<KeyedStateHandle>> doSnapshot(
long checkpointId,
long timestamp,
@Nonnull CheckpointStreamFactory primaryStreamFactory,
@Nonnull CheckpointOptions checkpointOptions) throws Exception {
final SupplierWithException<CheckpointStreamWithResultProvider, Exception> checkpointStreamSupplier =
createCheckpointStreamSupplier(checkpointId, primaryStreamFactory, checkpointOptions);
final List<StateMetaInfoSnapshot> stateMetaInfoSnapshots = new ArrayList<>(kvStateInformation.size());
final List<Tuple2<ColumnFamilyHandle, RegisteredStateMetaInfoBase>> metaDataCopy =
new ArrayList<>(kvStateInformation.size());
for (Tuple2<ColumnFamilyHandle, RegisteredStateMetaInfoBase> tuple2 : kvStateInformation.values()) {
// snapshot meta info
stateMetaInfoSnapshots.add(tuple2.f1.snapshot());
metaDataCopy.add(tuple2);
}
final ResourceGuard.Lease lease = rocksDBResourceGuard.acquireResource();
final Snapshot snapshot = db.getSnapshot();
final SnapshotAsynchronousPartCallable asyncSnapshotCallable =
new SnapshotAsynchronousPartCallable(
checkpointStreamSupplier,
lease,
snapshot,
stateMetaInfoSnapshots,
metaDataCopy,
primaryStreamFactory.toString());
return asyncSnapshotCallable.toAsyncSnapshotFutureTask(cancelStreamRegistry);
}
代码示例来源:origin: org.apache.flink/flink-statebackend-rocksdb_2.11
AbstractRocksDBState<?, ?, SV, S> rocksDBState = (AbstractRocksDBState<?, ?, SV, S>) state;
Snapshot rocksDBSnapshot = db.getSnapshot();
try (
RocksIteratorWrapper iterator = getRocksIterator(db, stateMetaInfo.f0);
代码示例来源:origin: org.apache.flink/flink-statebackend-rocksdb
AbstractRocksDBState<?, ?, SV, S> rocksDBState = (AbstractRocksDBState<?, ?, SV, S>) state;
Snapshot rocksDBSnapshot = db.getSnapshot();
try (
RocksIteratorWrapper iterator = getRocksIterator(db, stateMetaInfo.f0);
内容来源于网络,如有侵权,请联系作者删除!