mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-26 16:30:56 +00:00
[RocksJava] Addressed comments in D28971
This commit is contained in:
parent
fcc2dfd9f9
commit
f193deea31
|
@ -51,7 +51,7 @@ endif
|
|||
JAVA_TESTS = org.rocksdb.test.BackupableDBOptionsTest\
|
||||
org.rocksdb.test.BackupableDBTest\
|
||||
org.rocksdb.test.BlockBasedTableConfigTest\
|
||||
org.rocksdb.test.CheckpointTest\
|
||||
org.rocksdb.test.CheckPointTest\
|
||||
org.rocksdb.test.ColumnFamilyOptionsTest\
|
||||
org.rocksdb.test.ColumnFamilyTest\
|
||||
org.rocksdb.test.ComparatorOptionsTest\
|
||||
|
|
|
@ -17,15 +17,21 @@ public class Checkpoint extends RocksObject {
|
|||
*
|
||||
* @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(RocksDB db) {
|
||||
if (db == null || !db.isInitialized()) {
|
||||
if (db == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"RocksDB instance needs to be initialized.");
|
||||
"RocksDB instance shall not be null.");
|
||||
} else if (!db.isInitialized()) {
|
||||
throw new IllegalStateException(
|
||||
"RocksDB instance must be initialized.");
|
||||
}
|
||||
Checkpoint checkpoint = new Checkpoint(
|
||||
newCheckpoint(db.nativeHandle_));
|
||||
checkpoint.db_ = db;
|
||||
Checkpoint checkpoint = new Checkpoint(db);
|
||||
return checkpoint;
|
||||
}
|
||||
|
||||
|
@ -50,9 +56,10 @@ public class Checkpoint extends RocksObject {
|
|||
disposeInternal(nativeHandle_);
|
||||
}
|
||||
|
||||
private Checkpoint(long handle) {
|
||||
private Checkpoint(RocksDB db) {
|
||||
super();
|
||||
nativeHandle_ = handle;
|
||||
nativeHandle_ = newCheckpoint(db.nativeHandle_);
|
||||
db_ = db;
|
||||
}
|
||||
|
||||
RocksDB db_;
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.rocksdb.RocksDBException;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class CheckpointTest {
|
||||
public class CheckPointTest {
|
||||
|
||||
@ClassRule
|
||||
public static final RocksMemoryResource rocksMemoryResource =
|
||||
|
@ -74,7 +74,7 @@ public class CheckpointTest {
|
|||
Checkpoint.create(null);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void failIfDbNotInitialized() throws RocksDBException {
|
||||
RocksDB db = RocksDB.open(dbFolder.getRoot().getAbsolutePath());
|
||||
db.dispose();
|
||||
|
|
|
@ -58,4 +58,4 @@ void Java_org_rocksdb_Checkpoint_createCheckpoint(
|
|||
if (!s.ok()) {
|
||||
rocksdb::RocksDBExceptionJni::ThrowNew(env, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue