All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.rocksdb.RestoreBackupableDB Maven / Gradle / Ivy

Go to download

RocksDB fat jar to use with Apache Flink that contains .so files for linux32 and linux64, jnilib files for Mac OSX, and a .dll for Windows x64.

There is a newer version: 5.17.2-artisans-2.0
Show newest version
// Copyright (c) 2011-present, Facebook, Inc.  All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.

package org.rocksdb;

import java.util.List;

/**
 * 

This class is used to access information about backups and * restore from them.

* *

Note: {@code dispose()} must be called before this instance * become out-of-scope to release the allocated * memory in c++.

* */ public class RestoreBackupableDB extends RocksObject { /** *

Construct new estoreBackupableDB instance.

* * @param options {@link org.rocksdb.BackupableDBOptions} instance */ public RestoreBackupableDB(final BackupableDBOptions options) { super(newRestoreBackupableDB(options.nativeHandle_)); } /** *

Restore from backup with backup_id.

* *

Important: If options_.share_table_files == true * and you restore DB from some backup that is not the latest, and you * start creating new backups from the new DB, they will probably * fail.

* *

Example: Let's say you have backups 1, 2, 3, 4, 5 * and you restore 3. If you add new data to the DB and try creating a new * backup now, the database will diverge from backups 4 and 5 and the new * backup will fail. If you want to create new backup, you will first have * to delete backups 4 and 5.

* * @param backupId id pointing to backup * @param dbDir database directory to restore to * @param walDir directory where wal files are located * @param restoreOptions {@link org.rocksdb.RestoreOptions} instance. * * @throws RocksDBException thrown if error happens in underlying * native library. */ public void restoreDBFromBackup(final long backupId, final String dbDir, final String walDir, final RestoreOptions restoreOptions) throws RocksDBException { assert(isOwningHandle()); restoreDBFromBackup0(nativeHandle_, backupId, dbDir, walDir, restoreOptions.nativeHandle_); } /** *

Restore from the latest backup.

* * @param dbDir database directory to restore to * @param walDir directory where wal files are located * @param restoreOptions {@link org.rocksdb.RestoreOptions} instance * * @throws RocksDBException thrown if error happens in underlying * native library. */ public void restoreDBFromLatestBackup(final String dbDir, final String walDir, final RestoreOptions restoreOptions) throws RocksDBException { assert(isOwningHandle()); restoreDBFromLatestBackup0(nativeHandle_, dbDir, walDir, restoreOptions.nativeHandle_); } /** *

Deletes old backups, keeping latest numBackupsToKeep alive.

* * @param numBackupsToKeep of latest backups to keep * * @throws RocksDBException thrown if error happens in underlying * native library. */ public void purgeOldBackups(final int numBackupsToKeep) throws RocksDBException { assert(isOwningHandle()); purgeOldBackups0(nativeHandle_, numBackupsToKeep); } /** *

Deletes a specific backup.

* * @param backupId of backup to delete. * * @throws RocksDBException thrown if error happens in underlying * native library. */ public void deleteBackup(final int backupId) throws RocksDBException { assert(isOwningHandle()); deleteBackup0(nativeHandle_, backupId); } /** *

Returns a list of {@link BackupInfo} instances, which describe * already made backups.

* * @return List of {@link BackupInfo} instances. */ public List getBackupInfos() { assert(isOwningHandle()); return getBackupInfo(nativeHandle_); } /** *

Returns a list of corrupted backup ids. If there * is no corrupted backup the method will return an * empty list.

* * @return array of backup ids as int ids. */ public int[] getCorruptedBackups() { assert(isOwningHandle()); return getCorruptedBackups(nativeHandle_); } /** *

Will delete all the files we don't need anymore. It will * do the full scan of the files/ directory and delete all the * files that are not referenced.

* * @throws RocksDBException thrown if error happens in underlying * native library. */ public void garbageCollect() throws RocksDBException { assert(isOwningHandle()); garbageCollect(nativeHandle_); } private native static long newRestoreBackupableDB(final long options); private native void restoreDBFromBackup0(long nativeHandle, long backupId, String dbDir, String walDir, long restoreOptions) throws RocksDBException; private native void restoreDBFromLatestBackup0(long nativeHandle, String dbDir, String walDir, long restoreOptions) throws RocksDBException; private native void purgeOldBackups0(long nativeHandle, int numBackupsToKeep) throws RocksDBException; private native void deleteBackup0(long nativeHandle, int backupId) throws RocksDBException; private native List getBackupInfo(long handle); private native int[] getCorruptedBackups(long handle); private native void garbageCollect(long handle) throws RocksDBException; @Override protected final native void disposeInternal( final long nativeHandle); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy