use of org.rocksdb.IngestExternalFileOptions in project sofa-jraft by sofastack.
the class RocksRawKVStore method ingestSstFiles.
void ingestSstFiles(final EnumMap<SstColumnFamily, File> sstFileTable) {
final Timer.Context timeCtx = getTimeContext("INGEST_SST_FILE");
final Lock readLock = this.readWriteLock.readLock();
readLock.lock();
try {
for (final Map.Entry<SstColumnFamily, File> entry : sstFileTable.entrySet()) {
final SstColumnFamily sstColumnFamily = entry.getKey();
final File sstFile = entry.getValue();
final ColumnFamilyHandle columnFamilyHandle = findColumnFamilyHandle(sstColumnFamily);
try (final IngestExternalFileOptions ingestOptions = new IngestExternalFileOptions()) {
if (FileUtils.sizeOf(sstFile) == 0L) {
return;
}
final String filePath = sstFile.getAbsolutePath();
LOG.info("Start ingest sst file {}.", filePath);
this.db.ingestExternalFile(columnFamilyHandle, Collections.singletonList(filePath), ingestOptions);
} catch (final RocksDBException e) {
throw new StorageException("Fail to ingest sst file at path: " + sstFile, e);
}
}
} finally {
readLock.unlock();
timeCtx.stop();
}
}
use of org.rocksdb.IngestExternalFileOptions in project ignite-3 by apache.
the class RocksDbKeyValueStorage method restoreSnapshot.
/**
* {@inheritDoc}
*/
@Override
public void restoreSnapshot(Path path) {
rwLock.writeLock().lock();
try (IngestExternalFileOptions ingestOptions = new IngestExternalFileOptions()) {
for (ColumnFamily family : Arrays.asList(data, index)) {
Path snapshotPath = path.resolve(family.name());
if (!Files.exists(snapshotPath)) {
throw new IgniteInternalException("Snapshot not found: " + snapshotPath);
}
family.ingestExternalFile(Collections.singletonList(snapshotPath.toString()), ingestOptions);
}
rev = bytesToLong(data.get(REVISION_KEY));
updCntr = bytesToLong(data.get(UPDATE_COUNTER_KEY));
} catch (RocksDBException e) {
throw new IgniteInternalException("Fail to ingest sst file at path: " + path, e);
} finally {
rwLock.writeLock().unlock();
}
}
use of org.rocksdb.IngestExternalFileOptions in project ignite-3 by apache.
the class RocksDbPartitionStorage method restoreSnapshot.
/**
* {@inheritDoc}
*/
@Override
public void restoreSnapshot(Path path) {
try (IngestExternalFileOptions ingestOptions = new IngestExternalFileOptions()) {
Path snapshotPath = path.resolve(data.name());
if (!Files.exists(snapshotPath)) {
throw new IgniteInternalException("Snapshot not found: " + snapshotPath);
}
data.ingestExternalFile(Collections.singletonList(snapshotPath.toString()), ingestOptions);
} catch (RocksDBException e) {
throw new IgniteInternalException("Fail to ingest sst file at path: " + path, e);
}
}
use of org.rocksdb.IngestExternalFileOptions in project dingo by dingodb.
the class RocksRawKVStore method ingestSstFiles.
void ingestSstFiles(final EnumMap<SstColumnFamily, File> sstFileTable) {
final Timer.Context timeCtx = getTimeContext("INGEST_SST_FILE");
final Lock readLock = this.readWriteLock.readLock();
readLock.lock();
try {
for (final Map.Entry<SstColumnFamily, File> entry : sstFileTable.entrySet()) {
final SstColumnFamily sstColumnFamily = entry.getKey();
final File sstFile = entry.getValue();
final ColumnFamilyHandle columnFamilyHandle = findColumnFamilyHandle(sstColumnFamily);
try (final IngestExternalFileOptions ingestOptions = new IngestExternalFileOptions()) {
if (FileUtils.sizeOf(sstFile) == 0L) {
return;
}
final String filePath = sstFile.getAbsolutePath();
LOG.info("Start ingest sst file {}.", filePath);
this.db.ingestExternalFile(columnFamilyHandle, Collections.singletonList(filePath), ingestOptions);
} catch (final RocksDBException e) {
throw new StorageException("Fail to ingest sst file at path: " + sstFile, e);
}
}
} finally {
readLock.unlock();
timeCtx.stop();
}
}
Aggregations