From 5daedb7e5bce9733fdd04ebd6037176f855b799c Mon Sep 17 00:00:00 2001 From: sageweil Date: Tue, 17 Jul 2007 05:07:49 +0000 Subject: [PATCH] pgmonitor shell git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1513 29311d96-e01e-0410-9327-a35deaab8ce9 --- branches/sage/pgs/Makefile | 1 + branches/sage/pgs/mon/Monitor.cc | 8 +++++ branches/sage/pgs/mon/Monitor.h | 6 +++- branches/sage/pgs/mon/PGMap.h | 30 ++++++++++++++++++ branches/sage/pgs/mon/PGMonitor.h | 52 +++++++++++++++++++++++++++++++ branches/sage/pgs/mon/mon_types.h | 2 ++ 6 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 branches/sage/pgs/mon/PGMap.h create mode 100644 branches/sage/pgs/mon/PGMonitor.h diff --git a/branches/sage/pgs/Makefile b/branches/sage/pgs/Makefile index 9c2c757032eaf..03e13425c5b5e 100644 --- a/branches/sage/pgs/Makefile +++ b/branches/sage/pgs/Makefile @@ -79,6 +79,7 @@ MON_OBJS= \ mon/OSDMonitor.o\ mon/MDSMonitor.o\ mon/ClientMonitor.o\ + mon/PGMonitor.o\ mon/Elector.o\ mon/MonitorStore.o diff --git a/branches/sage/pgs/mon/Monitor.cc b/branches/sage/pgs/mon/Monitor.cc index 55af22cb3439b..299dbaf2f11c7 100644 --- a/branches/sage/pgs/mon/Monitor.cc +++ b/branches/sage/pgs/mon/Monitor.cc @@ -37,6 +37,7 @@ #include "OSDMonitor.h" #include "MDSMonitor.h" #include "ClientMonitor.h" +#include "PGMonitor.h" #include "config.h" #undef dout @@ -65,12 +66,14 @@ void Monitor::init() osdmon = new OSDMonitor(this, &paxos_osdmap); mdsmon = new MDSMonitor(this, &paxos_mdsmap); clientmon = new ClientMonitor(this, &paxos_clientmap); + pgmon = new PGMonitor(this, &paxos_pgmap); // init paxos paxos_test.init(); paxos_osdmap.init(); paxos_mdsmap.init(); paxos_clientmap.init(); + paxos_pgmap.init(); // i'm ready! messenger->set_dispatcher(this); @@ -130,6 +133,7 @@ void Monitor::shutdown() if (osdmon) delete osdmon; if (mdsmon) delete mdsmon; if (clientmon) delete clientmon; + if (pgmon) delete pgmon; // die. messenger->shutdown(); @@ -167,11 +171,13 @@ void Monitor::win_election(epoch_t epoch, set& active) paxos_mdsmap.leader_init(); paxos_osdmap.leader_init(); paxos_clientmap.leader_init(); + paxos_pgmap.leader_init(); // init osdmon->election_finished(); mdsmon->election_finished(); clientmon->election_finished(); + pgmon->election_finished(); } void Monitor::lose_election(epoch_t epoch, int l) @@ -186,11 +192,13 @@ void Monitor::lose_election(epoch_t epoch, int l) paxos_mdsmap.peon_init(); paxos_osdmap.peon_init(); paxos_clientmap.peon_init(); + paxos_pgmap.peon_init(); // init osdmon->election_finished(); mdsmon->election_finished(); clientmon->election_finished(); + pgmon->election_finished(); } diff --git a/branches/sage/pgs/mon/Monitor.h b/branches/sage/pgs/mon/Monitor.h index 015e5797ca6df..934916760e28c 100644 --- a/branches/sage/pgs/mon/Monitor.h +++ b/branches/sage/pgs/mon/Monitor.h @@ -30,7 +30,7 @@ class MonitorStore; class OSDMonitor; class MDSMonitor; class ClientMonitor; - +class PGMonitor; class Monitor : public Dispatcher { public: @@ -90,6 +90,7 @@ public: Paxos paxos_mdsmap; Paxos paxos_osdmap; Paxos paxos_clientmap; + Paxos paxos_pgmap; friend class Paxos; @@ -97,10 +98,12 @@ public: OSDMonitor *osdmon; MDSMonitor *mdsmon; ClientMonitor *clientmon; + PGMonitor *pgmon; friend class OSDMonitor; friend class MDSMonitor; friend class ClientMonitor; + friend class PGMonitor; // messages @@ -128,6 +131,7 @@ public: paxos_mdsmap(this, w, PAXOS_MDSMAP), paxos_osdmap(this, w, PAXOS_OSDMAP), paxos_clientmap(this, w, PAXOS_CLIENTMAP), + paxos_pgmap(this, w, PAXOS_PGMAP), osdmon(0), mdsmon(0), clientmon(0) { diff --git a/branches/sage/pgs/mon/PGMap.h b/branches/sage/pgs/mon/PGMap.h new file mode 100644 index 0000000000000..dc6b500111df0 --- /dev/null +++ b/branches/sage/pgs/mon/PGMap.h @@ -0,0 +1,30 @@ +// -*- 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 + * + * 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 __PGMAP_H +#define __PGMAP_H + +#include "osd/osd_types.h" + +class PGMap { + +public: + class Incremental { + + }; + + +}; + +#endif diff --git a/branches/sage/pgs/mon/PGMonitor.h b/branches/sage/pgs/mon/PGMonitor.h new file mode 100644 index 0000000000000..917d6e272a756 --- /dev/null +++ b/branches/sage/pgs/mon/PGMonitor.h @@ -0,0 +1,52 @@ +// -*- 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 + * + * 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 __PGMONITOR_H +#define __PGMONITOR_H + +#include +#include +using namespace std; + +#include "include/types.h" +#include "msg/Messenger.h" +#include "PaxosService.h" + +#include "PGMap.h" + +class PGMonitor : public PaxosService { +public: + + +private: + PGMap pg_map; + PGMap::Incremental pending_inc; + + void create_initial(); + bool update_from_paxos(); + void create_pending(); // prepare a new pending + void encode_pending(bufferlist &bl); // propose pending update to peers + + bool preprocess_query(Message *m); // true if processed. + bool prepare_update(Message *m); + + + public: + PGMonitor(Monitor *mn, Paxos *p) : PaxosService(mn, p) { } + + //void tick(); // check state, take actions + +}; + +#endif diff --git a/branches/sage/pgs/mon/mon_types.h b/branches/sage/pgs/mon/mon_types.h index 852e42b8d983f..8d1ac92822356 100644 --- a/branches/sage/pgs/mon/mon_types.h +++ b/branches/sage/pgs/mon/mon_types.h @@ -19,6 +19,7 @@ #define PAXOS_MDSMAP 1 #define PAXOS_OSDMAP 2 #define PAXOS_CLIENTMAP 3 +#define PAXOS_PGMAP 4 inline const char *get_paxos_name(int p) { switch (p) { @@ -26,6 +27,7 @@ inline const char *get_paxos_name(int p) { case PAXOS_MDSMAP: return "mdsmap"; case PAXOS_OSDMAP: return "osdmap"; case PAXOS_CLIENTMAP: return "clientmap"; + case PAXOS_PGMAP: return "pgmap"; default: assert(0); return 0; } } -- 2.39.5