/Users/deen/code/yugabyte-db/src/yb/client/tablet_server.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 | | #include <string> |
15 | | #ifndef YB_CLIENT_TABLET_SERVER_H |
16 | | #define YB_CLIENT_TABLET_SERVER_H |
17 | | |
18 | | namespace yb { |
19 | | namespace client { |
20 | | |
21 | | // In-memory representation of a remote tablet server. |
22 | | struct YBTabletServer { |
23 | | std::string uuid; |
24 | | std::string hostname; |
25 | | std::string placement_uuid; |
26 | | |
27 | | template <class PB, class CloudInfo> |
28 | 12 | static YBTabletServer FromPB(const PB& pb, const CloudInfo& cloud_info) { |
29 | 12 | return YBTabletServer { |
30 | 12 | .uuid = pb.instance_id().permanent_uuid(), |
31 | 12 | .hostname = DesiredHostPort(pb.registration().common(), cloud_info).host(), |
32 | 12 | .placement_uuid = pb.registration().common().placement_uuid(), |
33 | 12 | }; |
34 | 12 | } _ZN2yb6client14YBTabletServer6FromPBINS_6master33ListTabletServersResponsePB_EntryENS_11CloudInfoPBEEES1_RKT_RKT0_ Line | Count | Source | 28 | 6 | static YBTabletServer FromPB(const PB& pb, const CloudInfo& cloud_info) { | 29 | 6 | return YBTabletServer { | 30 | 6 | .uuid = pb.instance_id().permanent_uuid(), | 31 | 6 | .hostname = DesiredHostPort(pb.registration().common(), cloud_info).host(), | 32 | 6 | .placement_uuid = pb.registration().common().placement_uuid(), | 33 | 6 | }; | 34 | 6 | } |
_ZN2yb6client14YBTabletServer6FromPBINS_6master37ListLiveTabletServersResponsePB_EntryENS_11CloudInfoPBEEES1_RKT_RKT0_ Line | Count | Source | 28 | 6 | static YBTabletServer FromPB(const PB& pb, const CloudInfo& cloud_info) { | 29 | 6 | return YBTabletServer { | 30 | 6 | .uuid = pb.instance_id().permanent_uuid(), | 31 | 6 | .hostname = DesiredHostPort(pb.registration().common(), cloud_info).host(), | 32 | 6 | .placement_uuid = pb.registration().common().placement_uuid(), | 33 | 6 | }; | 34 | 6 | } |
|
35 | | |
36 | | template <class PB> |
37 | 6 | static YBTabletServer FromPB(const PB& pb) { |
38 | 6 | return YBTabletServer { |
39 | 6 | .uuid = pb.uuid(), |
40 | 6 | .hostname = pb.hostname(), |
41 | 6 | .placement_uuid = pb.placement_uuid(), |
42 | 6 | }; |
43 | 6 | } |
44 | | |
45 | | template <class PB> |
46 | 6 | void ToPB(PB* pb) const { |
47 | 6 | pb->set_uuid(uuid); |
48 | 6 | pb->set_hostname(hostname); |
49 | 6 | pb->set_placement_uuid(placement_uuid); |
50 | 6 | } |
51 | | }; |
52 | | |
53 | | struct YBTabletServerPlacementInfo { |
54 | | YBTabletServer server; |
55 | | std::string cloud; |
56 | | std::string region; |
57 | | std::string zone; |
58 | | bool is_primary; |
59 | | std::string public_ip; |
60 | | uint16_t pg_port; |
61 | | |
62 | | template <class PB> |
63 | 6 | static YBTabletServerPlacementInfo FromPB(const PB& pb) { |
64 | 6 | return YBTabletServerPlacementInfo { |
65 | 6 | .server = YBTabletServer::FromPB(pb), |
66 | 6 | .cloud = pb.cloud(), |
67 | 6 | .region = pb.region(), |
68 | 6 | .zone = pb.zone(), |
69 | 6 | .is_primary = pb.is_primary(), |
70 | 6 | .public_ip = pb.public_ip(), |
71 | 6 | .pg_port = static_cast<uint16_t>(pb.pg_port()), |
72 | 6 | }; |
73 | 6 | } |
74 | | |
75 | | template <class PB> |
76 | 6 | void ToPB(PB* pb) const { |
77 | 6 | server.ToPB(pb); |
78 | 6 | pb->set_cloud(cloud); |
79 | 6 | pb->set_region(region); |
80 | 6 | pb->set_zone(zone); |
81 | 6 | pb->set_is_primary(is_primary); |
82 | 6 | pb->set_public_ip(public_ip); |
83 | 6 | pb->set_pg_port(pg_port); |
84 | 6 | } |
85 | | }; |
86 | | |
87 | | } // namespace client |
88 | | } // namespace yb |
89 | | |
90 | | #endif // YB_CLIENT_TABLET_SERVER_H |