void MirrorPeerClientMeta::encode(bufferlist& bl) const {
::encode(image_id, bl);
+ ::encode(static_cast<uint32_t>(state), bl);
::encode(sync_object_count, bl);
::encode(static_cast<uint32_t>(sync_points.size()), bl);
for (auto &sync_point : sync_points) {
void MirrorPeerClientMeta::decode(__u8 version, bufferlist::iterator& it) {
::decode(image_id, it);
+
+ uint32_t decode_state;
+ ::decode(decode_state, it);
+ state = static_cast<MirrorPeerState>(decode_state);
+
::decode(sync_object_count, it);
uint32_t sync_point_count;
void MirrorPeerClientMeta::dump(Formatter *f) const {
f->dump_string("image_id", image_id);
+ f->dump_stream("state") << state;
f->dump_unsigned("sync_object_count", sync_object_count);
f->open_array_section("sync_points");
for (auto &sync_point : sync_points) {
return out;
}
+std::ostream &operator<<(std::ostream &out, const MirrorPeerState &state) {
+ switch (state) {
+ case MIRROR_PEER_STATE_SYNCING:
+ out << "Syncing";
+ break;
+ case MIRROR_PEER_STATE_REPLAYING:
+ out << "Replaying";
+ break;
+ default:
+ out << "Unknown (" << static_cast<uint32_t>(state) << ")";
+ break;
+ }
+ return out;
+}
+
std::ostream &operator<<(std::ostream &out, const MirrorPeerClientMeta &meta) {
out << "[image_id=" << meta.image_id << ", "
+ << "state=" << meta.state << ", "
<< "sync_object_count=" << meta.sync_object_count << ", "
<< "sync_points=[";
std::string delimiter;
void dump(Formatter *f) const;
};
+enum MirrorPeerState {
+ MIRROR_PEER_STATE_SYNCING,
+ MIRROR_PEER_STATE_REPLAYING
+};
+
struct MirrorPeerClientMeta {
typedef std::list<MirrorPeerSyncPoint> SyncPoints;
typedef std::map<uint64_t, uint64_t> SnapSeqs;
static const ClientMetaType TYPE = MIRROR_PEER_CLIENT_META_TYPE;
std::string image_id;
+ MirrorPeerState state = MIRROR_PEER_STATE_SYNCING; ///< replay state
uint64_t sync_object_count = 0; ///< maximum number of objects ever sync'ed
SyncPoints sync_points; ///< max two in-use snapshots for sync
SnapSeqs snap_seqs; ///< local to peer snap seq mapping
inline bool operator==(const MirrorPeerClientMeta &meta) const {
return (image_id == meta.image_id &&
+ state == meta.state &&
sync_object_count == meta.sync_object_count &&
sync_points == meta.sync_points &&
snap_seqs == meta.snap_seqs);
std::ostream &operator<<(std::ostream &out, const ClientMetaType &type);
std::ostream &operator<<(std::ostream &out, const ImageClientMeta &meta);
std::ostream &operator<<(std::ostream &out, const MirrorPeerSyncPoint &sync);
+std::ostream &operator<<(std::ostream &out, const MirrorPeerState &meta);
std::ostream &operator<<(std::ostream &out, const MirrorPeerClientMeta &meta);
std::ostream &operator<<(std::ostream &out, const TagData &tag_data);