YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/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
123k
YQLDatabase GetDatabaseType(const PB& ns) {
65
102k
  return ns.has_database_type() ? ns.database_type() : GetDefaultDatabaseType(ns.name());
66
123k
}
_ZN2yb6master15GetDatabaseTypeINS0_21NamespaceIdentifierPBEEENS_11YQLDatabaseERKT_
Line
Count
Source
64
120k
YQLDatabase GetDatabaseType(const PB& ns) {
65
100k
  return ns.has_database_type() ? ns.database_type() : GetDefaultDatabaseType(ns.name());
66
120k
}
_ZN2yb6master15GetDatabaseTypeINS0_24CreateNamespaceRequestPBEEENS_11YQLDatabaseERKT_
Line
Count
Source
64
2.08k
YQLDatabase GetDatabaseType(const PB& ns) {
65
1.91k
  return ns.has_database_type() ? ns.database_type() : GetDefaultDatabaseType(ns.name());
66
2.08k
}
Unexecuted instantiation: _ZN2yb6master15GetDatabaseTypeINS0_19SysNamespaceEntryPBEEENS_11YQLDatabaseERKT_
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