]>
Commit | Line | Data |
---|---|---|
20effc67 TL |
1 | // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. |
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 | public enum FlushReason { | |
9 | OTHERS((byte) 0x00), | |
10 | GET_LIVE_FILES((byte) 0x01), | |
11 | SHUTDOWN((byte) 0x02), | |
12 | EXTERNAL_FILE_INGESTION((byte) 0x03), | |
13 | MANUAL_COMPACTION((byte) 0x04), | |
14 | WRITE_BUFFER_MANAGER((byte) 0x05), | |
15 | WRITE_BUFFER_FULL((byte) 0x06), | |
16 | TEST((byte) 0x07), | |
17 | DELETE_FILES((byte) 0x08), | |
18 | AUTO_COMPACTION((byte) 0x09), | |
19 | MANUAL_FLUSH((byte) 0x0a), | |
20 | ERROR_RECOVERY((byte) 0xb); | |
21 | ||
22 | private final byte value; | |
23 | ||
24 | FlushReason(final byte value) { | |
25 | this.value = value; | |
26 | } | |
27 | ||
28 | /** | |
29 | * Get the internal representation. | |
30 | * | |
31 | * @return the internal representation | |
32 | */ | |
33 | byte getValue() { | |
34 | return value; | |
35 | } | |
36 | ||
37 | /** | |
38 | * Get the FlushReason from the internal representation value. | |
39 | * | |
40 | * @return the flush reason. | |
41 | * | |
42 | * @throws IllegalArgumentException if the value is unknown. | |
43 | */ | |
44 | static FlushReason fromValue(final byte value) { | |
45 | for (final FlushReason flushReason : FlushReason.values()) { | |
46 | if (flushReason.value == value) { | |
47 | return flushReason; | |
48 | } | |
49 | } | |
50 | ||
51 | throw new IllegalArgumentException("Illegal value provided for FlushReason: " + value); | |
52 | } | |
53 | } |