13 #ifndef KUDU_UTIL_STATUS_H_    14 #define KUDU_UTIL_STATUS_H_    19 #ifdef KUDU_HEADERS_NO_STUBS    20 #include "kudu/gutil/macros.h"    21 #include "kudu/gutil/port.h"    23 #include "kudu/client/stubs.h"    26 #include "kudu/util/kudu_export.h"    27 #include "kudu/util/slice.h"    30 #define KUDU_RETURN_NOT_OK(s) do { \    31     const ::kudu::Status& _s = (s);             \    32     if (PREDICT_FALSE(!_s.ok())) return _s;     \    37 #define KUDU_RETURN_NOT_OK_PREPEND(s, msg) do { \    38     const ::kudu::Status& _s = (s);                              \    39     if (PREDICT_FALSE(!_s.ok())) return _s.CloneAndPrepend(msg); \    45 #define KUDU_RETURN_NOT_OK_RET(to_call, to_return) do { \    46     const ::kudu::Status& s = (to_call);                \    47     if (PREDICT_FALSE(!s.ok())) return (to_return);  \    51 #define KUDU_WARN_NOT_OK(to_call, warning_prefix) do { \    52     const ::kudu::Status& _s = (to_call);              \    53     if (PREDICT_FALSE(!_s.ok())) { \    54       KUDU_LOG(WARNING) << (warning_prefix) << ": " << _s.ToString();  \    59 #define KUDU_LOG_AND_RETURN(level, status) do { \    60     const ::kudu::Status& _s = (status);        \    61     KUDU_LOG(level) << _s.ToString(); \    66 #define KUDU_RETURN_NOT_OK_LOG(s, level, msg) do { \    67     const ::kudu::Status& _s = (s);             \    68     if (PREDICT_FALSE(!_s.ok())) { \    69       KUDU_LOG(level) << "Status: " << _s.ToString() << " " << (msg); \    76 #define KUDU_CHECK_OK_PREPEND(to_call, msg) do { \    77     const ::kudu::Status& _s = (to_call);                   \    78     KUDU_CHECK(_s.ok()) << (msg) << ": " << _s.ToString();  \    83 #define KUDU_CHECK_OK(s) KUDU_CHECK_OK_PREPEND(s, "Bad status")    87 #define KUDU_DCHECK_OK_PREPEND(to_call, msg) do { \    88     const ::kudu::Status& _s = (to_call);                   \    89     KUDU_DCHECK(_s.ok()) << (msg) << ": " << _s.ToString();  \    94 #define KUDU_DCHECK_OK(s) KUDU_DCHECK_OK_PREPEND(s, "Bad status")   109 #ifdef KUDU_HEADERS_USE_SHORT_STATUS_MACROS   110 #define RETURN_NOT_OK         KUDU_RETURN_NOT_OK   111 #define RETURN_NOT_OK_PREPEND KUDU_RETURN_NOT_OK_PREPEND   112 #define RETURN_NOT_OK_RET     KUDU_RETURN_NOT_OK_RET   113 #define WARN_NOT_OK           KUDU_WARN_NOT_OK   114 #define LOG_AND_RETURN        KUDU_LOG_AND_RETURN   115 #define RETURN_NOT_OK_LOG     KUDU_RETURN_NOT_OK_LOG   116 #define CHECK_OK_PREPEND      KUDU_CHECK_OK_PREPEND   117 #define CHECK_OK              KUDU_CHECK_OK   118 #define DCHECK_OK_PREPEND     KUDU_DCHECK_OK_PREPEND   119 #define DCHECK_OK             KUDU_DCHECK_OK   123 #define KUDU_CHECK            CHECK   124 #define KUDU_DCHECK           DCHECK   135   ~
Status() { 
delete[] state_; }
   147   void operator=(
const Status& s);
   149 #if __cplusplus >= 201103L   160   void operator=(
