private void takeDBNativeCheckpoint(@Nonnull SnapshotDirectory outputDirectory) throws Exception { // create hard links of living files in the output path try ( ResourceGuard.Lease ignored = rocksDBResourceGuard.acquireResource(); Checkpoint checkpoint = Checkpoint.create(db)) { checkpoint.createCheckpoint(outputDirectory.getDirectory().getPath()); } catch (Exception ex) { try { outputDirectory.cleanup(); } catch (IOException cleanupEx) { ex = ExceptionUtils.firstOrSuppressed(cleanupEx, ex); } throw ex; } }
/** * <p>Builds an open-able snapshot of RocksDB on the same disk, which * accepts an output directory on the same disk, and under the directory * (1) hard-linked SST files pointing to existing live SST files * (2) a copied manifest files and other files</p> * * @param checkpointPath path to the folder where the snapshot is going * to be stored. * @throws RocksDBException thrown if an error occurs within the native * part of the library. */ public void createCheckpoint(final String checkpointPath) throws RocksDBException { createCheckpoint(nativeHandle_, checkpointPath); }
public RocksCheckpointer(String dbName, File dbPath, RocksDB rocksDB, CheckpointStore checkpointStore, boolean removeLocalCheckpointAfterSuccessfulCheckpoint, boolean removeRemoteCheckpointsAfterSuccessfulCheckpoint) { this.dbName = dbName; this.dbPath = dbPath; this.checkpoint = Checkpoint.create(rocksDB); this.checkpointStore = checkpointStore; this.removeLocalCheckpointAfterSuccessfulCheckpoint = removeLocalCheckpointAfterSuccessfulCheckpoint; this.removeRemoteCheckpointsAfterSuccessfulCheckpoint = removeRemoteCheckpointsAfterSuccessfulCheckpoint; }
private Checkpoint(final RocksDB db) { super(newCheckpoint(db.nativeHandle_)); this.db_ = db; }
/** * Creates a Checkpoint object to be used for creating open-able * snapshots. * * @param db {@link RocksDB} instance. * @return a Checkpoint instance. * * @throws java.lang.IllegalArgumentException if {@link RocksDB} * instance is null. * @throws java.lang.IllegalStateException if {@link RocksDB} * instance is not initialized. */ public static Checkpoint create(final RocksDB db) { if (db == null) { throw new IllegalArgumentException( "RocksDB instance shall not be null."); } else if (!db.isOwningHandle()) { throw new IllegalStateException( "RocksDB instance must be initialized."); } Checkpoint checkpoint = new Checkpoint(db); return checkpoint; }
try { try { checkpoint.createCheckpoint(tempDir.getAbsolutePath()); } catch (RocksDBException e) { throw new StateStoreException("Failed to create a checkpoint at " + tempDir, e);
/** * 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); }
int startValue2 = getStartValue(db, handler2);; Checkpoint cp = Checkpoint.create(db); db.flush(new FlushOptions()); if (isCheckpoint) { cp.createCheckpoint(cpPath + "/" + i);
@Override public void createSnapshot(File snapshotDir) { try (Checkpoint checkpoint = Checkpoint.create(this)) { try { checkpoint.createCheckpoint(snapshotDir.getAbsolutePath()); } catch (RocksDBException rocksException) { throw new RuntimeException(rocksException); } } }
@Override public void writeSnapshot(String snapshotDir) { Checkpoint checkpoint = Checkpoint.create(db); try { checkpoint.createCheckpoint(snapshotDir); } catch (Exception ex) { ex.printStackTrace(); LOG.warn("writeSnapshot meet exception, dir={}, msg={}", snapshotDir, ex.getMessage()); } }
void takeSnapshot() throws Exception { assert (Thread.holdsLock(stateBackend.asyncSnapshotLock)); 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); 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()); }
private void takeDBNativeCheckpoint(@Nonnull SnapshotDirectory outputDirectory) throws Exception { // create hard links of living files in the output path try ( ResourceGuard.Lease ignored = rocksDBResourceGuard.acquireResource(); Checkpoint checkpoint = Checkpoint.create(db)) { checkpoint.createCheckpoint(outputDirectory.getDirectory().getPath()); } catch (Exception ex) { try { outputDirectory.cleanup(); } catch (IOException cleanupEx) { ex = ExceptionUtils.firstOrSuppressed(cleanupEx, ex); } throw ex; } }
private void takeDBNativeCheckpoint(@Nonnull SnapshotDirectory outputDirectory) throws Exception { // create hard links of living files in the output path try ( ResourceGuard.Lease ignored = rocksDBResourceGuard.acquireResource(); Checkpoint checkpoint = Checkpoint.create(db)) { checkpoint.createCheckpoint(outputDirectory.getDirectory().getPath()); } catch (Exception ex) { try { outputDirectory.cleanup(); } catch (IOException cleanupEx) { ex = ExceptionUtils.firstOrSuppressed(cleanupEx, ex); } throw ex; } }