mirror of
https://github.com/ceph/ceph
synced 2025-02-01 07:52:57 +00:00
messages: add ceph-mgr messages
Signed-off-by: John Spray <john.spray@redhat.com>
This commit is contained in:
parent
7e6b4f1fcb
commit
e3b2225f0b
@ -21,31 +21,10 @@
|
||||
#include "include/ceph_features.h"
|
||||
|
||||
class MMDSMap : public Message {
|
||||
public:
|
||||
/*
|
||||
map<epoch_t, bufferlist> maps;
|
||||
map<epoch_t, bufferlist> incremental_maps;
|
||||
static const int HEAD_VERSION = 1;
|
||||
static const int COMPAT_VERSION = 1;
|
||||
public:
|
||||
|
||||
epoch_t get_first() {
|
||||
epoch_t e = 0;
|
||||
map<epoch_t, bufferlist>::iterator i = maps.begin();
|
||||
if (i != maps.end()) e = i->first;
|
||||
i = incremental_maps.begin();
|
||||
if (i != incremental_maps.end() &&
|
||||
(e == 0 || i->first < e)) e = i->first;
|
||||
return e;
|
||||
}
|
||||
epoch_t get_last() {
|
||||
epoch_t e = 0;
|
||||
map<epoch_t, bufferlist>::reverse_iterator i = maps.rbegin();
|
||||
if (i != maps.rend()) e = i->first;
|
||||
i = incremental_maps.rbegin();
|
||||
if (i != incremental_maps.rend() &&
|
||||
(e == 0 || i->first > e)) e = i->first;
|
||||
return e;
|
||||
}
|
||||
*/
|
||||
|
||||
uuid_d fsid;
|
||||
epoch_t epoch;
|
||||
bufferlist encoded;
|
||||
@ -54,9 +33,9 @@ class MMDSMap : public Message {
|
||||
bufferlist& get_encoded() { return encoded; }
|
||||
|
||||
MMDSMap() :
|
||||
Message(CEPH_MSG_MDS_MAP) {}
|
||||
Message(CEPH_MSG_MDS_MAP, HEAD_VERSION, COMPAT_VERSION) {}
|
||||
MMDSMap(const uuid_d &f, MDSMap *mm) :
|
||||
Message(CEPH_MSG_MDS_MAP),
|
||||
Message(CEPH_MSG_MDS_MAP, HEAD_VERSION, COMPAT_VERSION),
|
||||
fsid(f) {
|
||||
epoch = mm->get_epoch();
|
||||
mm->encode(encoded, -1); // we will reencode with fewer features as necessary
|
||||
|
69
src/messages/MMgrBeacon.h
Normal file
69
src/messages/MMgrBeacon.h
Normal file
@ -0,0 +1,69 @@
|
||||
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
|
||||
// vim: ts=8 sw=2 smarttab
|
||||
/*
|
||||
* Ceph - scalable distributed file system
|
||||
*
|
||||
* Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
|
||||
*
|
||||
* This is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software
|
||||
* Foundation. See file COPYING.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CEPH_MMGRBEACON_H
|
||||
#define CEPH_MMGRBEACON_H
|
||||
|
||||
#include "messages/PaxosServiceMessage.h"
|
||||
|
||||
#include "include/types.h"
|
||||
|
||||
|
||||
class MMgrBeacon : public PaxosServiceMessage {
|
||||
|
||||
static const int HEAD_VERSION = 1;
|
||||
static const int COMPAT_VERSION = 1;
|
||||
|
||||
protected:
|
||||
uint64_t gid;
|
||||
entity_addr_t server_addr;
|
||||
|
||||
public:
|
||||
MMgrBeacon()
|
||||
: PaxosServiceMessage(MSG_MGR_BEACON, 0, HEAD_VERSION, COMPAT_VERSION)
|
||||
{
|
||||
}
|
||||
|
||||
MMgrBeacon(uint64_t gid_, entity_addr_t server_addr_)
|
||||
: PaxosServiceMessage(MSG_MGR_BEACON, 0, HEAD_VERSION, COMPAT_VERSION),
|
||||
gid(gid_), server_addr(server_addr_)
|
||||
{
|
||||
}
|
||||
|
||||
uint64_t get_gid() const { return gid; }
|
||||
entity_addr_t get_server_addr() const { return server_addr; }
|
||||
|
||||
private:
|
||||
~MMgrBeacon() {}
|
||||
|
||||
public:
|
||||
|
||||
const char *get_type_name() const { return "mgrbeacon"; }
|
||||
|
||||
void print(ostream& out) const {
|
||||
out << get_type_name() << "(" << gid << ", " << server_addr << ")";
|
||||
}
|
||||
|
||||
void encode_payload(uint64_t features) {
|
||||
paxos_encode();
|
||||
::encode(server_addr, payload, features);
|
||||
}
|
||||
void decode_payload() {
|
||||
bufferlist::iterator p = payload.begin();
|
||||
paxos_decode(p);
|
||||
::decode(server_addr, p);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
53
src/messages/MMgrConfigure.h
Normal file
53
src/messages/MMgrConfigure.h
Normal file
@ -0,0 +1,53 @@
|
||||
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
|
||||
// vim: ts=8 sw=2 smarttab
|
||||
/*
|
||||
* Ceph - scalable distributed file system
|
||||
*
|
||||
* Copyright (C) 2016 John Spray <john.spray@redhat.com>
|
||||
*
|
||||
* This is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software
|
||||
* Foundation. See file COPYING.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CEPH_MMGRCONFIGURE_H_
|
||||
#define CEPH_MMGRCONFIGURE_H_
|
||||
|
||||
#include "msg/Message.h"
|
||||
|
||||
/**
|
||||
* This message is sent from ceph-mgr to MgrClient, instructing it
|
||||
* it about what data to send back to ceph-mgr at what frequency.
|
||||
*/
|
||||
class MMgrConfigure : public Message
|
||||
{
|
||||
static const int HEAD_VERSION = 1;
|
||||
static const int COMPAT_VERSION = 1;
|
||||
|
||||
public:
|
||||
uint32_t stats_period;
|
||||
|
||||
void decode_payload()
|
||||
{
|
||||
bufferlist::iterator p = payload.begin();
|
||||
::decode(stats_period, p);
|
||||
}
|
||||
|
||||
void encode_payload(uint64_t features) {
|
||||
::encode(stats_period, payload);
|
||||
}
|
||||
|
||||
const char *get_type_name() const { return "mgrconfigure"; }
|
||||
void print(ostream& out) const {
|
||||
out << get_type_name() << "()";
|
||||
}
|
||||
|
||||
MMgrConfigure()
|
||||
: Message(MSG_MGR_CONFIGURE, HEAD_VERSION, COMPAT_VERSION)
|
||||
{}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
53
src/messages/MMgrDigest.h
Normal file
53
src/messages/MMgrDigest.h
Normal file
@ -0,0 +1,53 @@
|
||||
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
|
||||
// vim: ts=8 sw=2 smarttab
|
||||
/*
|
||||
* Ceph - scalable distributed file system
|
||||
*
|
||||
* Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
|
||||
*
|
||||
* This is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software
|
||||
* Foundation. See file COPYING.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CEPH_MMGRDIGEST_H
|
||||
#define CEPH_MMGRDIGEST_H
|
||||
|
||||
#include "msg/Message.h"
|
||||
|
||||
/**
|
||||
* The mgr digest is a way for the mgr to subscribe to things
|
||||
* other than the cluster maps, which are needed by
|
||||
*/
|
||||
class MMgrDigest : public Message {
|
||||
public:
|
||||
bufferlist mon_status_json;
|
||||
bufferlist health_json;
|
||||
|
||||
MMgrDigest() :
|
||||
Message(MSG_MGR_DIGEST) {}
|
||||
|
||||
const char *get_type_name() const { return "mgrdigest"; }
|
||||
void print(ostream& out) const {
|
||||
out << get_type_name();
|
||||
}
|
||||
|
||||
void decode_payload() {
|
||||
bufferlist::iterator p = payload.begin();
|
||||
::decode(mon_status_json, p);
|
||||
::decode(health_json, p);
|
||||
}
|
||||
void encode_payload(uint64_t features) {
|
||||
::encode(mon_status_json, payload);
|
||||
::encode(health_json, payload);
|
||||
}
|
||||
|
||||
private:
|
||||
~MMgrDigest() {}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
54
src/messages/MMgrMap.h
Normal file
54
src/messages/MMgrMap.h
Normal file
@ -0,0 +1,54 @@
|
||||
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
|
||||
// vim: ts=8 sw=2 smarttab
|
||||
/*
|
||||
* Ceph - scalable distributed file system
|
||||
*
|
||||
* Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
|
||||
*
|
||||
* This is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software
|
||||
* Foundation. See file COPYING.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CEPH_MMGRMAP_H
|
||||
#define CEPH_MMGRMAP_H
|
||||
|
||||
#include "msg/Message.h"
|
||||
#include "mon/MgrMap.h"
|
||||
|
||||
class MMgrMap : public Message {
|
||||
protected:
|
||||
MgrMap map;
|
||||
|
||||
public:
|
||||
const MgrMap & get_map() {return map;}
|
||||
|
||||
MMgrMap() :
|
||||
Message(MSG_MGR_MAP) {}
|
||||
MMgrMap(const MgrMap &map_) :
|
||||
Message(MSG_MGR_MAP), map(map_)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
~MMgrMap() {}
|
||||
|
||||
public:
|
||||
const char *get_type_name() const { return "mgrmap"; }
|
||||
void print(ostream& out) const {
|
||||
out << get_type_name() << "(e " << map.epoch << ")";
|
||||
}
|
||||
|
||||
void decode_payload() {
|
||||
bufferlist::iterator p = payload.begin();
|
||||
::decode(map, p);
|
||||
}
|
||||
void encode_payload(uint64_t features) {
|
||||
::encode(map, payload, features);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
50
src/messages/MMgrOpen.h
Normal file
50
src/messages/MMgrOpen.h
Normal file
@ -0,0 +1,50 @@
|
||||
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
|
||||
// vim: ts=8 sw=2 smarttab
|
||||
/*
|
||||
* Ceph - scalable distributed file system
|
||||
*
|
||||
* Copyright (C) 2016 John Spray <john.spray@redhat.com>
|
||||
*
|
||||
* This is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software
|
||||
* Foundation. See file COPYING.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CEPH_MMGROPEN_H_
|
||||
#define CEPH_MMGROPEN_H_
|
||||
|
||||
#include "msg/Message.h"
|
||||
|
||||
class MMgrOpen : public Message
|
||||
{
|
||||
static const int HEAD_VERSION = 1;
|
||||
static const int COMPAT_VERSION = 1;
|
||||
|
||||
public:
|
||||
|
||||
std::string daemon_name;
|
||||
|
||||
void decode_payload()
|
||||
{
|
||||
bufferlist::iterator p = payload.begin();
|
||||
::decode(daemon_name, p);
|
||||
}
|
||||
|
||||
void encode_payload(uint64_t features) {
|
||||
::encode(daemon_name, payload);
|
||||
}
|
||||
|
||||
const char *get_type_name() const { return "mgropen"; }
|
||||
void print(ostream& out) const {
|
||||
out << get_type_name() << "(" << daemon_name << ")";
|
||||
}
|
||||
|
||||
MMgrOpen()
|
||||
: Message(MSG_MGR_OPEN, HEAD_VERSION, COMPAT_VERSION)
|
||||
{}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
105
src/messages/MMgrReport.h
Normal file
105
src/messages/MMgrReport.h
Normal file
@ -0,0 +1,105 @@
|
||||
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
|
||||
// vim: ts=8 sw=2 smarttab
|
||||
/*
|
||||
* Ceph - scalable distributed file system
|
||||
*
|
||||
* Copyright (C) 2016 John Spray <john.spray@redhat.com>
|
||||
*
|
||||
* This is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software
|
||||
* Foundation. See file COPYING.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CEPH_MMGRREPORT_H_
|
||||
#define CEPH_MMGRREPORT_H_
|
||||
|
||||
#include "msg/Message.h"
|
||||
|
||||
#include "common/perf_counters.h"
|
||||
|
||||
class PerfCounterType
|
||||
{
|
||||
public:
|
||||
std::string path;
|
||||
std::string description;
|
||||
std::string nick;
|
||||
enum perfcounter_type_d type;
|
||||
|
||||
void encode(bufferlist &bl) const
|
||||
{
|
||||
// TODO: decide whether to drop the per-type
|
||||
// encoding here, we could rely on the MgrReport
|
||||
// verisoning instead.
|
||||
ENCODE_START(1, 1, bl);
|
||||
::encode(path, bl);
|
||||
::encode(description, bl);
|
||||
::encode(nick, bl);
|
||||
assert(type < 256);
|
||||
::encode((uint8_t)type, bl);
|
||||
ENCODE_FINISH(bl);
|
||||
}
|
||||
|
||||
void decode(bufferlist::iterator &p)
|
||||
{
|
||||
DECODE_START(1, p);
|
||||
::decode(path, p);
|
||||
::decode(description, p);
|
||||
::decode(nick, p);
|
||||
::decode((uint8_t&)type, p);
|
||||
DECODE_FINISH(p);
|
||||
}
|
||||
};
|
||||
WRITE_CLASS_ENCODER(PerfCounterType)
|
||||
|
||||
class MMgrReport : public Message
|
||||
{
|
||||
static const int HEAD_VERSION = 1;
|
||||
static const int COMPAT_VERSION = 1;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Client is responsible for remembering whether it has introduced
|
||||
* each perf counter to the server. When first sending a particular
|
||||
* counter, it must inline the counter's schema here.
|
||||
*/
|
||||
std::vector<PerfCounterType> declare_types;
|
||||
|
||||
// For all counters present, sorted by idx, output
|
||||
// as many bytes as are needed to represent them
|
||||
|
||||
// Decode: iterate over the types we know about, sorted by idx,
|
||||
// and use the current type's type to decide how to decode
|
||||
// the next bytes from the bufferlist.
|
||||
bufferlist packed;
|
||||
|
||||
std::string daemon_name;
|
||||
|
||||
void decode_payload()
|
||||
{
|
||||
bufferlist::iterator p = payload.begin();
|
||||
::decode(daemon_name, p);
|
||||
::decode(declare_types, p);
|
||||
::decode(packed, p);
|
||||
}
|
||||
|
||||
void encode_payload(uint64_t features) {
|
||||
::encode(daemon_name, payload);
|
||||
::encode(declare_types, payload);
|
||||
::encode(packed, payload);
|
||||
}
|
||||
|
||||
const char *get_type_name() const { return "mgrreport"; }
|
||||
void print(ostream& out) const {
|
||||
out << get_type_name() << "(" << declare_types.size() << " "
|
||||
<< packed.length() << ")";
|
||||
}
|
||||
|
||||
MMgrReport()
|
||||
: Message(MSG_MGR_REPORT, HEAD_VERSION, COMPAT_VERSION)
|
||||
{}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -156,6 +156,13 @@ using namespace std;
|
||||
#include "messages/MCacheExpire.h"
|
||||
#include "messages/MInodeFileCaps.h"
|
||||
|
||||
#include "messages/MMgrBeacon.h"
|
||||
#include "messages/MMgrMap.h"
|
||||
#include "messages/MMgrDigest.h"
|
||||
#include "messages/MMgrReport.h"
|
||||
#include "messages/MMgrOpen.h"
|
||||
#include "messages/MMgrConfigure.h"
|
||||
|
||||
#include "messages/MLock.h"
|
||||
|
||||
#include "messages/MWatchNotify.h"
|
||||
@ -706,6 +713,30 @@ Message *decode_message(CephContext *cct, int crcflags,
|
||||
m = new MLock();
|
||||
break;
|
||||
|
||||
case MSG_MGR_BEACON:
|
||||
m = new MMgrBeacon();
|
||||
break;
|
||||
|
||||
case MSG_MGR_MAP:
|
||||
m = new MMgrMap();
|
||||
break;
|
||||
|
||||
case MSG_MGR_DIGEST:
|
||||
m = new MMgrDigest();
|
||||
break;
|
||||
|
||||
case MSG_MGR_OPEN:
|
||||
m = new MMgrOpen();
|
||||
break;
|
||||
|
||||
case MSG_MGR_REPORT:
|
||||
m = new MMgrReport();
|
||||
break;
|
||||
|
||||
case MSG_MGR_CONFIGURE:
|
||||
m = new MMgrConfigure();
|
||||
break;
|
||||
|
||||
case MSG_TIMECHECK:
|
||||
m = new MTimeCheck();
|
||||
break;
|
||||
|
@ -176,6 +176,20 @@
|
||||
// Special
|
||||
#define MSG_NOP 0x607
|
||||
|
||||
// *** ceph-mgr <-> OSD/MDS daemons ***
|
||||
#define MSG_MGR_OPEN 0x700
|
||||
#define MSG_MGR_CONFIGURE 0x701
|
||||
#define MSG_MGR_REPORT 0x702
|
||||
|
||||
// *** ceph-mgr <-> ceph-mon ***
|
||||
#define MSG_MGR_BEACON 0x703
|
||||
|
||||
// *** ceph-mon(MgrMonitor) -> OSD/MDS daemons ***
|
||||
#define MSG_MGR_MAP 0x704
|
||||
|
||||
// *** ceph-mon(MgrMonitor) -> ceph-mgr
|
||||
#define MSG_MGR_DIGEST 0x705
|
||||
|
||||
// ======================================================
|
||||
|
||||
// abstract Message class
|
||||
|
Loading…
Reference in New Issue
Block a user