]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/java/src/main/java/org/rocksdb/Status.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 * Represents the status returned by a function call in RocksDB.
11 * Currently only used with {@link RocksDBException} when the
12 * status is not {@link Code#Ok}
15 private final Code code
;
16 /* @Nullable */ private final SubCode subCode
;
17 /* @Nullable */ private final String state
;
19 public Status(final Code code
, final SubCode subCode
, final String state
) {
21 this.subCode
= subCode
;
26 * Intentionally private as this will be called from JNI
28 private Status(final byte code
, final byte subCode
, final String state
) {
29 this.code
= Code
.getCode(code
);
30 this.subCode
= SubCode
.getSubCode(subCode
);
34 public Code
getCode() {
38 public SubCode
getSubCode() {
42 public String
getState() {
46 public String
getCodeString() {
47 final StringBuilder builder
= new StringBuilder()
49 if(subCode
!= null && subCode
!= SubCode
.None
) {
51 .append(subCode
.name())
54 return builder
.toString();
60 Corruption( (byte)0x2),
61 NotSupported( (byte)0x3),
62 InvalidArgument( (byte)0x4),
64 MergeInProgress( (byte)0x6),
65 Incomplete( (byte)0x7),
66 ShutdownInProgress( (byte)0x8),
73 private final byte value
;
75 Code(final byte value
) {
79 public static Code
getCode(final byte value
) {
80 for (final Code code
: Code
.values()) {
81 if (code
.value
== value
){
85 throw new IllegalArgumentException(
86 "Illegal value provided for Code.");
92 MutexTimeout( (byte)0x1),
93 LockTimeout( (byte)0x2),
94 LockLimit( (byte)0x3),
95 MaxSubCode( (byte)0x7E);
97 private final byte value
;
99 SubCode(final byte value
) {
103 public static SubCode
getSubCode(final byte value
) {
104 for (final SubCode subCode
: SubCode
.values()) {
105 if (subCode
.value
== value
){
109 throw new IllegalArgumentException(
110 "Illegal value provided for SubCode.");