}
template <typename I>
-image_replayer::HealthState GroupReplayer<I>::get_health_state() const {
- // TODO: Implement something like m_mirror_image_status_state for group
- return image_replayer::HEALTH_STATE_OK;
+group_replayer::HealthState GroupReplayer<I>::get_health_state() const {
+ std::lock_guard locker{m_lock};
+
+ if (!m_status_state) {
+ return group_replayer::HEALTH_STATE_OK;
+ } else if (*m_status_state ==
+ cls::rbd::MIRROR_GROUP_STATUS_STATE_UNKNOWN) {
+ return group_replayer::HEALTH_STATE_WARNING;
+ }
+ return group_replayer::HEALTH_STATE_ERROR;
}
template <typename I>
// chain the shut down sequence (reverse order)
Context *ctx = new LambdaContext(
[this, r](int _r) {
- set_mirror_group_status_update(m_status_state, m_state_desc);
+ set_mirror_group_status_update(*m_status_state, m_state_desc);
handle_shut_down(r);
});
m_remote_group_peer.mirror_status_updater->set_mirror_group_status(
m_global_group_id, remote_status, true);
}
+ m_status_state = local_status.state;
+ m_state_desc = local_status.description;
}
} // namespace mirror
#include "include/rados/librados.hpp"
#include "tools/rbd_mirror/Types.h"
#include "tools/rbd_mirror/group_replayer/Replayer.h"
-#include "tools/rbd_mirror/image_replayer/Types.h"
+#include "tools/rbd_mirror/group_replayer/Types.h"
#include <boost/optional.hpp>
#include <string>
#include <list>
void sync_group_names();
- image_replayer::HealthState get_health_state() const;
+ group_replayer::HealthState get_health_state() const;
void add_peer(const Peer<ImageCtxT>& peer);
}
};
+ typedef boost::optional<cls::rbd::MirrorGroupStatusState>
+ OptionalMirrorGroupStatusState;
+
librados::IoCtx &m_local_io_ctx;
std::string m_local_mirror_uuid;
std::string m_global_group_id;
mutable ceph::mutex m_lock;
State m_state = STATE_STOPPED;
std::string m_state_desc;
- cls::rbd::MirrorGroupStatusState m_status_state;
+ OptionalMirrorGroupStatusState m_status_state =
+ boost::make_optional(false, cls::rbd::MIRROR_GROUP_STATUS_STATE_UNKNOWN);
int m_last_r = 0;
Context *m_on_start_finish = nullptr;
++group_count;
auto health_state = current_it->second->get_health_state();
- if (health_state == image_replayer::HEALTH_STATE_WARNING) {
+ if (health_state == group_replayer::HEALTH_STATE_WARNING) {
++warning_count;
- } else if (health_state == image_replayer::HEALTH_STATE_ERROR) {
+ } else if (health_state == group_replayer::HEALTH_STATE_ERROR) {
++error_count;
}
#include "include/rados/librados.hpp"
#include "librbd/mirror/snapshot/Types.h"
#include "tools/rbd_mirror/Types.h"
-#include "tools/rbd_mirror/image_replayer/Replayer.h"
-#include "tools/rbd_mirror/image_replayer/Types.h"
+#include "tools/rbd_mirror/group_replayer/Types.h"
#include <string>
class Context;
--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#ifndef CEPH_RBD_MIRROR_GROUP_REPLAYER_TYPES_H
+#define CEPH_RBD_MIRROR_GROUP_REPLAYER_TYPES_H
+
+namespace rbd {
+namespace mirror {
+namespace group_replayer {
+
+enum HealthState {
+ HEALTH_STATE_OK,
+ HEALTH_STATE_WARNING,
+ HEALTH_STATE_ERROR
+};
+
+} // namespace group_replayer
+} // namespace mirror
+} // namespace rbd
+
+#endif // CEPH_RBD_MIRROR_GROUP_REPLAYER_TYPES_H