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.
7 import org
.junit
.ClassRule
;
10 import org
.junit
.rules
.TemporaryFolder
;
12 import static org
.assertj
.core
.api
.Assertions
.assertThat
;
14 public class FlushTest
{
17 public static final RocksMemoryResource rocksMemoryResource
=
18 new RocksMemoryResource();
21 public TemporaryFolder dbFolder
= new TemporaryFolder();
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()
31 final FlushOptions flushOptions
= new FlushOptions()
32 .setWaitForFlush(true)) {
33 assertThat(flushOptions
.waitForFlush()).isTrue();
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"))
43 db
.flush(flushOptions
);
44 assertThat(db
.getProperty("rocksdb.num-entries-active-mem-table"))