/Users/deen/code/yugabyte-db/src/yb/util/status.h
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. |
2 | | // Use of this source code is governed by a BSD-style license that can be |
3 | | // found in the LICENSE file. See the AUTHORS file for names of contributors. |
4 | | // |
5 | | // The following only applies to changes made to this file as part of YugaByte development. |
6 | | // |
7 | | // Portions Copyright (c) YugaByte, Inc. |
8 | | // |
9 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
10 | | // in compliance with the License. You may obtain a copy of the License at |
11 | | // |
12 | | // http://www.apache.org/licenses/LICENSE-2.0 |
13 | | // |
14 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
15 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
16 | | // or implied. See the License for the specific language governing permissions and limitations |
17 | | // under the License. |
18 | | // |
19 | | // A Status encapsulates the result of an operation. It may indicate success, |
20 | | // or it may indicate an error with an associated error message. |
21 | | // |
22 | | // Multiple threads can invoke const methods on a Status without |
23 | | // external synchronization, but if any of the threads may call a |
24 | | // non-const method, all threads accessing the same Status must use |
25 | | // external synchronization. |
26 | | |
27 | | #ifndef YB_UTIL_STATUS_H_ |
28 | | #define YB_UTIL_STATUS_H_ |
29 | | |
30 | | #include <string> |
31 | | |
32 | | #include <boost/intrusive_ptr.hpp> |
33 | | |
34 | | #include "yb/util/slice.h" |
35 | | #include "yb/util/status_fwd.h" |
36 | | #include "yb/util/strongly_typed_bool.h" |
37 | | |
38 | | // Return the given status if it is not OK. |
39 | 17.9G | #define YB_RETURN_NOT_OK(s) do { \ |
40 | 17.9G | auto&& _s = (s104M ); \ Unexecuted instantiation: tablet-split-itest-base.cc:yb::TabletSplitITest::CheckPostSplitTabletReplicasData(unsigned long, unsigned long, unsigned long)::$_3::operator()() const tablet-split-itest-base.cc:yb::TabletSplitExternalMiniClusterITest::SplitTabletCrashMaster(bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)::$_6::operator()() const Line | Count | Source | 40 | 174 | auto&& _s = (s); \ |
Unexecuted instantiation: ts_tablet_manager.cc:yb::tserver::TSTabletManager::TriggerCompactionAndWait(std::__1::vector<std::__1::shared_ptr<yb::tablet::Tablet>, std::__1::allocator<std::__1::shared_ptr<yb::tablet::Tablet> > > const&)::$_7::operator()() const Unexecuted instantiation: mini_tablet_server.cc:yb::tserver::MiniTabletServer::Reconnect()::$_1::operator()(boost::asio::ip::address const&) const executor.cc:yb::ql::Executor::LoadPagingStateFromUser(yb::ql::PTSelectStmt const*, yb::ql::TnodeContext*)::$_0::operator()(yb::ql::PTSelectStmt const*) const Line | Count | Source | 40 | 7.20M | auto&& _s = (s); \ |
executor.cc:yb::ql::Executor::LoadPagingStateFromUser(yb::ql::PTSelectStmt const*, yb::ql::TnodeContext*)::$_1::operator()(yb::ql::PTSelectStmt const*) const Line | Count | Source | 40 | 254 | auto&& _s = (s); \ |
executor.cc:yb::ql::Executor::ProcessTnodeResults(yb::ql::TnodeContext*)::$_5::operator()(yb::ql::TnodeContext*) const Line | Count | Source | 40 | 309 | auto&& _s = (s); \ |
catalog_manager.cc:yb::master::CatalogManager::VerifyTablePgLayer(scoped_refptr<yb::master::TableInfo>, bool)::$_9::operator()() const Line | Count | Source | 40 | 252 | auto&& _s = (s); \ |
catalog_manager.cc:yb::master::CatalogManager::EnableBgTasks()::$_14::operator()() const Line | Count | Source | 40 | 7.94k | auto&& _s = (s); \ |
Unexecuted instantiation: yb::master::MasterSnapshotCoordinator::Impl::Load(yb::tablet::Tablet*)::'lambda'(yb::Slice const&, yb::Slice const&)::operator()(yb::Slice const&, yb::Slice const&) const sys_catalog.cc:yb::master::SysCatalogTable::Visit(yb::master::VisitorBase*)::$_2::operator()(yb::Slice const&, yb::Slice const&) const Line | Count | Source | 40 | 467k | auto&& _s = (s); \ |
client-internal.cc:yb::client::YBClient::Data::WaitUntilIndexPermissionsAtLeast(yb::client::YBClient*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::IndexPermissions const&, std::__1::chrono::time_point<yb::CoarseMonoClock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> >)::$_0::operator()(std::__1::chrono::time_point<yb::CoarseMonoClock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >, bool*) const Line | Count | Source | 40 | 2.89k | auto&& _s = (s); \ |
client-internal.cc:yb::client::YBClient::Data::WaitUntilIndexPermissionsAtLeast(yb::client::YBClient*, yb::client::YBTableName const&, yb::client::YBTableName const&, yb::IndexPermissions const&, std::__1::chrono::time_point<yb::CoarseMonoClock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> >)::$_1::operator()(std::__1::chrono::time_point<yb::CoarseMonoClock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >, bool*) const Line | Count | Source | 40 | 405 | auto&& _s = (s); \ |
client-internal.cc:yb::client::YBClient::Data::WaitUntilIndexPermissionsAtLeast(yb::client::YBClient*, yb::client::YBTableName const&, yb::client::YBTableName const&, yb::IndexPermissions const&, std::__1::chrono::time_point<yb::CoarseMonoClock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> >)::$_2::operator()(std::__1::chrono::time_point<yb::CoarseMonoClock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >, bool*) const Line | Count | Source | 40 | 2.45k | auto&& _s = (s); \ |
Unexecuted instantiation: snapshot_test_util.cc:yb::client::SnapshotTestUtil::WaitAllSnapshotsDeleted()::$_2::operator()() const yb::Status yb::pggate::PgSession::RunHelper::Apply(yb::pggate::PgTableDesc const&, std::__1::shared_ptr<yb::pggate::PgsqlOp> const&, unsigned long long*, bool)::'lambda'(auto, auto)::operator()<yb::pggate::BufferableOperations, yb::StronglyTypedBool<yb::pggate::IsTransactionalSession_Tag> >(auto, auto) const Line | Count | Source | 40 | 281k | auto&& _s = (s); \ |
external_mini_cluster.cc:yb::ExternalMiniCluster::WaitForMasterToMarkTSAlive(int, yb::MonoDelta)::$_0::operator()() const Line | Count | Source | 40 | 15 | auto&& _s = (s); \ |
external_mini_cluster.cc:yb::ExternalMiniCluster::WaitForMasterToMarkTSDead(int, yb::MonoDelta)::$_1::operator()() const Line | Count | Source | 40 | 20 | auto&& _s = (s); \ |
Unexecuted instantiation: mini_cluster.cc:yb::MiniCluster::AddTServerToBlacklist(yb::tserver::MiniTabletServer const&)::$_7::operator()(yb::master::SysClusterConfigEntryPB*) const Unexecuted instantiation: mini_cluster.cc:yb::MiniCluster::ClearBlacklist()::$_8::operator()(yb::master::SysClusterConfigEntryPB*) const Unexecuted instantiation: mini_cluster.cc:yb::WaitForTableActiveTabletLeadersPeers(yb::MiniCluster*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long, yb::MonoDelta)::$_11::operator()() const Unexecuted instantiation: mini_cluster.cc:yb::WaitAllReplicasSynchronizedWithLeader(yb::MiniCluster*, std::__1::chrono::time_point<yb::CoarseMonoClock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >)::$_17::operator()() const yb-admin_client_ent.cc:yb::tools::enterprise::ClusterAdminClient::ListSnapshots(yb::EnumBitSet<yb::tools::enterprise::ListSnapshotsFlag> const&)::$_0::operator()(yb::rpc::RpcController*) const Line | Count | Source | 40 | 1 | auto&& _s = (s); \ |
yb-admin_client_ent.cc:yb::tools::enterprise::ClusterAdminClient::ListSnapshots(yb::EnumBitSet<yb::tools::enterprise::ListSnapshotsFlag> const&)::$_1::operator()(yb::rpc::RpcController*) const Line | Count | Source | 40 | 1 | auto&& _s = (s); \ |
yb-admin_client_ent.cc:yb::tools::enterprise::ClusterAdminClient::CreateSnapshot(std::__1::vector<yb::client::YBTableName, std::__1::allocator<yb::client::YBTableName> > const&, bool, int)::$_2::operator()(yb::rpc::RpcController*) const Line | Count | Source | 40 | 5 | auto&& _s = (s); \ |
Unexecuted instantiation: yb-admin_client_ent.cc:yb::tools::enterprise::ClusterAdminClient::CreateNamespaceSnapshot(yb::tools::TypedNamespaceName const&)::$_3::operator()(yb::rpc::RpcController*) const yb-admin_client_ent.cc:yb::tools::enterprise::ClusterAdminClient::ListSnapshotRestorations(yb::StronglyTypedUuid<yb::TxnSnapshotRestorationId_Tag> const&)::$_4::operator()(yb::rpc::RpcController*) const Line | Count | Source | 40 | 15 | auto&& _s = (s); \ |
yb-admin_client_ent.cc:yb::tools::enterprise::ClusterAdminClient::CreateSnapshotSchedule(yb::client::YBTableName const&, yb::MonoDelta, yb::MonoDelta)::$_5::operator()(yb::rpc::RpcController*) const Line | Count | Source | 40 | 8 | auto&& _s = (s); \ |
yb-admin_client_ent.cc:yb::tools::enterprise::ClusterAdminClient::ListSnapshotSchedules(yb::StronglyTypedUuid<yb::SnapshotScheduleId_Tag> const&)::$_6::operator()(yb::rpc::RpcController*) const Line | Count | Source | 40 | 23 | auto&& _s = (s); \ |
Unexecuted instantiation: yb-admin_client_ent.cc:yb::tools::enterprise::ClusterAdminClient::DeleteSnapshotSchedule(yb::StronglyTypedUuid<yb::SnapshotScheduleId_Tag> const&)::$_7::operator()(yb::rpc::RpcController*) const Unexecuted instantiation: yb-admin_client_ent.cc:yb::tools::enterprise::ClusterAdminClient::RestoreSnapshot(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::HybridTime)::$_8::operator()(yb::rpc::RpcController*) const Unexecuted instantiation: yb-admin_client_ent.cc:yb::tools::enterprise::ClusterAdminClient::DeleteSnapshot(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_9::operator()(yb::rpc::RpcController*) const Unexecuted instantiation: yb-admin_client_ent.cc:yb::tools::enterprise::ClusterAdminClient::CreateSnapshotMetaFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_10::operator()(yb::rpc::RpcController*) const Unexecuted instantiation: yb-admin_client_ent.cc:yb::tools::enterprise::ClusterAdminClient::ImportSnapshotMetaFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::tools::TypedNamespaceName const&, std::__1::vector<yb::client::YBTableName, std::__1::allocator<yb::client::YBTableName> > const&)::$_11::operator()(yb::rpc::RpcController*) const Unexecuted instantiation: yb-admin_client_ent.cc:yb::tools::enterprise::ClusterAdminClient::ImportSnapshotMetaFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::tools::TypedNamespaceName const&, std::__1::vector<yb::client::YBTableName, std::__1::allocator<yb::client::YBTableName> > const&)::$_13::operator()(yb::rpc::RpcController*) const Unexecuted instantiation: yb-admin_client_ent.cc:yb::tools::enterprise::ClusterAdminClient::ListReplicaTypeCounts(yb::client::YBTableName const&)::$_14::operator()(yb::rpc::RpcController*) const net_util.cc:yb::HostPort::ResolveAddresses(std::__1::vector<boost::asio::ip::basic_endpoint<boost::asio::ip::tcp>, std::__1::allocator<boost::asio::ip::basic_endpoint<boost::asio::ip::tcp> > >*) const::$_0::operator()(boost::asio::ip::address const&) const Line | Count | Source | 40 | 706k | auto&& _s = (s); \ |
conflict_resolution.cc:auto yb::docdb::(anonymous namespace)::TransactionConflictResolverContext::ReadConflicts(yb::docdb::(anonymous namespace)::ConflictResolver*)::'lambda'(auto, yb::StronglyTypedBool<yb::docdb::FullDocKey_Tag>, auto, auto, auto)::operator()<yb::docdb::IntentStrength, yb::Slice, yb::docdb::KeyBytes*, yb::StronglyTypedBool<yb::docdb::LastKey_Tag> >(auto, yb::StronglyTypedBool<yb::docdb::FullDocKey_Tag>, auto, auto, auto) const Line | Count | Source | 40 | 51.1M | auto&& _s = (s); \ |
conflict_resolution.cc:auto yb::docdb::(anonymous namespace)::TransactionConflictResolverContext::ReadConflicts(yb::docdb::(anonymous namespace)::ConflictResolver*)::'lambda0'(auto, yb::StronglyTypedBool<yb::docdb::FullDocKey_Tag>, auto, auto, auto)::operator()<yb::docdb::IntentStrength, yb::Slice, yb::docdb::KeyBytes*, yb::StronglyTypedBool<yb::docdb::LastKey_Tag> >(auto, yb::StronglyTypedBool<yb::docdb::FullDocKey_Tag>, auto, auto, auto) const Line | Count | Source | 40 | 5.96M | auto&& _s = (s); \ |
docdb.cc:yb::docdb::(anonymous namespace)::DetermineKeysToLock(std::__1::vector<std::__1::unique_ptr<yb::docdb::DocOperation, std::__1::default_delete<yb::docdb::DocOperation> >, std::__1::allocator<std::__1::unique_ptr<yb::docdb::DocOperation, std::__1::default_delete<yb::docdb::DocOperation> > > > const&, google::protobuf::RepeatedPtrField<yb::docdb::KeyValuePairPB> const&, yb::IsolationLevel, yb::docdb::OperationKind, yb::RowMarkType, bool, yb::StronglyTypedBool<yb::docdb::PartialRangeKeyIntents_Tag>)::$_0::operator()(yb::docdb::IntentStrength, yb::StronglyTypedBool<yb::docdb::FullDocKey_Tag>, yb::Slice, yb::docdb::KeyBytes*, yb::StronglyTypedBool<yb::docdb::LastKey_Tag>) const Line | Count | Source | 40 | 17.2M | auto&& _s = (s); \ |
Unexecuted instantiation: yb::docdb::RocksDBPatcher::Impl::UpdateFileSizes()::'lambda'(int, rocksdb::FileMetaData const&)::operator()(int, rocksdb::FileMetaData const&) const |
41 | 17.9G | if (PREDICT_FALSE(!_s.ok())) return MoveStatus(std::move(_s))6.08M ; \ |
42 | 17.9G | } while (false) |
43 | | |
44 | | // Return the given status if it is not OK, but first clone it and prepend the given message. |
45 | 4.33G | #define YB_RETURN_NOT_OK_PREPEND(s, msg) do { \ |
46 | 4.33G | auto&& _s = (s1.38k ); \ restore_sys_catalog_state.cc:auto yb::master::RestoreSysCatalogState::Process()::$_0::operator()<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, yb::master::SysNamespaceEntryPB>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::master::SysNamespaceEntryPB*) const Line | Count | Source | 46 | 9 | auto&& _s = (s); \ |
restore_sys_catalog_state.cc:auto yb::master::RestoreSysCatalogState::Process()::$_0::operator()<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, yb::master::SysTablesEntryPB>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::master::SysTablesEntryPB*) const Line | Count | Source | 46 | 660 | auto&& _s = (s); \ |
restore_sys_catalog_state.cc:auto yb::master::RestoreSysCatalogState::Process()::$_0::operator()<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, yb::master::SysTabletsEntryPB>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::master::SysTabletsEntryPB*) const Line | Count | Source | 46 | 30 | auto&& _s = (s); \ |
restore_sys_catalog_state.cc:auto yb::master::RestoreSysCatalogState::Process()::$_1::operator()<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, yb::master::SysNamespaceEntryPB>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::master::SysNamespaceEntryPB*) const Line | Count | Source | 46 | 9 | auto&& _s = (s); \ |
restore_sys_catalog_state.cc:auto yb::master::RestoreSysCatalogState::Process()::$_1::operator()<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, yb::master::SysTablesEntryPB>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::master::SysTablesEntryPB*) const Line | Count | Source | 46 | 657 | auto&& _s = (s); \ |
restore_sys_catalog_state.cc:auto yb::master::RestoreSysCatalogState::Process()::$_1::operator()<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, yb::master::SysTabletsEntryPB>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::master::SysTabletsEntryPB*) const Line | Count | Source | 46 | 21 | auto&& _s = (s); \ |
|
47 | 4.33G | if (PREDICT_FALSE(!_s.ok())) return MoveStatus(_s).CloneAndPrepend(2.26M msg0 ); \ |
48 | 4.33G | } while (04.33G ); |
49 | | |
50 | | // Return 'to_return' if 'to_call' returns a bad status. The substitution for 'to_return' may |
51 | | // reference the variable 's' for the bad status. |
52 | 0 | #define YB_RETURN_NOT_OK_RET(to_call, to_return) do { \ |
53 | 0 | ::yb::Status s = (to_call); \ |
54 | 0 | if (PREDICT_FALSE(!s.ok())) return (to_return); \ |
55 | 0 | } while (0); |
56 | | |
57 | | // Return the given status by adding the error code if it is not OK. |
58 | 15.8k | #define YB_RETURN_NOT_OK_SET_CODE(s, code) do { \ |
59 | 15.8k | auto&& _s = (s); \ |
60 | 15.8k | if (PREDICT_FALSE(!_s.ok())) return MoveStatus(_s).CloneAndAddErrorCode(code)0 ; \ |
61 | 15.8k | } while (false) |
62 | | |
63 | 17.9G | #define RETURN_NOT_OK YB_RETURN_NOT_OK |
64 | 4.33G | #define RETURN_NOT_OK_PREPEND YB_RETURN_NOT_OK_PREPEND |
65 | 0 | #define RETURN_NOT_OK_RET YB_RETURN_NOT_OK_RET |
66 | 15.8k | #define RETURN_NOT_OK_SET_CODE YB_RETURN_NOT_OK_SET_CODE |
67 | | |
68 | | extern "C" { |
69 | | |
70 | | struct YBCStatusStruct; |
71 | | |
72 | | } |
73 | | |
74 | | namespace yb { |
75 | | |
76 | | class Slice; |
77 | | |
78 | | YB_STRONGLY_TYPED_BOOL(DupFileName); |
79 | | YB_STRONGLY_TYPED_BOOL(AddRef); |
80 | | |
81 | | class StatusErrorCode; |
82 | | struct StatusCategoryDescription; |
83 | | |
84 | | class NODISCARD_CLASS Status { |
85 | | public: |
86 | | // Wrapper class for OK status to forbid creation of Result from Status::OK in compile time |
87 | | class OK { |
88 | | public: |
89 | 27.6G | operator Status() const { |
90 | 27.6G | return Status(); |
91 | 27.6G | } |
92 | | }; |
93 | | // Create a success status. |
94 | 28.8G | Status() {} |
95 | | |
96 | | // Returns true if the status indicates success. |
97 | 36.2G | MUST_USE_RESULT bool ok() const { return state_ == nullptr; } |
98 | | |
99 | | // Declares set of Is* functions |
100 | | |
101 | | #define YB_STATUS_CODE(name, pb_name, value, message) \ |
102 | 672M | bool BOOST_PP_CAT(Is, name)() const { \ |
103 | 672M | return code() == BOOST_PP_CAT(k, name); \ |
104 | 672M | } Unexecuted instantiation: yb::Status::IsConfigurationError() const Unexecuted instantiation: yb::Status::IsSnapshotTooOld() const yb::Status::IsServiceUnavailable() const Line | Count | Source | 102 | 14.3M | bool BOOST_PP_CAT(Is, name)() const { \ | 103 | 14.3M | return code() == BOOST_PP_CAT(k, name); \ | 104 | 14.3M | } |
yb::Status::IsNotFound() const Line | Count | Source | 102 | 96.8M | bool BOOST_PP_CAT(Is, name)() const { \ | 103 | 96.8M | return code() == BOOST_PP_CAT(k, name); \ | 104 | 96.8M | } |
yb::Status::IsInvalidArgument() const Line | Count | Source | 102 | 188k | bool BOOST_PP_CAT(Is, name)() const { \ | 103 | 188k | return code() == BOOST_PP_CAT(k, name); \ | 104 | 188k | } |
yb::Status::IsBusy() const Line | Count | Source | 102 | 828k | bool BOOST_PP_CAT(Is, name)() const { \ | 103 | 828k | return code() == BOOST_PP_CAT(k, name); \ | 104 | 828k | } |
yb::Status::IsTimedOut() const Line | Count | Source | 102 | 25.3M | bool BOOST_PP_CAT(Is, name)() const { \ | 103 | 25.3M | return code() == BOOST_PP_CAT(k, name); \ | 104 | 25.3M | } |
yb::Status::IsTryAgain() const Line | Count | Source | 102 | 177M | bool BOOST_PP_CAT(Is, name)() const { \ | 103 | 177M | return code() == BOOST_PP_CAT(k, name); \ | 104 | 177M | } |
yb::Status::IsExpired() const Line | Count | Source | 102 | 10.1M | bool BOOST_PP_CAT(Is, name)() const { \ | 103 | 10.1M | return code() == BOOST_PP_CAT(k, name); \ | 104 | 10.1M | } |
yb::Status::IsAlreadyPresent() const Line | Count | Source | 102 | 5.83M | bool BOOST_PP_CAT(Is, name)() const { \ | 103 | 5.83M | return code() == BOOST_PP_CAT(k, name); \ | 104 | 5.83M | } |
yb::Status::IsNotSupported() const Line | Count | Source | 102 | 7.72M | bool BOOST_PP_CAT(Is, name)() const { \ | 103 | 7.72M | return code() == BOOST_PP_CAT(k, name); \ | 104 | 7.72M | } |
yb::Status::IsIOError() const Line | Count | Source | 102 | 9.29M | bool BOOST_PP_CAT(Is, name)() const { \ | 103 | 9.29M | return code() == BOOST_PP_CAT(k, name); \ | 104 | 9.29M | } |
yb::Status::IsNetworkError() const Line | Count | Source | 102 | 25.3M | bool BOOST_PP_CAT(Is, name)() const { \ | 103 | 25.3M | return code() == BOOST_PP_CAT(k, name); \ | 104 | 25.3M | } |
yb::Status::IsIllegalState() const Line | Count | Source | 102 | 32.0M | bool BOOST_PP_CAT(Is, name)() const { \ | 103 | 32.0M | return code() == BOOST_PP_CAT(k, name); \ | 104 | 32.0M | } |
yb::Status::IsRemoteError() const Line | Count | Source | 102 | 66.4M | bool BOOST_PP_CAT(Is, name)() const { \ | 103 | 66.4M | return code() == BOOST_PP_CAT(k, name); \ | 104 | 66.4M | } |
yb::Status::IsLeaderHasNoLease() const Line | Count | Source | 102 | 14.1M | bool BOOST_PP_CAT(Is, name)() const { \ | 103 | 14.1M | return code() == BOOST_PP_CAT(k, name); \ | 104 | 14.1M | } |
yb::Status::IsShutdownInProgress() const Line | Count | Source | 102 | 144k | bool BOOST_PP_CAT(Is, name)() const { \ | 103 | 144k | return code() == BOOST_PP_CAT(k, name); \ | 104 | 144k | } |
yb::Status::IsNotAuthorized() const Line | Count | Source | 102 | 455 | bool BOOST_PP_CAT(Is, name)() const { \ | 103 | 455 | return code() == BOOST_PP_CAT(k, name); \ | 104 | 455 | } |
yb::Status::IsQLError() const Line | Count | Source | 102 | 18.4M | bool BOOST_PP_CAT(Is, name)() const { \ | 103 | 18.4M | return code() == BOOST_PP_CAT(k, name); \ | 104 | 18.4M | } |
yb::Status::IsCorruption() const Line | Count | Source | 102 | 1.15k | bool BOOST_PP_CAT(Is, name)() const { \ | 103 | 1.15k | return code() == BOOST_PP_CAT(k, name); \ | 104 | 1.15k | } |
yb::Status::IsAborted() const Line | Count | Source | 102 | 28.4M | bool BOOST_PP_CAT(Is, name)() const { \ | 103 | 28.4M | return code() == BOOST_PP_CAT(k, name); \ | 104 | 28.4M | } |
Line | Count | Source | 102 | 1.62M | bool BOOST_PP_CAT(Is, name)() const { \ | 103 | 1.62M | return code() == BOOST_PP_CAT(k, name); \ | 104 | 1.62M | } |
yb::Status::IsUninitialized() const Line | Count | Source | 102 | 219k | bool BOOST_PP_CAT(Is, name)() const { \ | 103 | 219k | return code() == BOOST_PP_CAT(k, name); \ | 104 | 219k | } |
yb::Status::IsIncomplete() const Line | Count | Source | 102 | 107M | bool BOOST_PP_CAT(Is, name)() const { \ | 103 | 107M | return code() == BOOST_PP_CAT(k, name); \ | 104 | 107M | } |
yb::Status::IsInvalidCommand() const Line | Count | Source | 102 | 185k | bool BOOST_PP_CAT(Is, name)() const { \ | 103 | 185k | return code() == BOOST_PP_CAT(k, name); \ | 104 | 185k | } |
yb::Status::IsLeaderNotReadyToServe() const Line | Count | Source | 102 | 14.2M | bool BOOST_PP_CAT(Is, name)() const { \ | 103 | 14.2M | return code() == BOOST_PP_CAT(k, name); \ | 104 | 14.2M | } |
yb::Status::IsCombined() const Line | Count | Source | 102 | 4.00k | bool BOOST_PP_CAT(Is, name)() const { \ | 103 | 4.00k | return code() == BOOST_PP_CAT(k, name); \ | 104 | 4.00k | } |
yb::Status::IsEndOfFile() const Line | Count | Source | 102 | 437k | bool BOOST_PP_CAT(Is, name)() const { \ | 103 | 437k | return code() == BOOST_PP_CAT(k, name); \ | 104 | 437k | } |
yb::Status::IsMergeInProgress() const Line | Count | Source | 102 | 16.1M | bool BOOST_PP_CAT(Is, name)() const { \ | 103 | 16.1M | return code() == BOOST_PP_CAT(k, name); \ | 104 | 16.1M | } |
|
105 | | #include "yb/util/status_codes.h" |
106 | | #undef YB_STATUS_CODE |
107 | | |
108 | | // Returns a text message of this status to be reported to users. |
109 | | // Returns empty string for success. |
110 | 5.45k | std::string ToUserMessage(bool include_code = false) const { |
111 | 5.45k | return ToString(false /* include_file_and_line */, include_code); |
112 | 5.45k | } |
113 | | |
114 | | // Return a string representation of this status suitable for printing. |
115 | | // Returns the string "OK" for success. |
116 | | std::string ToString(bool include_file_and_line = true, bool include_code = true) const; |
117 | | |
118 | | // Return a string representation of the status code, without the message |
119 | | // text or posix code information. |
120 | | std::string CodeAsString() const; |
121 | | |
122 | | // Returned string has unlimited lifetime, and should NOT be released by the caller. |
123 | | const char* CodeAsCString() const; |
124 | | |
125 | | // Return the message portion of the Status. This is similar to ToString, |
126 | | // except that it does not include the stringified error code or posix code. |
127 | | // |
128 | | // For OK statuses, this returns an empty string. |
129 | | // |
130 | | // The returned Slice is only valid as long as this Status object remains |
131 | | // live and unchanged. |
132 | | Slice message() const; |
133 | | |
134 | | const uint8_t* ErrorData(uint8_t category) const; |
135 | | Slice ErrorCodesSlice() const; |
136 | | |
137 | | const char* file_name() const; |
138 | | int line_number() const; |
139 | | |
140 | | // Return a new Status object with the same state plus an additional leading message. |
141 | | Status CloneAndPrepend(const Slice& msg) const; |
142 | | |
143 | | // Same as CloneAndPrepend, but appends to the message instead. |
144 | | Status CloneAndAppend(const Slice& msg) const; |
145 | | |
146 | | // Same as CloneAndPrepend, but adds new error code to status. |
147 | | // If error code of the same category already present, it will be replaced with new one. |
148 | | Status CloneAndAddErrorCode(const StatusErrorCode& error_code) const; |
149 | | |
150 | | // Returns the memory usage of this object without the object itself. Should |
151 | | // be used when embedded inside another object. |
152 | | size_t memory_footprint_excluding_this() const; |
153 | | |
154 | | // Returns the memory usage of this object including the object itself. |
155 | | // Should be used when allocated on the heap. |
156 | | size_t memory_footprint_including_this() const; |
157 | | |
158 | | enum Code : int32_t { |
159 | | #define YB_STATUS_CODE(name, pb_name, value, message) \ |
160 | | BOOST_PP_CAT(k, name) = value, |
161 | | #include "yb/util/status_codes.h" // NOLINT |
162 | | #undef YB_STATUS_CODE |
163 | | }; |
164 | | |
165 | | // Return a new Status object with the same state except status code. |
166 | | Status CloneAndReplaceCode(Code code) const; |
167 | | |
168 | | Status(Code code, |
169 | | const char* file_name, |
170 | | int line_number, |
171 | | const Slice& msg, |
172 | | // Error message details. If present - would be combined as "msg: msg2". |
173 | | const Slice& msg2 = Slice(), |
174 | | const StatusErrorCode* error = nullptr, |
175 | | DupFileName dup_file_name = DupFileName::kFalse); |
176 | | |
177 | | Status(Code code, |
178 | | const char* file_name, |
179 | | int line_number, |
180 | | const Slice& msg, |
181 | | // Error message details. If present - would be combined as "msg: msg2". |
182 | | const Slice& msg2, |
183 | | const StatusErrorCode& error, |
184 | | DupFileName dup_file_name = DupFileName::kFalse) |
185 | 7.10M | : Status(code, file_name, line_number, msg, msg2, &error, dup_file_name) { |
186 | 7.10M | } Unexecuted instantiation: yb::Status::Status(yb::Status::Code, char const*, int, yb::Slice const&, yb::Slice const&, yb::StatusErrorCode const&, yb::StronglyTypedBool<yb::DupFileName_Tag>) yb::Status::Status(yb::Status::Code, char const*, int, yb::Slice const&, yb::Slice const&, yb::StatusErrorCode const&, yb::StronglyTypedBool<yb::DupFileName_Tag>) Line | Count | Source | 185 | 7.10M | : Status(code, file_name, line_number, msg, msg2, &error, dup_file_name) { | 186 | 7.10M | } |
|
187 | | |
188 | | Status(Code code, |
189 | | const char* file_name, |
190 | | int line_number, |
191 | | const StatusErrorCode& error, |
192 | | DupFileName dup_file_name = DupFileName::kFalse); |
193 | | |
194 | | Status(Code code, |
195 | | const char* file_name, |
196 | | int line_number, |
197 | | const Slice& msg, |
198 | | const StatusErrorCode& error, |
199 | | DupFileName dup_file_name = DupFileName::kFalse); |
200 | | |
201 | | Status(Code code, |
202 | | const char* file_name, |
203 | | int line_number, |
204 | | const Slice& msg, |
205 | | const Slice& errors, |
206 | | DupFileName dup_file_name); |
207 | | |
208 | | Code code() const; |
209 | | |
210 | | static void RegisterCategory(const StatusCategoryDescription& description); |
211 | | |
212 | | static const std::string& CategoryName(uint8_t category); |
213 | | |
214 | | // Adopt status that was previously exported to C interface. |
215 | | explicit Status(YBCStatusStruct* state, AddRef add_ref); |
216 | | |
217 | | // Increments state ref count and returns pointer that could be used in C interface. |
218 | | YBCStatusStruct* RetainStruct() const; |
219 | | |
220 | | // Reset state w/o touching ref count. Return detached pointer that could be used in C interface. |
221 | | YBCStatusStruct* DetachStruct(); |
222 | | |
223 | | private: |
224 | | struct State; |
225 | | |
226 | | bool file_name_duplicated() const; |
227 | | |
228 | | typedef boost::intrusive_ptr<State> StatePtr; |
229 | | |
230 | | explicit Status(StatePtr state); |
231 | | |
232 | | friend void intrusive_ptr_release(State* state); |
233 | | friend void intrusive_ptr_add_ref(State* state); |
234 | | |
235 | | StatePtr state_; |
236 | | |
237 | | static_assert(sizeof(Code) == 4, "Code enum size is part of ABI"); |
238 | | }; |
239 | | |
240 | 5.20M | inline Status&& MoveStatus(Status&& status) { |
241 | 5.20M | return std::move(status); |
242 | 5.20M | } |
243 | | |
244 | 2.26M | inline const Status& MoveStatus(const Status& status) { |
245 | 2.26M | return status; |
246 | 2.26M | } |
247 | | |
248 | 388 | inline std::string StatusToString(const Status& status) { |
249 | 388 | return status.ToString(); |
250 | 388 | } |
251 | | |
252 | 1.34M | inline std::ostream& operator<<(std::ostream& out, const Status& status) { |
253 | 1.34M | return out << status.ToString(); |
254 | 1.34M | } |
255 | | |
256 | | } // namespace yb |
257 | | |
258 | | #define STATUS(status_type, ...) \ |
259 | 276M | (Status(Status::BOOST_PP_CAT(k, status_type), __FILE__, __LINE__, __VA_ARGS__8.87k )) |
260 | | |
261 | | // Utility macros to perform the appropriate check. If the check fails, returns the specified |
262 | | // (error) Status, with the given message. |
263 | 154M | #define SCHECK(expr, status_type, msg) do { \ |
264 | 154M | if (PREDICT_FALSE(!(expr))) return 189 STATUS189 (status_type, (msg)); \ |
265 | 154M | } while (0154M ) |
266 | | |
267 | 10.1k | #define SCHECK_NOTNULL(expr) do { \ |
268 | 10.1k | if ((expr) == nullptr) { \ |
269 | 0 | return STATUS(IllegalState, BOOST_PP_STRINGIZE(expr) " must not be null"); \ |
270 | 0 | } \ |
271 | 10.1k | } while (0) |
272 | | |
273 | | #include "yb/util/status_format.h" |
274 | | #include "yb/util/status_log.h" |
275 | | |
276 | | #endif // YB_UTIL_STATUS_H_ |