本文整理汇总了Java中org.rocksdb.Checkpoint类的典型用法代码示例。如果您正苦于以下问题:Java Checkpoint类的具体用法?Java Checkpoint怎么用?Java Checkpoint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Checkpoint类属于org.rocksdb包,在下文中一共展示了Checkpoint类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkpoint
import org.rocksdb.Checkpoint; //导入依赖的package包/类
/**
* Flush the data in memtable of RocksDB into disk, and then create checkpoint
*
* @param batchId
*/
@Override
public void checkpoint(long batchId) {
long startTime = System.currentTimeMillis();
try {
rocksDb.flush(new FlushOptions());
Checkpoint cp = Checkpoint.create(rocksDb);
cp.createCheckpoint(getLocalCheckpointPath(batchId));
} catch (RocksDBException e) {
LOG.error("Failed to create checkpoint for batch-" + batchId, e);
throw new RuntimeException(e.getMessage());
}
if (JStormMetrics.enabled)
rocksDbFlushAndCpLatency.update(System.currentTimeMillis() - startTime);
}
示例2: takeSnapshot
import org.rocksdb.Checkpoint; //导入依赖的package包/类
void takeSnapshot() throws Exception {
final long lastCompletedCheckpoint;
// use the last completed checkpoint as the comparison base.
synchronized (stateBackend.materializedSstFiles) {
lastCompletedCheckpoint = stateBackend.lastCompletedCheckpointId;
baseSstFiles = stateBackend.materializedSstFiles.get(lastCompletedCheckpoint);
}
LOG.trace("Taking incremental snapshot for checkpoint {}. Snapshot is based on last completed checkpoint {} " +
"assuming the following (shared) files as base: {}.", checkpointId, lastCompletedCheckpoint, baseSstFiles);
// save meta data
for (Map.Entry<String, Tuple2<ColumnFamilyHandle, RegisteredKeyedBackendStateMetaInfo<?, ?>>> stateMetaInfoEntry
: stateBackend.kvStateInformation.entrySet()) {
stateMetaInfoSnapshots.add(stateMetaInfoEntry.getValue().f1.snapshot());
}
// save state data
backupPath = new Path(stateBackend.instanceBasePath.getAbsolutePath(), "chk-" + checkpointId);
LOG.trace("Local RocksDB checkpoint goes to backup path {}.", backupPath);
backupFileSystem = backupPath.getFileSystem();
if (backupFileSystem.exists(backupPath)) {
throw new IllegalStateException("Unexpected existence of the backup directory.");
}
// create hard links of living files in the checkpoint path
Checkpoint checkpoint = Checkpoint.create(stateBackend.db);
checkpoint.createCheckpoint(backupPath.getPath());
}
示例3: rocksDbTest
import org.rocksdb.Checkpoint; //导入依赖的package包/类
private static void rocksDbTest(RocksDB db, List<ColumnFamilyHandle> handlers) {
try {
ColumnFamilyHandle handler1 = null;
ColumnFamilyHandle handler2 = null;
if (handlers.size() > 0) {
// skip default column family
handler1 = handlers.get(1);
handler2 = handlers.get(2);
} else {
handler1 = db.createColumnFamily(new ColumnFamilyDescriptor("test1".getBytes()));
handler2 = db.createColumnFamily(new ColumnFamilyDescriptor("test2".getBytes()));
}
int startValue1 = getStartValue(db, handler1);
int startValue2 = getStartValue(db, handler2);;
Checkpoint cp = Checkpoint.create(db);
if (isCompaction) {
db.compactRange();
LOG.info("Compaction!");
}
long flushWaitTime = System.currentTimeMillis() + flushInterval;
for (int i = 0; i < putNum || putNum == -1; i++) {
db.put(handler1, String.valueOf(i % 1000).getBytes(), String.valueOf(startValue1 + i).getBytes());
db.put(handler2, String.valueOf(i % 1000).getBytes(), String.valueOf(startValue2 + i).getBytes());
if (isFlush && flushWaitTime <= System.currentTimeMillis()) {
db.flush(new FlushOptions());
if (isCheckpoint) {
cp.createCheckpoint(cpPath + "/" + i);
}
flushWaitTime = System.currentTimeMillis() + flushInterval;
}
}
} catch (RocksDBException e) {
LOG.error("Failed to put or flush", e);
}
}