version_t version = get_version() + 1;
put_version(t, version, bl);
put_last_committed(t, version);
+}
+
+void AuthMonitor::encode_full(MonitorDBStore::Transaction *t)
+{
+ version_t version = mon->key_server.get_ver();
+ dout(10) << __func__ << " auth v " << version << dendl;
+ assert(get_version() == version);
bufferlist full_bl;
Mutex::Locker l(mon->key_server.get_lock());
if (mon->key_server.has_secrets()) {
- dout(10) << __func__ << " key server has secrets!" << dendl;
- v = 1;
+ dout(20) << __func__ << " key server has secrets!" << dendl;
+ __u8 v = 1;
::encode(v, full_bl);
::encode(max_global_id, full_bl);
::encode(mon->key_server, full_bl);
put_version_full(t, version, full_bl);
put_version_latest_full(t, version);
- } else
- dout(10) << __func__ << " key server has no secrets; do not put them in tx" << dendl;
+ } else {
+ dout(20) << __func__
+ << " key server has no secrets; do not put them in tx" << dendl;
+ }
}
void AuthMonitor::update_trim()
uint64_t assign_global_id(MAuth *m, bool should_increase_max);
// propose pending update to peers
void encode_pending(MonitorDBStore::Transaction *t);
+ virtual void encode_full(MonitorDBStore::Transaction *t);
void update_trim();
bool preprocess_query(PaxosServiceMessage *m); // true if processed.
for (p = pending_log.begin(); p != pending_log.end(); p++)
p->second.encode(bl);
- bufferlist summary_bl;
- ::encode(summary, summary_bl);
-
put_version(t, version, bl);
put_last_committed(t, version);
+}
+
+void LogMonitor::encode_full(MonitorDBStore::Transaction *t)
+{
+ dout(10) << __func__ << " log v " << summary.version << dendl;
+ assert(get_version() == summary.version);
+
+ bufferlist summary_bl;
+ ::encode(summary, summary_bl);
- put_version_full(t, version, summary_bl);
- put_version_latest_full(t, version);
+ put_version_full(t, summary.version, summary_bl);
+ put_version_latest_full(t, summary.version);
}
void LogMonitor::update_trim()
void create_pending(); // prepare a new pending
// propose pending update to peers
void encode_pending(MonitorDBStore::Transaction *t);
+ virtual void encode_full(MonitorDBStore::Transaction *t);
void update_trim();
bool preprocess_query(PaxosServiceMessage *m); // true if processed.
bool prepare_update(PaxosServiceMessage *m);
void update_from_paxos();
void create_pending();
void encode_pending(MonitorDBStore::Transaction *t);
+ // we don't require full versions; don't encode any.
+ virtual void encode_full(MonitorDBStore::Transaction *t) { }
bool should_trim() { return false; }
void encode_trim(MonitorDBStore::Transaction *t) { }
void create_pending();
void encode_pending(MonitorDBStore::Transaction *t);
+ // we always encode the full map; we have no use for full versions
+ virtual void encode_full(MonitorDBStore::Transaction *t) { }
void on_active();
/* put everything in the transaction */
put_version(t, pending_inc.epoch, bl);
put_last_committed(t, pending_inc.epoch);
+}
+void OSDMonitor::encode_full(MonitorDBStore::Transaction *t)
+{
+ dout(10) << __func__ << " osdmap e " << osdmap.epoch << dendl;
+ assert(get_version() == osdmap.epoch);
+
bufferlist osdmap_bl;
osdmap.encode(osdmap_bl);
- put_version_full(t, pending_inc.epoch, osdmap_bl);
- put_version_latest_full(t, pending_inc.epoch);
+ put_version_full(t, osdmap.epoch, osdmap_bl);
+ put_version_latest_full(t, osdmap.epoch);
}
-
void OSDMonitor::share_map_with_random_osd()
{
if (osdmap.get_num_up_osds() == 0) {
void update_from_paxos();
void create_pending(); // prepare a new pending
void encode_pending(MonitorDBStore::Transaction *t);
+ virtual void encode_full(MonitorDBStore::Transaction *t);
void on_active();
void update_msgr_features();
bufferlist bl;
pending_inc.encode(bl, mon->get_quorum_features());
- bufferlist full_bl;
- pg_map.encode(full_bl, mon->get_quorum_features());
-
put_version(t, version, bl);
put_last_committed(t, version);
+}
+
+void PGMonitor::encode_full(MonitorDBStore::Transaction *t)
+{
+ dout(10) << __func__ << " pgmap v " << pg_map.version << dendl;
+ assert(get_version() == pg_map.version);
+
+ bufferlist full_bl;
+ pg_map.encode(full_bl, mon->get_quorum_features());
- put_version_full(t, version, full_bl);
- put_version_latest_full(t, version);
+ put_version_full(t, pg_map.version, full_bl);
+ put_version_latest_full(t, pg_map.version);
}
void PGMonitor::update_trim()
// propose pending update to peers
void update_trim();
void encode_pending(MonitorDBStore::Transaction *t);
+ virtual void encode_full(MonitorDBStore::Transaction *t);
void update_logger();
bool preprocess_query(PaxosServiceMessage *m); // true if processed.
MonitorDBStore::Transaction t;
bufferlist bl;
+ update_trim();
+ if (should_stash_full())
+ encode_full(&t);
+
if (should_trim()) {
encode_trim(&t);
set_trim_to(0);
paxos->propose_new_value(bl, new C_Committed(this));
}
-
+bool PaxosService::should_stash_full()
+{
+ version_t latest_full = get_version_latest_full();
+ /* @note The first member of the condition is moot and it is here just for
+ * clarity's sake. The second member would end up returing true
+ * nonetheless because, in that event,
+ * latest_full == get_trim_to() == 0.
+ */
+ return (!latest_full || (latest_full <= get_trim_to()));
+}
void PaxosService::restart()
{
/**
* @}
*/
-
+ /**
+ * @defgroup PaxosService_h_Stash_Full
+ * @{
+ */
+ bool should_stash_full();
+ /**
+ * Encode a full version on @p t
+ *
+ * @note We force every service to implement this function, since we strongly
+ * desire the encoding of full versions.
+ * @note Services that do not trim their state, will be bound to only create
+ * one full version. Full version stashing is determined/controled by
+ * trimming: we stash a version each time a trim is bound to erase the
+ * latest full version.
+ *
+ * @param t Transaction on which the full version shall be encoded.
+ */
+ virtual void encode_full(MonitorDBStore::Transaction *t) = 0;
+ /**
+ * @}
+ */
/**
* Cancel events.