]> git.proxmox.com Git - ceph.git/blame - ceph/src/rocksdb/java/src/main/java/org/rocksdb/Checkpoint.java
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / rocksdb / java / src / main / java / org / rocksdb / Checkpoint.java
CommitLineData
7c673cae 1// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
11fdf7f2
TL
2// This source code is licensed under both the GPLv2 (found in the
3// COPYING file in the root directory) and Apache 2.0 License
4// (found in the LICENSE.Apache file in the root directory).
7c673cae
FG
5
6package org.rocksdb;
7
8/**
9 * Provides Checkpoint functionality. Checkpoints
10 * provide persistent snapshots of RocksDB databases.
11 */
12public class Checkpoint extends RocksObject {
13
14 /**
15 * Creates a Checkpoint object to be used for creating open-able
16 * snapshots.
17 *
18 * @param db {@link RocksDB} instance.
19 * @return a Checkpoint instance.
20 *
21 * @throws java.lang.IllegalArgumentException if {@link RocksDB}
22 * instance is null.
23 * @throws java.lang.IllegalStateException if {@link RocksDB}
24 * instance is not initialized.
25 */
26 public static Checkpoint create(final RocksDB db) {
27 if (db == null) {
28 throw new IllegalArgumentException(
29 "RocksDB instance shall not be null.");
30 } else if (!db.isOwningHandle()) {
31 throw new IllegalStateException(
32 "RocksDB instance must be initialized.");
33 }
34 Checkpoint checkpoint = new Checkpoint(db);
35 return checkpoint;
36 }
37
38 /**
39 * <p>Builds an open-able snapshot of RocksDB on the same disk, which
40 * accepts an output directory on the same disk, and under the directory
41 * (1) hard-linked SST files pointing to existing live SST files
42 * (2) a copied manifest files and other files</p>
43 *
44 * @param checkpointPath path to the folder where the snapshot is going
45 * to be stored.
46 * @throws RocksDBException thrown if an error occurs within the native
47 * part of the library.
48 */
49 public void createCheckpoint(final String checkpointPath)
50 throws RocksDBException {
51 createCheckpoint(nativeHandle_, checkpointPath);
52 }
53
54 private Checkpoint(final RocksDB db) {
55 super(newCheckpoint(db.nativeHandle_));
56 this.db_ = db;
57 }
58
59 private final RocksDB db_;
60
61 private static native long newCheckpoint(long dbHandle);
62 @Override protected final native void disposeInternal(final long handle);
63
64 private native void createCheckpoint(long handle, String checkpointPath)
65 throws RocksDBException;
66}