2006-10-05 05:39:29 +00:00
|
|
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
|
2007-06-01 19:51:31 +00:00
|
|
|
// vim: ts=8 sw=2 smarttab
|
2006-10-05 05:39:29 +00:00
|
|
|
/*
|
|
|
|
* 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 __OSDMONITOR_H
|
|
|
|
#define __OSDMONITOR_H
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <set>
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
#include "include/types.h"
|
|
|
|
#include "msg/Messenger.h"
|
|
|
|
|
|
|
|
#include "osd/OSDMap.h"
|
|
|
|
|
2007-07-01 14:43:27 +00:00
|
|
|
#include "PaxosService.h"
|
2006-10-05 05:39:29 +00:00
|
|
|
|
2007-07-01 14:43:27 +00:00
|
|
|
class Monitor;
|
|
|
|
class MOSDBoot;
|
2006-10-05 05:39:29 +00:00
|
|
|
|
2007-07-01 14:43:27 +00:00
|
|
|
class OSDMonitor : public PaxosService {
|
2006-10-24 16:55:51 +00:00
|
|
|
public:
|
2006-10-11 21:36:16 +00:00
|
|
|
OSDMap osdmap;
|
2006-10-05 05:39:29 +00:00
|
|
|
|
2006-10-24 16:55:51 +00:00
|
|
|
private:
|
2007-08-25 19:14:14 +00:00
|
|
|
map<entity_inst_t, pair<epoch_t,epoch_t> > waiting_for_map; // who -> (has, wants)
|
2006-10-09 19:10:44 +00:00
|
|
|
|
|
|
|
// [leader]
|
|
|
|
OSDMap::Incremental pending_inc;
|
|
|
|
map<int,utime_t> down_pending_out; // osd down -> out
|
|
|
|
|
2007-09-28 21:07:08 +00:00
|
|
|
map<int,double> osd_weight;
|
|
|
|
|
2007-10-23 21:53:24 +00:00
|
|
|
void build_crush_map(CrushWrapper& crush,
|
2007-09-28 21:07:08 +00:00
|
|
|
map<int,double>& weights);
|
|
|
|
|
2007-07-01 14:43:27 +00:00
|
|
|
// svc
|
|
|
|
void create_initial();
|
|
|
|
bool update_from_paxos();
|
|
|
|
void create_pending(); // prepare a new pending
|
|
|
|
void encode_pending(bufferlist &bl);
|
2006-10-09 19:10:44 +00:00
|
|
|
|
2007-09-09 23:47:09 +00:00
|
|
|
void committed();
|
|
|
|
|
2007-07-01 14:43:27 +00:00
|
|
|
void handle_query(Message *m);
|
|
|
|
bool preprocess_query(Message *m); // true if processed.
|
|
|
|
bool prepare_update(Message *m);
|
2007-08-27 02:49:41 +00:00
|
|
|
bool should_propose(double &delay);
|
2006-10-09 19:10:44 +00:00
|
|
|
|
2007-07-01 14:43:27 +00:00
|
|
|
// ...
|
|
|
|
bool get_map_bl(epoch_t epoch, bufferlist &bl);
|
|
|
|
bool get_inc_map_bl(epoch_t epoch, bufferlist &bl);
|
2006-10-05 05:39:29 +00:00
|
|
|
|
2007-07-01 14:43:27 +00:00
|
|
|
void send_to_waiting(); // send current map to waiters.
|
2007-02-17 22:49:47 +00:00
|
|
|
void send_full(entity_inst_t dest);
|
2007-07-17 21:38:28 +00:00
|
|
|
void send_incremental(entity_inst_t dest, epoch_t since);
|
2006-10-05 05:39:29 +00:00
|
|
|
void bcast_latest_mds();
|
|
|
|
void bcast_latest_osd();
|
2007-07-01 14:43:27 +00:00
|
|
|
void bcast_full_osd();
|
|
|
|
|
2006-10-05 05:39:29 +00:00
|
|
|
void handle_osd_getmap(class MOSDGetMap *m);
|
|
|
|
|
2007-07-01 14:43:27 +00:00
|
|
|
bool preprocess_failure(class MOSDFailure *m);
|
|
|
|
bool prepare_failure(class MOSDFailure *m);
|
|
|
|
void _reported_failure(MOSDFailure *m);
|
|
|
|
|
|
|
|
bool preprocess_boot(class MOSDBoot *m);
|
|
|
|
bool prepare_boot(class MOSDBoot *m);
|
|
|
|
void _booted(MOSDBoot *m);
|
|
|
|
|
|
|
|
class C_Booted : public Context {
|
|
|
|
OSDMonitor *cmon;
|
|
|
|
MOSDBoot *m;
|
|
|
|
public:
|
|
|
|
C_Booted(OSDMonitor *cm, MOSDBoot *m_) :
|
|
|
|
cmon(cm), m(m_) {}
|
|
|
|
void finish(int r) {
|
|
|
|
if (r >= 0)
|
|
|
|
cmon->_booted(m);
|
|
|
|
else
|
|
|
|
cmon->dispatch((Message*)m);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
class C_Reported : public Context {
|
|
|
|
OSDMonitor *cmon;
|
|
|
|
MOSDFailure *m;
|
|
|
|
public:
|
|
|
|
C_Reported(OSDMonitor *cm, MOSDFailure *m_) :
|
|
|
|
cmon(cm), m(m_) {}
|
|
|
|
void finish(int r) {
|
|
|
|
if (r >= 0)
|
|
|
|
cmon->_reported_failure(m);
|
|
|
|
else
|
|
|
|
cmon->dispatch((Message*)m);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
bool preprocess_in(class MOSDIn *m);
|
|
|
|
bool prepare_in(class MOSDIn *m);
|
|
|
|
|
|
|
|
bool preprocess_out(class MOSDOut *m);
|
|
|
|
bool prepare_out(class MOSDOut *m);
|
2006-10-09 19:10:44 +00:00
|
|
|
|
2006-10-05 05:39:29 +00:00
|
|
|
public:
|
2007-07-01 14:43:27 +00:00
|
|
|
OSDMonitor(Monitor *mn, Paxos *p) :
|
|
|
|
PaxosService(mn, p) { }
|
2006-10-05 05:39:29 +00:00
|
|
|
|
|
|
|
void tick(); // check state, take actions
|
|
|
|
|
2007-12-19 04:53:48 +00:00
|
|
|
int do_command(vector<string>& cmd, bufferlist& data,
|
|
|
|
bufferlist& rdata, string &rs);
|
|
|
|
|
2007-02-26 00:17:32 +00:00
|
|
|
void mark_all_down();
|
|
|
|
|
2007-07-17 21:38:28 +00:00
|
|
|
void send_latest(entity_inst_t i, epoch_t start=0);
|
2007-05-16 21:53:22 +00:00
|
|
|
|
2006-10-05 05:39:29 +00:00
|
|
|
void fake_osd_failure(int osd, bool down);
|
|
|
|
void fake_osdmap_update();
|
|
|
|
void fake_reorg();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|