Close will close out an open mgr session (unwind MMgrOpen).
Signed-off-by: Sage Weil <sage@redhat.com>
--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#pragma once
+
+#include "msg/Message.h"
+
+class MMgrClose : public Message
+{
+ static const int HEAD_VERSION = 1;
+ static const int COMPAT_VERSION = 1;
+
+public:
+ std::string daemon_name;
+ std::string service_name; // optional; otherwise infer from entity type
+
+ void decode_payload() override
+ {
+ bufferlist::iterator p = payload.begin();
+ decode(daemon_name, p);
+ decode(service_name, p);
+ }
+
+ void encode_payload(uint64_t features) override {
+ using ceph::encode;
+ encode(daemon_name, payload);
+ encode(service_name, payload);
+ }
+
+ const char *get_type_name() const override { return "mgrclose"; }
+ void print(ostream& out) const override {
+ out << get_type_name() << "(";
+ if (service_name.length()) {
+ out << service_name;
+ } else {
+ out << ceph_entity_type_name(get_source().type());
+ }
+ out << "." << daemon_name;
+ out << ")";
+ }
+
+ MMgrClose()
+ : Message(MSG_MGR_CLOSE, HEAD_VERSION, COMPAT_VERSION)
+ {}
+};
#include "mon/MonCommand.h"
#include "messages/MMgrOpen.h"
+#include "messages/MMgrClose.h"
#include "messages/MMgrConfigure.h"
#include "messages/MMonMgrReport.h"
#include "messages/MCommand.h"
return handle_report(static_cast<MMgrReport*>(m));
case MSG_MGR_OPEN:
return handle_open(static_cast<MMgrOpen*>(m));
+ case MSG_MGR_CLOSE:
+ return handle_close(static_cast<MMgrClose*>(m));
case MSG_COMMAND:
return handle_command(static_cast<MCommand*>(m));
default:
return true;
}
+bool DaemonServer::handle_close(MMgrClose *m)
+{
+ Mutex::Locker l(lock);
+
+ DaemonKey key;
+ if (!m->service_name.empty()) {
+ key.first = m->service_name;
+ } else {
+ key.first = ceph_entity_type_name(m->get_connection()->get_peer_type());
+ }
+ key.second = m->daemon_name;
+
+ dout(4) << "from " << m->get_connection() << " " << key << dendl;
+
+ if (daemon_state.exists(key)) {
+ DaemonStatePtr daemon = daemon_state.get(key);
+ daemon_state.rm(key);
+ {
+ Mutex::Locker l(daemon->lock);
+ if (daemon->service_daemon) {
+ pending_service_map.rm_daemon(m->service_name, m->daemon_name);
+ pending_service_map_dirty = pending_service_map.epoch;
+ }
+ }
+ }
+
+ // send same message back as a reply
+ m->get_connection()->send_message(m);
+ return true;
+}
+
bool DaemonServer::handle_report(MMgrReport *m)
{
DaemonKey key;
class MMgrReport;
class MMgrOpen;
+class MMgrClose;
class MMonMgrReport;
class MCommand;
struct MonCommand;
CryptoKey& session_key) override;
bool handle_open(MMgrOpen *m);
+ bool handle_close(MMgrClose *m);
bool handle_report(MMgrReport *m);
bool handle_command(MCommand *m);
void send_report();
#include "messages/MMgrDigest.h"
#include "messages/MMgrReport.h"
#include "messages/MMgrOpen.h"
+#include "messages/MMgrClose.h"
#include "messages/MMgrConfigure.h"
#include "messages/MMonMgrReport.h"
#include "messages/MServiceMap.h"
m = new MMgrOpen();
break;
+ case MSG_MGR_CLOSE:
+ m = new MMgrClose();
+ break;
+
case MSG_MGR_REPORT:
m = new MMgrReport();
break;
#define MSG_MON_MGR_REPORT 0x706
#define MSG_SERVICE_MAP 0x707
+#define MSG_MGR_CLOSE 0x708
+
// ======================================================
// abstract Message class