/Users/deen/code/yugabyte-db/src/yb/master/master_util.h
Line | Count | Source |
1 | | // Copyright (c) YugaByte, Inc. |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
4 | | // in compliance with the License. You may obtain a copy of the License at |
5 | | // |
6 | | // http://www.apache.org/licenses/LICENSE-2.0 |
7 | | // |
8 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
9 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
10 | | // or implied. See the License for the specific language governing permissions and limitations |
11 | | // under the License. |
12 | | // |
13 | | |
14 | | #ifndef YB_MASTER_MASTER_UTIL_H |
15 | | #define YB_MASTER_MASTER_UTIL_H |
16 | | |
17 | | #include <memory> |
18 | | |
19 | | #include "yb/common/common_fwd.h" |
20 | | #include "yb/common/common_types.pb.h" |
21 | | #include "yb/common/entity_ids_types.h" |
22 | | |
23 | | #include "yb/master/master_client.fwd.h" |
24 | | #include "yb/master/master_fwd.h" |
25 | | |
26 | | #include "yb/rpc/rpc_fwd.h" |
27 | | |
28 | | #include "yb/util/status_fwd.h" |
29 | | #include "yb/util/monotime.h" |
30 | | |
31 | | // This file contains utility functions that can be shared between client and master code. |
32 | | |
33 | | namespace yb { |
34 | | |
35 | | namespace consensus { |
36 | | |
37 | | class RaftPeerPB; |
38 | | |
39 | | } |
40 | | |
41 | | namespace master { |
42 | | |
43 | | // Given a hostport, return the master server information protobuf. |
44 | | // Does not apply to tablet server. |
45 | | CHECKED_STATUS GetMasterEntryForHosts( |
46 | | rpc::ProxyCache* proxy_cache, |
47 | | const std::vector<HostPort>& hostports, |
48 | | MonoDelta timeout, |
49 | | ServerEntryPB* e); |
50 | | |
51 | | const HostPortPB& DesiredHostPort(const TSInfoPB& ts_info, const CloudInfoPB& from); |
52 | | |
53 | | void TakeRegistration(consensus::RaftPeerPB* source, TSInfoPB* dest); |
54 | | void CopyRegistration(const consensus::RaftPeerPB& source, TSInfoPB* dest); |
55 | | |
56 | | void TakeRegistration(ServerRegistrationPB* source, TSInfoPB* dest); |
57 | | void CopyRegistration(const ServerRegistrationPB& source, TSInfoPB* dest); |
58 | | |
59 | | bool IsSystemNamespace(const std::string& namespace_name); |
60 | | |
61 | | YQLDatabase GetDefaultDatabaseType(const std::string& keyspace_name); |
62 | | |
63 | | template<class PB> |
64 | 142k | YQLDatabase GetDatabaseType(const PB& ns) { |
65 | 142k | return ns.has_database_type() ? ns.database_type()107k : GetDefaultDatabaseType(ns.name())35.4k ; |
66 | 142k | } yb::YQLDatabase yb::master::GetDatabaseType<yb::master::NamespaceIdentifierPB>(yb::master::NamespaceIdentifierPB const&) Line | Count | Source | 64 | 139k | YQLDatabase GetDatabaseType(const PB& ns) { | 65 | 139k | return ns.has_database_type() ? ns.database_type()104k : GetDefaultDatabaseType(ns.name())35.2k ; | 66 | 139k | } |
yb::YQLDatabase yb::master::GetDatabaseType<yb::master::CreateNamespaceRequestPB>(yb::master::CreateNamespaceRequestPB const&) Line | Count | Source | 64 | 2.65k | YQLDatabase GetDatabaseType(const PB& ns) { | 65 | 2.65k | return ns.has_database_type() ? ns.database_type()2.48k : GetDefaultDatabaseType(ns.name())166 ; | 66 | 2.65k | } |
Unexecuted instantiation: yb::YQLDatabase yb::master::GetDatabaseType<yb::master::SysNamespaceEntryPB>(yb::master::SysNamespaceEntryPB const&) |
67 | | |
68 | | YQLDatabase GetDatabaseTypeForTable(const TableType table_type); |
69 | | TableType GetTableTypeForDatabase(const YQLDatabase database_type); |
70 | | |
71 | | Result<bool> NamespaceMatchesIdentifier( |
72 | | const NamespaceId& namespace_id, YQLDatabase db_type, const NamespaceName& namespace_name, |
73 | | const NamespaceIdentifierPB& ns_identifier); |
74 | | |
75 | | Result<bool> TableMatchesIdentifier(const TableId& id, |
76 | | const SysTablesEntryPB& table, |
77 | | const TableIdentifierPB& table_identifier); |
78 | | |
79 | | CHECKED_STATUS SetupError(MasterErrorPB* error, const Status& s); |
80 | | |
81 | | } // namespace master |
82 | | } // namespace yb |
83 | | |
84 | | #endif // YB_MASTER_MASTER_UTIL_H |