HBASE-26286: Add support for specifying store file tracker when restoring or cloning...
[hbase.git] / hbase-server / src / main / java / org / apache / hadoop / hbase / regionserver / OperationStatus.java
blob6beb7c78e2ca5bdf5e4d5afa17a9e83f2fd3ad7d
1 /*
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 package org.apache.hadoop.hbase.regionserver;
21 import org.apache.hadoop.hbase.HBaseInterfaceAudience;
22 import org.apache.hadoop.hbase.HConstants.OperationStatusCode;
23 import org.apache.hadoop.hbase.client.Result;
24 import org.apache.yetus.audience.InterfaceAudience;
26 /**
28 * This class stores the Operation status code and the exception message
29 * that occurs in case of failure of operations like put, delete, etc.
30 * This class is added with a purpose of adding more details or info regarding
31 * the operation status in future.
34 @InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC)
35 public class OperationStatus {
37 /** Singleton for successful operations. */
38 public static final OperationStatus SUCCESS = new OperationStatus(OperationStatusCode.SUCCESS);
40 /** Singleton for failed operations. */
41 public static final OperationStatus FAILURE = new OperationStatus(OperationStatusCode.FAILURE);
43 /** Singleton for operations not yet run. */
44 public static final OperationStatus NOT_RUN = new OperationStatus(OperationStatusCode.NOT_RUN);
46 private final OperationStatusCode code;
47 private final Result result;
48 private final String exceptionMsg;
50 public OperationStatus(OperationStatusCode code) {
51 this(code, null, "");
54 public OperationStatus(OperationStatusCode code, Result result) {
55 this(code, result, "");
58 public OperationStatus(OperationStatusCode code, String exceptionMsg) {
59 this(code, null, exceptionMsg);
62 public OperationStatus(OperationStatusCode code, Exception e) {
63 this(code, null, (e == null) ? "" : e.getClass().getName() + ": " + e.getMessage());
66 private OperationStatus(OperationStatusCode code, Result result, String exceptionMsg) {
67 this.code = code;
68 this.result = result;
69 this.exceptionMsg = exceptionMsg;
72 /**
73 * @return OperationStatusCode
75 public OperationStatusCode getOperationStatusCode() {
76 return code;
79 /**
80 * @return result
82 public Result getResult() {
83 return result;
86 /**
87 * @return ExceptionMessge
89 public String getExceptionMsg() {
90 return exceptionMsg;