mirror of
https://github.com/ceph/ceph
synced 2025-02-22 18:47:18 +00:00
message: MMonSync: Monitor Synchronization message
The monitor's synchronization process requires a specific message type to carry the required informations. Since this process significantly differs from slurping, reusing the MMonProbe message is not an option as it would require major changes and, for all intetions and purposes, it would be far outside the scope of the MMonProbe message. Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
This commit is contained in:
parent
d8a5cf6b4f
commit
6db25a3885
@ -1768,6 +1768,7 @@ noinst_HEADERS = \
|
||||
messages/MMonProbe.h\
|
||||
messages/MMonSubscribe.h\
|
||||
messages/MMonSubscribeAck.h\
|
||||
messages/MMonSync.h \
|
||||
messages/MOSDAlive.h\
|
||||
messages/MOSDBoot.h\
|
||||
messages/MOSDFailure.h\
|
||||
|
218
src/messages/MMonSync.h
Normal file
218
src/messages/MMonSync.h
Normal file
@ -0,0 +1,218 @@
|
||||
// -*- 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) 2012 Inktank, Inc.
|
||||
*
|
||||
* 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_MMONSYNC_H
|
||||
#define CEPH_MMONSYNC_H
|
||||
|
||||
#include "msg/Message.h"
|
||||
|
||||
class MMonSync : public Message
|
||||
{
|
||||
static const int HEAD_VERSION = 1;
|
||||
static const int COMPAT_VERSION = 1;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Operation types
|
||||
*/
|
||||
enum {
|
||||
/**
|
||||
* Start synchronization request
|
||||
* (mon.X -> Leader)
|
||||
*/
|
||||
OP_START = 1,
|
||||
/**
|
||||
* Reply to an OP_START
|
||||
* (Leader -> mon.X)
|
||||
*/
|
||||
OP_START_REPLY = 2,
|
||||
/**
|
||||
* Let the Leader know we are still synchronizing
|
||||
* (mon.X -> Leader)
|
||||
*/
|
||||
OP_HEARTBEAT = 3,
|
||||
/**
|
||||
* Reply to a hearbeat
|
||||
* (Leader -> mon.X)
|
||||
*/
|
||||
OP_HEARTBEAT_REPLY = 4,
|
||||
/**
|
||||
* Let the Leader know we finished synchronizing
|
||||
* (mon.X -> Leader)
|
||||
*/
|
||||
OP_FINISH = 5,
|
||||
/**
|
||||
* Request a given monitor (mon.Y) to start synchronizing with us, hence
|
||||
* sending us chunks.
|
||||
* (mon.X -> mon.Y)
|
||||
*/
|
||||
OP_START_CHUNKS = 6,
|
||||
/**
|
||||
* Send a chunk to a given monitor (mon.X)
|
||||
* (mon.Y -> mon.X)
|
||||
*/
|
||||
OP_CHUNK = 7,
|
||||
/**
|
||||
* Acknowledge that we received the last chunk sent
|
||||
* (mon.X -> mon.Y)
|
||||
*/
|
||||
OP_CHUNK_REPLY = 8,
|
||||
/**
|
||||
* Reply to an OP_FINISH
|
||||
* (Leader -> mon.X)
|
||||
*/
|
||||
OP_FINISH_REPLY = 9,
|
||||
/**
|
||||
* Let the receiver know that he should abort whatever he is in the middle
|
||||
* of doing with the sender.
|
||||
*/
|
||||
OP_ABORT = 10,
|
||||
};
|
||||
|
||||
/**
|
||||
* Chunk is the last available
|
||||
*/
|
||||
const static uint8_t FLAG_LAST = 0x01;
|
||||
/**
|
||||
* Let the other monitor it should retry again its last operation.
|
||||
*/
|
||||
const static uint8_t FLAG_RETRY = 0x02;
|
||||
/**
|
||||
* This message contains a crc
|
||||
*/
|
||||
const static uint8_t FLAG_CRC = 0x04;
|
||||
/**
|
||||
* Do not reply to this message to the sender, but to @p reply_to.
|
||||
*/
|
||||
const static uint8_t FLAG_REPLY_TO = 0x08;
|
||||
|
||||
/**
|
||||
* Obtain a string corresponding to the operation type @p op
|
||||
*
|
||||
* @param op Operation type
|
||||
* @returns A string
|
||||
*/
|
||||
static const char *get_opname(int op) {
|
||||
switch (op) {
|
||||
case OP_START: return "start";
|
||||
case OP_START_REPLY: return "start_reply";
|
||||
case OP_HEARTBEAT: return "heartbeat";
|
||||
case OP_HEARTBEAT_REPLY: return "heartbeat_reply";
|
||||
case OP_FINISH: return "finish";
|
||||
case OP_FINISH_REPLY: return "finish_reply";
|
||||
case OP_START_CHUNKS: return "start_chunks";
|
||||
case OP_CHUNK: return "chunk";
|
||||
case OP_CHUNK_REPLY: return "chunk_reply";
|
||||
case OP_ABORT: return "abort";
|
||||
default: assert("unknown op type"); return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t op;
|
||||
uint8_t flags;
|
||||
version_t version;
|
||||
bufferlist chunk_bl;
|
||||
pair<string,string> last_key;
|
||||
__u32 crc;
|
||||
entity_inst_t reply_to;
|
||||
|
||||
MMonSync()
|
||||
: Message(MSG_MON_SYNC, HEAD_VERSION, COMPAT_VERSION)
|
||||
{ }
|
||||
|
||||
MMonSync(uint32_t op)
|
||||
: Message(MSG_MON_SYNC, HEAD_VERSION, COMPAT_VERSION),
|
||||
op(op), flags(0), version(0)
|
||||
{ }
|
||||
|
||||
MMonSync(uint32_t op, bufferlist bl, uint8_t flags = 0)
|
||||
: Message(MSG_MON_SYNC, HEAD_VERSION, COMPAT_VERSION),
|
||||
op(op), flags(flags), version(0), chunk_bl(bl)
|
||||
{ }
|
||||
|
||||
MMonSync(MMonSync *m)
|
||||
: Message(MSG_MON_SYNC, HEAD_VERSION, COMPAT_VERSION),
|
||||
op(m->op), flags(m->flags), version(m->version),
|
||||
chunk_bl(m->chunk_bl), last_key(m->last_key),
|
||||
crc(m->crc), reply_to(m->reply_to)
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Obtain this message type's name */
|
||||
const char *get_type_name() const { return "mon_sync"; }
|
||||
|
||||
/**
|
||||
* Print this message in a pretty format to @p out
|
||||
*
|
||||
* @param out The output stream to output to
|
||||
*/
|
||||
void print(ostream& out) const {
|
||||
out << "mon_sync( " << get_opname(op);
|
||||
|
||||
if (version > 0)
|
||||
out << " v " << version;
|
||||
|
||||
if (flags) {
|
||||
out << " flags( ";
|
||||
if (flags & FLAG_LAST)
|
||||
out << "last ";
|
||||
if (flags & FLAG_RETRY)
|
||||
out << "retry ";
|
||||
if (flags & FLAG_CRC)
|
||||
out << "crc(" << crc << ") ";
|
||||
if (flags & FLAG_REPLY_TO)
|
||||
out << "reply-to(" << reply_to << ") ";
|
||||
out << ")";
|
||||
}
|
||||
|
||||
if (chunk_bl.length())
|
||||
out << " bl " << chunk_bl.length() << " bytes";
|
||||
|
||||
if (!last_key.first.empty() || !last_key.second.empty()) {
|
||||
out << " last_key ( " << last_key.first << ","
|
||||
<< last_key.second << " )";
|
||||
}
|
||||
|
||||
out << " )";
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode this message into the Message's payload
|
||||
*/
|
||||
void encode_payload(uint64_t features) {
|
||||
::encode(op, payload);
|
||||
::encode(flags, payload);
|
||||
::encode(version, payload);
|
||||
::encode(chunk_bl, payload);
|
||||
::encode(last_key.first, payload);
|
||||
::encode(last_key.second, payload);
|
||||
::encode(crc, payload);
|
||||
::encode(reply_to, payload);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode the message's payload into this message
|
||||
*/
|
||||
void decode_payload() {
|
||||
bufferlist::iterator p = payload.begin();
|
||||
::decode(op, p);
|
||||
::decode(flags, p);
|
||||
::decode(version, p);
|
||||
::decode(chunk_bl, p);
|
||||
::decode(last_key.first, p);
|
||||
::decode(last_key.second, p);
|
||||
::decode(crc, p);
|
||||
::decode(reply_to, p);
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* CEPH_MMONSYNC_H */
|
@ -39,6 +39,7 @@ using namespace std;
|
||||
#include "messages/MMonProbe.h"
|
||||
#include "messages/MMonJoin.h"
|
||||
#include "messages/MMonElection.h"
|
||||
#include "messages/MMonSync.h"
|
||||
|
||||
#include "messages/MLog.h"
|
||||
#include "messages/MLogAck.h"
|
||||
@ -310,6 +311,9 @@ Message *decode_message(CephContext *cct, ceph_msg_header& header, ceph_msg_foot
|
||||
case MSG_MON_ELECTION:
|
||||
m = new MMonElection;
|
||||
break;
|
||||
case MSG_MON_SYNC:
|
||||
m = new MMonSync;
|
||||
break;
|
||||
|
||||
case MSG_LOG:
|
||||
m = new MLog;
|
||||
|
@ -37,6 +37,7 @@
|
||||
#define MSG_MON_PAXOS 66
|
||||
#define MSG_MON_PROBE 67
|
||||
#define MSG_MON_JOIN 68
|
||||
#define MSG_MON_SYNC 69
|
||||
|
||||
/* monitor <-> mon admin tool */
|
||||
#define MSG_MON_COMMAND 50
|
||||
|
Loading…
Reference in New Issue
Block a user