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 // Performance counters
21 l_rbd_mirror_first
= 27000,
23 l_rbd_mirror_replay_bytes
,
24 l_rbd_mirror_replay_latency
,
28 typedef std::shared_ptr
<librados::Rados
> RadosRef
;
29 typedef std::shared_ptr
<librados::IoCtx
> IoCtxRef
;
30 typedef std::shared_ptr
<librbd::Image
> ImageRef
;
33 std::string global_id
;
36 explicit ImageId(const std::string
&global_id
) : global_id(global_id
) {
38 ImageId(const std::string
&global_id
, const std::string
&id
)
39 : global_id(global_id
), id(id
) {
42 inline bool operator==(const ImageId
&rhs
) const {
43 return (global_id
== rhs
.global_id
&& id
== rhs
.id
);
45 inline bool operator<(const ImageId
&rhs
) const {
46 return global_id
< rhs
.global_id
;
50 std::ostream
&operator<<(std::ostream
&, const ImageId
&image_id
);
52 typedef std::set
<ImageId
> ImageIds
;
55 std::string peer_uuid
;
56 librados::IoCtx io_ctx
;
60 Peer(const std::string
&peer_uuid
) : peer_uuid(peer_uuid
) {
62 Peer(const std::string
&peer_uuid
, librados::IoCtx
& io_ctx
)
63 : peer_uuid(peer_uuid
), io_ctx(io_ctx
) {
66 inline bool operator<(const Peer
&rhs
) const {
67 return peer_uuid
< rhs
.peer_uuid
;
71 typedef std::set
<Peer
> Peers
;
75 PeerSpec(const std::string
&uuid
, const std::string
&cluster_name
,
76 const std::string
&client_name
)
77 : uuid(uuid
), cluster_name(cluster_name
), client_name(client_name
)
80 PeerSpec(const librbd::mirror_peer_t
&peer
) :
82 cluster_name(peer
.cluster_name
),
83 client_name(peer
.client_name
)
88 std::string cluster_name
;
89 std::string client_name
;
91 /// optional config properties
95 bool operator==(const PeerSpec
& rhs
) const {
96 return (uuid
== rhs
.uuid
&&
97 cluster_name
== rhs
.cluster_name
&&
98 client_name
== rhs
.client_name
&&
99 mon_host
== rhs
.mon_host
&&
102 bool operator<(const PeerSpec
& rhs
) const {
103 if (uuid
!= rhs
.uuid
) {
104 return uuid
< rhs
.uuid
;
105 } else if (cluster_name
!= rhs
.cluster_name
) {
106 return cluster_name
< rhs
.cluster_name
;
107 } else if (client_name
!= rhs
.client_name
) {
108 return client_name
< rhs
.client_name
;
109 } else if (mon_host
< rhs
.mon_host
) {
110 return mon_host
< rhs
.mon_host
;
112 return key
< rhs
.key
;
117 std::ostream
& operator<<(std::ostream
& lhs
, const PeerSpec
&peer
);
119 } // namespace mirror
123 #endif // CEPH_RBD_MIRROR_TYPES_H