1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef CEPH_RBD_MIRROR_TYPES_H
5 #define CEPH_RBD_MIRROR_TYPES_H
13 #include "include/rados/librados.hpp"
14 #include "include/rbd/librbd.hpp"
19 template <typename
> struct MirrorStatusUpdater
;
21 // Performance counters
23 l_rbd_mirror_journal_first
= 27000,
24 l_rbd_mirror_journal_entries
,
25 l_rbd_mirror_journal_replay_bytes
,
26 l_rbd_mirror_journal_replay_latency
,
27 l_rbd_mirror_journal_last
,
28 l_rbd_mirror_snapshot_first
,
29 l_rbd_mirror_snapshot_snapshots
,
30 l_rbd_mirror_snapshot_sync_time
,
31 l_rbd_mirror_snapshot_sync_bytes
,
32 // per-image only counters below
33 l_rbd_mirror_snapshot_remote_timestamp
,
34 l_rbd_mirror_snapshot_local_timestamp
,
35 l_rbd_mirror_snapshot_last_sync_time
,
36 l_rbd_mirror_snapshot_last_sync_bytes
,
37 l_rbd_mirror_snapshot_last
,
40 typedef std::shared_ptr
<librados::Rados
> RadosRef
;
41 typedef std::shared_ptr
<librados::IoCtx
> IoCtxRef
;
42 typedef std::shared_ptr
<librbd::Image
> ImageRef
;
45 std::string global_id
;
48 explicit ImageId(const std::string
&global_id
) : global_id(global_id
) {
50 ImageId(const std::string
&global_id
, const std::string
&id
)
51 : global_id(global_id
), id(id
) {
54 inline bool operator==(const ImageId
&rhs
) const {
55 return (global_id
== rhs
.global_id
&& id
== rhs
.id
);
57 inline bool operator<(const ImageId
&rhs
) const {
58 return global_id
< rhs
.global_id
;
62 std::ostream
&operator<<(std::ostream
&, const ImageId
&image_id
);
64 typedef std::set
<ImageId
> ImageIds
;
66 struct LocalPoolMeta
{
68 LocalPoolMeta(const std::string
& mirror_uuid
)
69 : mirror_uuid(mirror_uuid
) {
72 std::string mirror_uuid
;
75 std::ostream
& operator<<(std::ostream
& lhs
,
76 const LocalPoolMeta
& local_pool_meta
);
78 struct RemotePoolMeta
{
80 RemotePoolMeta(const std::string
& mirror_uuid
,
81 const std::string
& mirror_peer_uuid
)
82 : mirror_uuid(mirror_uuid
),
83 mirror_peer_uuid(mirror_peer_uuid
) {
86 std::string mirror_uuid
;
87 std::string mirror_peer_uuid
;
90 std::ostream
& operator<<(std::ostream
& lhs
,
91 const RemotePoolMeta
& remote_pool_meta
);
96 mutable librados::IoCtx io_ctx
;
97 RemotePoolMeta remote_pool_meta
;
98 MirrorStatusUpdater
<I
>* mirror_status_updater
= nullptr;
102 Peer(const std::string
& uuid
,
103 librados::IoCtx
& io_ctx
,
104 const RemotePoolMeta
& remote_pool_meta
,
105 MirrorStatusUpdater
<I
>* mirror_status_updater
)
107 remote_pool_meta(remote_pool_meta
),
108 mirror_status_updater(mirror_status_updater
) {
111 inline bool operator<(const Peer
&rhs
) const {
112 return uuid
< rhs
.uuid
;
116 template <typename I
>
117 std::ostream
& operator<<(std::ostream
& lhs
, const Peer
<I
>& peer
) {
118 return lhs
<< peer
.remote_pool_meta
;
122 PeerSpec() = default;
123 PeerSpec(const std::string
&uuid
, const std::string
&cluster_name
,
124 const std::string
&client_name
)
125 : uuid(uuid
), cluster_name(cluster_name
), client_name(client_name
)
128 PeerSpec(const librbd::mirror_peer_site_t
&peer
) :
130 cluster_name(peer
.site_name
),
131 client_name(peer
.client_name
)
136 std::string cluster_name
;
137 std::string client_name
;
139 /// optional config properties
140 std::string mon_host
;
143 bool operator==(const PeerSpec
& rhs
) const {
144 return (uuid
== rhs
.uuid
&&
145 cluster_name
== rhs
.cluster_name
&&
146 client_name
== rhs
.client_name
&&
147 mon_host
== rhs
.mon_host
&&
150 bool operator<(const PeerSpec
& rhs
) const {
151 if (uuid
!= rhs
.uuid
) {
152 return uuid
< rhs
.uuid
;
153 } else if (cluster_name
!= rhs
.cluster_name
) {
154 return cluster_name
< rhs
.cluster_name
;
155 } else if (client_name
!= rhs
.client_name
) {
156 return client_name
< rhs
.client_name
;
157 } else if (mon_host
< rhs
.mon_host
) {
158 return mon_host
< rhs
.mon_host
;
160 return key
< rhs
.key
;
165 std::ostream
& operator<<(std::ostream
& lhs
, const PeerSpec
&peer
);
167 } // namespace mirror
171 #endif // CEPH_RBD_MIRROR_TYPES_H