本文整理了Java中org.rocksdb.RocksDB.flush
方法的一些代码示例,展示了RocksDB.flush
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RocksDB.flush
方法的具体详情如下:
包路径:org.rocksdb.RocksDB
类名称:RocksDB
方法名:flush
[英]Flush all memory table data.
Note: it must be ensured that the FlushOptions instance is not GC'ed before this method finishes. If the wait parameter is set to false, flush processing is asynchronous.
[中]刷新所有内存表数据。
注意:必须确保FlushOptions实例在该方法完成之前没有被GC’ed。如果wait参数设置为false,则刷新处理是异步的。
代码示例来源:origin: alibaba/jstorm
@Override
public void close() {
try {
this.rocksDB.flush(new FlushOptions());
} catch (RocksDBException e) {
LOG.warn("Failed to flush db before cleanup", e);
}
this.rocksDB.dispose();
}
代码示例来源:origin: alibaba/jstorm
public void close() {
try {
this.rocksDB.flush(new FlushOptions());
} catch (RocksDBException e) {
LOG.warn("Failed to flush db before cleanup", e);
}
this.rocksDB.dispose();
}
}
代码示例来源:origin: alibaba/jstorm
/**
* Flush the data in memtable of RocksDB into disk, and then create checkpoint
*
* @param checkpointId
*/
@Override
public void checkpoint(long checkpointId) {
long startTime = System.currentTimeMillis();
try {
rocksDB.flush(new FlushOptions());
Checkpoint cp = Checkpoint.create(rocksDB);
cp.createCheckpoint(getRocksDbCheckpointPath(checkpointId));
} catch (RocksDBException e) {
LOG.error(String.format("Failed to create checkpoint for checkpointId-%d", checkpointId), e);
throw new RuntimeException(e.getMessage());
}
if (isEnableMetrics && JStormMetrics.enabled)
rocksDbFlushAndCpLatency.update(System.currentTimeMillis() - startTime);
}
代码示例来源:origin: alibaba/jstorm
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);
代码示例来源:origin: apache/storm
store.db.flush(flushOps);
} catch (RocksDBException e) {
LOG.error("Failed ot flush RocksDB", e);
代码示例来源:origin: org.rocksdb/rocksdbjni
/**
* <p>Flush all memory table data.</p>
*
* <p>Note: it must be ensured that the FlushOptions instance
* is not GC'ed before this method finishes. If the wait parameter is
* set to false, flush processing is asynchronous.</p>
*
* @param flushOptions {@link org.rocksdb.FlushOptions} instance.
* @throws RocksDBException thrown if an error occurs within the native
* part of the library.
*/
public void flush(final FlushOptions flushOptions)
throws RocksDBException {
flush(nativeHandle_, flushOptions.nativeHandle_);
}
代码示例来源:origin: org.rocksdb/rocksdbjni
/**
* <p>Flush all memory table data.</p>
*
* <p>Note: it must be ensured that the FlushOptions instance
* is not GC'ed before this method finishes. If the wait parameter is
* set to false, flush processing is asynchronous.</p>
*
* @param flushOptions {@link org.rocksdb.FlushOptions} instance.
* @param columnFamilyHandle {@link org.rocksdb.ColumnFamilyHandle} instance.
* @throws RocksDBException thrown if an error occurs within the native
* part of the library.
*/
public void flush(final FlushOptions flushOptions,
final ColumnFamilyHandle columnFamilyHandle) throws RocksDBException {
flush(nativeHandle_, flushOptions.nativeHandle_,
columnFamilyHandle.nativeHandle_);
}
代码示例来源:origin: org.apache.kafka/kafka-streams
/**
* @throws ProcessorStateException if flushing failed because of any internal store exceptions
*/
private void flushInternal() {
try {
db.flush(fOptions);
} catch (final RocksDBException e) {
throw new ProcessorStateException("Error while executing flush from store " + name, e);
}
}
代码示例来源:origin: org.apache.bookkeeper/statelib
@Override
public synchronized void flush() throws StateStoreException {
if (null == db) {
return;
}
try {
db.flush(flushOpts);
} catch (RocksDBException e) {
throw new StateStoreException("Exception on flushing rocksdb from store " + name, e);
}
}
代码示例来源:origin: opendedup/sdfs
@Override
public void sync() throws IOException {
syncLock.lock();
try {
if (this.isClosed()) {
throw new IOException("hashtable [" + this.fileName + "] is close");
}
try {
for (RocksDB db : dbs) {
db.flush(flo);
}
} catch (RocksDBException e) {
throw new IOException(e);
}
} finally {
syncLock.unlock();
}
}
代码示例来源:origin: opendedup/sdfs
@Override
public void sync() throws IOException {
syncLock.lock();
try {
if (this.isClosed()) {
throw new IOException("hashtable [" + this.fileName + "] is close");
}
try {
for (RocksDB db : dbs) {
db.flush(new FlushOptions().setWaitForFlush(true));
}
} catch (RocksDBException e) {
throw new IOException(e);
}
} finally {
syncLock.unlock();
}
}
代码示例来源:origin: jwplayer/southpaw
@Override
public void flush() {
try {
for(Map.Entry<ByteArray, Map<ByteArray, byte[]>> entry: dataBatches.entrySet()) {
WriteBatch writeBatch = new WriteBatch();
WriteOptions writeOptions = new WriteOptions().setDisableWAL(true);
for(Map.Entry<ByteArray, byte[]> batchEntry: entry.getValue().entrySet()) {
writeBatch.put(
cfHandles.get(entry.getKey()),
batchEntry.getKey().getBytes(),
batchEntry.getValue()
);
}
rocksDB.write(writeOptions, writeBatch);
writeBatch.close();
writeOptions.close();
entry.getValue().clear();
}
FlushOptions fOptions = new FlushOptions().setWaitForFlush(true);
rocksDB.flush(fOptions);
fOptions.close();
} catch(RocksDBException ex) {
throw new RuntimeException(ex);
}
}
代码示例来源:origin: actiontech/dble
public void run() {
FlushOptions fo = new FlushOptions();
fo.setWaitForFlush(true);
try {
finalDB.flush(fo);
} catch (RocksDBException e) {
LOGGER.warn("RocksDB flush error", e);
} finally {
finalDB.close();
fo.close();
options.close();
}
}
});
代码示例来源:origin: jwplayer/southpaw
@Override
public void flush(String keySpace) {
Preconditions.checkNotNull(keySpace);
ByteArray byteArray = new ByteArray(keySpace);
try {
WriteBatch writeBatch = new WriteBatch();
WriteOptions writeOptions = new WriteOptions().setDisableWAL(true);
for(Map.Entry<ByteArray, byte[]> entry: dataBatches.get(byteArray).entrySet()) {
writeBatch.put(
cfHandles.get(byteArray),
entry.getKey().getBytes(),
entry.getValue()
);
}
rocksDB.write(writeOptions, writeBatch);
writeBatch.close();
writeOptions.close();
dataBatches.get(byteArray).clear();
FlushOptions fOptions = new FlushOptions().setWaitForFlush(true);
rocksDB.flush(new FlushOptions(), cfHandles.get(byteArray));
fOptions.close();
} catch(RocksDBException ex) {
throw new RuntimeException(ex);
}
}
代码示例来源:origin: opendedup/sdfs
@Override
public void close() {
this.syncLock.lock();
try {
this.closed = true;
CommandLineProgressBar bar = new CommandLineProgressBar("Closing Hash Tables", dbs.length, System.out);
int i = 0;
for (RocksDB db : dbs) {
try {
FlushOptions op = new FlushOptions();
op.setWaitForFlush(true);
db.flush(op);
db.close();
} catch (Exception e) {
SDFSLogger.getLog().warn("While closing hashtable ", e);
}
bar.update(i);
i++;
}
bar.finish();
} finally {
this.syncLock.unlock();
SDFSLogger.getLog().info("Hashtable [" + this.fileName + "] closed");
}
}
代码示例来源:origin: dremio/dremio-oss
@Override
public void close() throws IOException {
if (!closed.compareAndSet(false, true)) {
return;
}
if (COLLECT_METRICS) {
MetricUtils.removeAllMetricsThatStartWith(MetricRegistry.name(METRICS_PREFIX, name));
}
exclusively((deferred) -> {
deleteAllIterators(deferred);
try(FlushOptions options = new FlushOptions()){
options.setWaitForFlush(true);
db.flush(options, handle);
} catch (RocksDBException ex) {
deferred.addException(ex);
}
deferred.suppressingClose(handle);
});
}
内容来源于网络,如有侵权,请联系作者删除!