]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/PaxosService: move upgrade_format() machinery into PaxosService
authorSage Weil <sage@inktank.com>
Thu, 20 Jun 2013 21:12:16 +0000 (14:12 -0700)
committerSage Weil <sage@inktank.com>
Tue, 25 Jun 2013 16:57:00 +0000 (09:57 -0700)
We originally did this in AuthMonitor, but it is perfect for PGMonitor too,
so make it generic.

Signed-off-by: Sage Weil <sage@inktank.com>
src/mon/AuthMonitor.cc
src/mon/AuthMonitor.h
src/mon/PaxosService.cc
src/mon/PaxosService.h

index 9adadf18378802680178d65b7780385d0ec23b40..46e81b661e0ce0eb12b834e497eef4e1fd4c486f 100644 (file)
@@ -87,8 +87,6 @@ void AuthMonitor::on_active()
 /*
   check_rotate();
 */
-
-  upgrade_format();
 }
 
 void AuthMonitor::create_initial()
@@ -200,8 +198,6 @@ void AuthMonitor::update_from_paxos(bool *need_bootstrap)
   if (last_allocated_id == 0)
     last_allocated_id = max_global_id;
 
-  format_version = get_value("format_version");
-
   dout(10) << "update_from_paxos() last_allocated_id=" << last_allocated_id
           << " max_global_id=" << max_global_id
           << " format_version " << format_version
@@ -253,10 +249,6 @@ void AuthMonitor::encode_pending(MonitorDBStore::Transaction *t)
   for (p = pending_auth.begin(); p != pending_auth.end(); ++p)
     p->encode(bl, mon->get_quorum_features());
 
-  if (format_version > 0) {
-    t->put(get_service_name(), "format_version", format_version);
-  }
-
   version_t version = get_last_committed() + 1;
   put_version(t, version, bl);
   put_last_committed(t, version);
index ab52833daec78c85bfee02ff1cd86cb505c88298..bdae645d8d0b46f6a092f99015b186943949962c 100644 (file)
@@ -112,8 +112,6 @@ private:
   uint64_t max_global_id;
   uint64_t last_allocated_id;
 
-  version_t format_version;
-
   void upgrade_format();
 
   void export_keyring(KeyRing& keyring);
@@ -151,9 +149,10 @@ private:
   bool check_rotate();
  public:
   AuthMonitor(Monitor *mn, Paxos *p, const string& service_name)
-    : PaxosService(mn, p, service_name), last_rotating_ver(0),
-      max_global_id(0), last_allocated_id(0),
-      format_version(0)
+    : PaxosService(mn, p, service_name),
+      last_rotating_ver(0),
+      max_global_id(0),
+      last_allocated_id(0)
   {}
 
   void pre_auth(MAuth *m);
index d3912e87b63a00c81c190900b0a925f91b8d7132..345fa36cb41bd2e98e5c4b8a00873f1ef20b49a8 100644 (file)
@@ -114,6 +114,7 @@ void PaxosService::refresh(bool *need_bootstrap)
   // update cached versions
   cached_first_committed = mon->store->get(get_service_name(), first_committed_name);
   cached_last_committed = mon->store->get(get_service_name(), last_committed_name);
+  format_version = get_value("format_version");
 
   dout(10) << __func__ << dendl;
 
@@ -195,6 +196,10 @@ void PaxosService::propose_pending()
   encode_pending(&t);
   have_pending = false;
 
+  if (format_version > 0) {
+    t.put(get_service_name(), "format_version", format_version);
+  }
+
   dout(30) << __func__ << " transaction dump:\n";
   JSONFormatter f(true);
   t.dump(&f);
@@ -298,6 +303,9 @@ void PaxosService::_active()
   // on this list; it is on Paxos's.
   finish_contexts(g_ceph_context, waiting_for_finished_proposal, 0);
 
+  if (is_active() && mon->is_leader())
+    upgrade_format();
+
   // NOTE: it's possible that this will get called twice if we commit
   // an old paxos value.  Implementations should be mindful of that.
   if (is_active())
index 14854e137ad294225341b424d671e2ca4980af7d..289e25c8ecff8a82698a43223133509a20c9985b 100644 (file)
@@ -85,6 +85,14 @@ class PaxosService {
   version_t trim_version;
 
 protected:
+
+  /**
+   * format of our state in leveldb, 0 for default
+   */
+  version_t format_version;
+
+
+
   /**
    * @defgroup PaxosService_h_callbacks Callback classes
    * @{
@@ -193,6 +201,7 @@ public:
       proposing(false),
       service_version(0), proposal_timer(0), have_pending(false),
       trim_version(0),
+      format_version(0),
       last_committed_name("last_committed"),
       first_committed_name("first_committed"),
       full_prefix_name("full"), full_latest_name("latest"),
@@ -428,6 +437,13 @@ public:
    */
   virtual void on_active() { }
 
+  /**
+   * this is called when activating on the leader
+   *
+   * it should conditionally upgrade the on-disk format by proposing a transaction
+   */
+  virtual void upgrade_format() { }
+
   /**
    * Called when the Paxos system enters a Leader election.
    *