]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/java/src/main/java/org/rocksdb/PrepopulateBlobCache.java
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / rocksdb / java / src / main / java / org / rocksdb / PrepopulateBlobCache.java
1 // Copyright (c) Meta Platforms, Inc. and affiliates.
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).
5
6 package org.rocksdb;
7
8 /**
9 * Enum PrepopulateBlobCache
10 *
11 * <p>Prepopulate warm/hot blobs which are already in memory into blob
12 * cache at the time of flush. On a flush, the blob that is in memory
13 * (in memtables) get flushed to the device. If using Direct IO,
14 * additional IO is incurred to read this blob back into memory again,
15 * which is avoided by enabling this option. This further helps if the
16 * workload exhibits high temporal locality, where most of the reads go
17 * to recently written data. This also helps in case of the remote file
18 * system since it involves network traffic and higher latencies.</p>
19 */
20 public enum PrepopulateBlobCache {
21 PREPOPULATE_BLOB_DISABLE((byte) 0x0, "prepopulate_blob_disable", "kDisable"),
22 PREPOPULATE_BLOB_FLUSH_ONLY((byte) 0x1, "prepopulate_blob_flush_only", "kFlushOnly");
23
24 /**
25 * <p>Get the PrepopulateBlobCache enumeration value by
26 * passing the library name to this method.</p>
27 *
28 * <p>If library cannot be found the enumeration
29 * value {@code PREPOPULATE_BLOB_DISABLE} will be returned.</p>
30 *
31 * @param libraryName prepopulate blob cache library name.
32 *
33 * @return PrepopulateBlobCache instance.
34 */
35 public static PrepopulateBlobCache getPrepopulateBlobCache(String libraryName) {
36 if (libraryName != null) {
37 for (PrepopulateBlobCache prepopulateBlobCache : PrepopulateBlobCache.values()) {
38 if (prepopulateBlobCache.getLibraryName() != null
39 && prepopulateBlobCache.getLibraryName().equals(libraryName)) {
40 return prepopulateBlobCache;
41 }
42 }
43 }
44 return PrepopulateBlobCache.PREPOPULATE_BLOB_DISABLE;
45 }
46
47 /**
48 * <p>Get the PrepopulateBlobCache enumeration value by
49 * passing the byte identifier to this method.</p>
50 *
51 * @param byteIdentifier of PrepopulateBlobCache.
52 *
53 * @return PrepopulateBlobCache instance.
54 *
55 * @throws IllegalArgumentException If PrepopulateBlobCache cannot be found for the
56 * provided byteIdentifier
57 */
58 public static PrepopulateBlobCache getPrepopulateBlobCache(byte byteIdentifier) {
59 for (final PrepopulateBlobCache prepopulateBlobCache : PrepopulateBlobCache.values()) {
60 if (prepopulateBlobCache.getValue() == byteIdentifier) {
61 return prepopulateBlobCache;
62 }
63 }
64
65 throw new IllegalArgumentException("Illegal value provided for PrepopulateBlobCache.");
66 }
67
68 /**
69 * <p>Get a PrepopulateBlobCache value based on the string key in the C++ options output.
70 * This gets used in support of getting options into Java from an options string,
71 * which is generated at the C++ level.
72 * </p>
73 *
74 * @param internalName the internal (C++) name by which the option is known.
75 *
76 * @return PrepopulateBlobCache instance (optional)
77 */
78 static PrepopulateBlobCache getFromInternal(final String internalName) {
79 for (final PrepopulateBlobCache prepopulateBlobCache : PrepopulateBlobCache.values()) {
80 if (prepopulateBlobCache.internalName_.equals(internalName)) {
81 return prepopulateBlobCache;
82 }
83 }
84
85 throw new IllegalArgumentException(
86 "Illegal internalName '" + internalName + " ' provided for PrepopulateBlobCache.");
87 }
88
89 /**
90 * <p>Returns the byte value of the enumerations value.</p>
91 *
92 * @return byte representation
93 */
94 public byte getValue() {
95 return value_;
96 }
97
98 /**
99 * <p>Returns the library name of the prepopulate blob cache mode
100 * identified by the enumeration value.</p>
101 *
102 * @return library name
103 */
104 public String getLibraryName() {
105 return libraryName_;
106 }
107
108 PrepopulateBlobCache(final byte value, final String libraryName, final String internalName) {
109 value_ = value;
110 libraryName_ = libraryName;
111 internalName_ = internalName;
112 }
113
114 private final byte value_;
115 private final String libraryName_;
116 private final String internalName_;
117 }