}
}
-void AuthMonitor::update_trim()
+version_t AuthMonitor::get_trim_to()
{
unsigned max = g_conf->paxos_max_join_drift * 2;
version_t version = get_last_committed();
if (mon->is_leader() && (version > max))
- set_trim_to(version - max);
+ return version - max;
+ return 0;
}
bool AuthMonitor::preprocess_query(PaxosServiceMessage *m)
// propose pending update to peers
void encode_pending(MonitorDBStore::Transaction *t);
virtual void encode_full(MonitorDBStore::Transaction *t);
- void update_trim();
+ version_t get_trim_to();
bool preprocess_query(PaxosServiceMessage *m); // true if processed.
bool prepare_update(PaxosServiceMessage *m);
put_version_latest_full(t, summary.version);
}
-void LogMonitor::update_trim()
+version_t LogMonitor::get_trim_to()
{
unsigned max = g_conf->mon_max_log_epochs;
version_t version = get_last_committed();
if (mon->is_leader() && version > max)
- set_trim_to(version - max);
+ return version - max;
+ return 0;
}
bool LogMonitor::preprocess_query(PaxosServiceMessage *m)
// propose pending update to peers
void encode_pending(MonitorDBStore::Transaction *t);
virtual void encode_full(MonitorDBStore::Transaction *t);
- void update_trim();
+ version_t get_trim_to();
bool preprocess_query(PaxosServiceMessage *m); // true if processed.
bool prepare_update(PaxosServiceMessage *m);
mon->messenger->send_message(m, s->inst);
}
-void OSDMonitor::update_trim()
+version_t OSDMonitor::get_trim_to()
{
if (mon->pgmon()->is_readable() &&
mon->pgmon()->pg_map.creating_pgs.empty()) {
floor = 0;
}
if (floor > get_first_committed())
- if (get_trim_to() < floor)
- set_trim_to(floor);
+ return floor;
}
+ return 0;
}
void OSDMonitor::encode_trim_extra(MonitorDBStore::Transaction *tx, version_t first)
if (update_pools_status())
do_propose = true;
- update_trim();
-
if (do_propose ||
!pending_inc.new_pg_temp.empty()) // also propose if we adjusted pg_temp
propose_pending();
bool prepare_update(PaxosServiceMessage *m);
bool should_propose(double &delay);
- void update_trim();
+ version_t get_trim_to();
bool can_mark_down(int o);
bool can_mark_up(int o);
put_last_committed(t, version);
}
-void PGMonitor::update_trim()
+version_t PGMonitor::get_trim_to()
{
unsigned max = g_conf->mon_max_pgmap_epochs;
version_t version = get_last_committed();
if (mon->is_leader() && (version > max))
- set_trim_to(version - max);
+ return version - max;
+ return 0;
}
bool PGMonitor::preprocess_query(PaxosServiceMessage *m)
void handle_osd_timeouts();
void create_pending(); // prepare a new pending
// propose pending update to peers
- void update_trim();
+ version_t get_trim_to();
void update_logger();
void encode_pending(MonitorDBStore::Transaction *t);
if (!is_writeable())
return;
- update_trim();
- if (get_trim_to() == 0)
+ version_t trim_to = get_trim_to();
+ if (trim_to == 0)
return;
if (g_conf->paxos_service_trim_min > 0) {
- version_t trim_to = get_trim_to();
version_t first = get_first_committed();
if ((trim_to > 0) &&
trim_to > first &&
return; // not enough to trim
}
- dout(10) << __func__ << " trimming" << dendl;
+ dout(10) << __func__ << " trimming to " << trim_to << dendl;
MonitorDBStore::Transaction t;
- encode_trim(&t, get_trim_to());
+ encode_trim(&t, trim_to);
bufferlist bl;
t.encode(bl);
// let the service add any extra stuff
encode_trim_extra(t, trim_to_max);
-
- if (trim_to_max == trim_to)
- set_trim_to(0);
}
void PaxosService::trim(MonitorDBStore::Transaction *t,
* then have_pending should be true; otherwise, false.
*/
bool have_pending;
- /**
- * The version to trim to. If zero, we assume there is no version to be
- * trimmed; otherwise, we assume we should trim to the version held by
- * this variable.
- */
- version_t trim_version;
protected:
: mon(mn), paxos(p), service_name(name),
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"),
*/
virtual void encode_trim_extra(MonitorDBStore::Transaction *tx, version_t first) {}
- /**
- * Update our trim status. We do nothing here, because there is no
- * straightforward way to update the trim version, since that's service
- * specific. However, we do not force services to implement it, since there
- * a couple of services that do not trim anything at all, and we don't want
- * to shove this function down their throats if they are never going to use
- * it anyway.
- */
- virtual void update_trim() { }
- /**
- * Set the trim version variable to @p ver
- *
- * @param ver The version to trim to.
- */
- void set_trim_to(version_t ver) {
- trim_version = ver;
- }
/**
* Get the version we should trim to.
*
* @returns the version we should trim to; if we return zero, it should be
* assumed that there's no version to trim to.
*/
- version_t get_trim_to() {
- return trim_version;
+ virtual version_t get_trim_to() {
+ return 0;
}
/**
* @}