Status&& s);
   179                          int16_t posix_code = -1) {
   180     return Status(kNotFound, msg, msg2, posix_code);
   183                          int16_t posix_code = -1) {
   184     return Status(kCorruption, msg, msg2, posix_code);
   187                          int16_t posix_code = -1) {
   188     return Status(kNotSupported, msg, msg2, posix_code);
   191                          int16_t posix_code = -1) {
   192     return Status(kInvalidArgument, msg, msg2, posix_code);
   195                          int16_t posix_code = -1) {
   196     return Status(kIOError, msg, msg2, posix_code);
   199                          int16_t posix_code = -1) {
   200     return Status(kAlreadyPresent, msg, msg2, posix_code);
   203                          int16_t posix_code = -1) {
   204     return Status(kRuntimeError, msg, msg2, posix_code);
   207                          int16_t posix_code = -1) {
   208     return Status(kNetworkError, msg, msg2, posix_code);
   211                          int16_t posix_code = -1) {
   212     return Status(kIllegalState, msg, msg2, posix_code);
   215                          int16_t posix_code = -1) {
   216     return Status(kNotAuthorized, msg, msg2, posix_code);
   219                          int16_t posix_code = -1) {
   220     return Status(kAborted, msg, msg2, posix_code);
   223                          int16_t posix_code = -1) {
   224     return Status(kRemoteError, msg, msg2, posix_code);
   227                          int16_t posix_code = -1) {
   228     return Status(kServiceUnavailable, msg, msg2, posix_code);
   231                          int16_t posix_code = -1) {
   232     return Status(kTimedOut, msg, msg2, posix_code);
   235                               int16_t posix_code = -1) {
   236     return Status(kUninitialized, msg, msg2, posix_code);
   239                                    int16_t posix_code = -1) {
   240     return Status(kConfigurationError, msg, msg2, posix_code);
   243                            int64_t posix_code = -1) {
   244     return Status(kIncomplete, msg, msg2, posix_code);
   247                           int64_t posix_code = -1) {
   248     return Status(kEndOfFile, msg, msg2, posix_code);
   253   bool ok()
 const { 
return (state_ == NULL); }
   311   std::string ToString() 
const;
   315   std::string CodeAsString() 
const;
   325   Slice message() 
const;
   329   int16_t posix_code() 
const;
   349   size_t memory_footprint_excluding_this() 
const;
   353   size_t memory_footprint_including_this() 
const;
   369     kInvalidArgument = 4,
   378     kServiceUnavailable = 13,
   381     kConfigurationError = 16,
   390   COMPILE_ASSERT(
sizeof(Code) == 4, code_enum_size_is_part_of_abi);
   393     return (state_ == NULL) ? kOk : 
static_cast<Code
>(state_[4]);
   397   static const char* CopyState(
const char* s);
   401   state_ = (s.state_ == NULL) ? NULL : CopyState(s.state_);
   406   if (state_ != s.state_) {
   408     state_ = (s.state_ == NULL) ? NULL : CopyState(s.state_);
   412 #if __cplusplus >= 201103L   418   if (state_ != s.state_) {
   428 #endif  // KUDU_UTIL_STATUS_H_ Status()
Create an object representing success status. 
Definition: status.h:133
 
bool IsNotAuthorized() const 
Definition: status.h:283
 
A representation of an operation's outcome. 
Definition: status.h:130
 
bool IsIllegalState() const 
Definition: status.h:280
 
Definition: callbacks.h:28
 
bool ok() const 
Definition: status.h:253
 
bool IsTimedOut() const 
Definition: status.h:295
 
bool IsRemoteError() const 
Definition: status.h:289
 
bool IsServiceUnavailable() const 
Definition: status.h:292
 
bool IsAborted() const 
Definition: status.h:286
 
bool IsUninitialized() const 
Definition: status.h:298
 
bool IsRuntimeError() const 
Definition: status.h:274
 
bool IsAlreadyPresent() const 
Definition: status.h:271
 
bool IsIOError() const 
Definition: status.h:265
 
static Status OK()
Definition: status.h:164
 
A wrapper around externally allocated data. 
Definition: slice.h:43
 
bool IsConfigurationError() const 
Definition: status.h:301
 
bool IsInvalidArgument() const 
Definition: status.h:268
 
bool IsCorruption() const 
Definition: status.h:259
 
void operator=(const Status &s)
Definition: status.h:403
 
bool IsEndOfFile() const 
Definition: status.h:307
 
bool IsNotSupported() const 
Definition: status.h:262
 
bool IsNetworkError() const 
Definition: status.h:277
 
bool IsIncomplete() const 
Definition: status.h:304
 
bool IsNotFound() const 
Definition: status.h:256