]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/java/src/main/java/org/rocksdb/Env.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.
9 * Base class for all Env implementations in RocksDB.
11 public abstract class Env
extends RocksObject
{
12 public static final int FLUSH_POOL
= 0;
13 public static final int COMPACTION_POOL
= 1;
16 * <p>Returns the default environment suitable for the current operating
19 * <p>The result of {@code getDefault()} is a singleton whose ownership
20 * belongs to rocksdb c++. As a result, the returned RocksEnv will not
21 * have the ownership of its c++ resource, and calling its dispose()
24 * @return the default {@link org.rocksdb.RocksEnv} instance.
26 public static Env
getDefault() {
31 * <p>Sets the number of background worker threads of the flush pool
32 * for this environment.</p>
33 * <p>Default number: 1</p>
35 * @param num the number of threads
37 * @return current {@link RocksEnv} instance.
39 public Env
setBackgroundThreads(final int num
) {
40 return setBackgroundThreads(num
, FLUSH_POOL
);
44 * <p>Sets the number of background worker threads of the specified thread
45 * pool for this environment.</p>
47 * @param num the number of threads
48 * @param poolID the id to specified a thread pool. Should be either
49 * FLUSH_POOL or COMPACTION_POOL.
51 * <p>Default number: 1</p>
52 * @return current {@link RocksEnv} instance.
54 public Env
setBackgroundThreads(final int num
, final int poolID
) {
55 setBackgroundThreads(nativeHandle_
, num
, poolID
);
60 * <p>Returns the length of the queue associated with the specified
63 * @param poolID the id to specified a thread pool. Should be either
64 * FLUSH_POOL or COMPACTION_POOL.
66 * @return the thread pool queue length.
68 public int getThreadPoolQueueLen(final int poolID
) {
69 return getThreadPoolQueueLen(nativeHandle_
, poolID
);
73 protected Env(final long nativeHandle
) {
78 default_env_
= new RocksEnv(getDefaultEnvInternal());
82 * <p>The static default Env. The ownership of its native handle
83 * belongs to rocksdb c++ and is not able to be released on the Java
86 static Env default_env_
;
88 private static native long getDefaultEnvInternal();
89 private native void setBackgroundThreads(
90 long handle
, int num
, int priority
);
91 private native int getThreadPoolQueueLen(long handle
, int poolID
);