]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/java/src/test/java/org/rocksdb/FlushTest.java
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / rocksdb / java / src / test / java / org / rocksdb / FlushTest.java
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under the BSD-style license found in the
3 // LICENSE file in the root directory of this source tree. An additional grant
4 // of patent rights can be found in the PATENTS file in the same directory.
5 package org.rocksdb;
6
7 import org.junit.ClassRule;
8 import org.junit.Rule;
9 import org.junit.Test;
10 import org.junit.rules.TemporaryFolder;
11
12 import static org.assertj.core.api.Assertions.assertThat;
13
14 public class FlushTest {
15
16 @ClassRule
17 public static final RocksMemoryResource rocksMemoryResource =
18 new RocksMemoryResource();
19
20 @Rule
21 public TemporaryFolder dbFolder = new TemporaryFolder();
22
23 @Test
24 public void flush() throws RocksDBException {
25 try(final Options options = new Options()
26 .setCreateIfMissing(true)
27 .setMaxWriteBufferNumber(10)
28 .setMinWriteBufferNumberToMerge(10);
29 final WriteOptions wOpt = new WriteOptions()
30 .setDisableWAL(true);
31 final FlushOptions flushOptions = new FlushOptions()
32 .setWaitForFlush(true)) {
33 assertThat(flushOptions.waitForFlush()).isTrue();
34
35 try(final RocksDB db = RocksDB.open(options,
36 dbFolder.getRoot().getAbsolutePath())) {
37 db.put(wOpt, "key1".getBytes(), "value1".getBytes());
38 db.put(wOpt, "key2".getBytes(), "value2".getBytes());
39 db.put(wOpt, "key3".getBytes(), "value3".getBytes());
40 db.put(wOpt, "key4".getBytes(), "value4".getBytes());
41 assertThat(db.getProperty("rocksdb.num-entries-active-mem-table"))
42 .isEqualTo("4");
43 db.flush(flushOptions);
44 assertThat(db.getProperty("rocksdb.num-entries-active-mem-table"))
45 .isEqualTo("0");
46 }
47 }
48 }
49 }