void PaxosService::maybe_trim()
{
- if (is_writeable() && should_trim()) {
- dout(10) << __func__ << " trimming" << dendl;
-
- MonitorDBStore::Transaction t;
- encode_trim(&t);
- bufferlist bl;
- t.encode(bl);
-
- paxos->propose_new_value(bl, new C_Committed(this));
- }
-}
+ if (!is_writeable())
+ return;
-bool PaxosService::should_trim()
-{
update_trim();
if (get_trim_to() == 0)
- return false;
+ 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 ((trim_to - first) >= (version_t)g_conf->paxos_service_trim_min);
- }
- return true;
+ if ((trim_to > 0) &&
+ trim_to > first &&
+ (trim_to - first) < (version_t)g_conf->paxos_service_trim_min)
+ return; // not enough to trim
+ }
+
+ dout(10) << __func__ << " trimming" << dendl;
+
+ MonitorDBStore::Transaction t;
+ encode_trim(&t);
+ bufferlist bl;
+ t.encode(bl);
+
+ paxos->propose_new_value(bl, new C_Committed(this));
}
void PaxosService::encode_trim(MonitorDBStore::Transaction *t)
*/
virtual void encode_trim_extra(MonitorDBStore::Transaction *tx, version_t first) {}
- /**
- * decide whether we should trim service states
- */
- bool should_trim();
-
/**
* Update our trim status. We do nothing here, because there is no
* straightforward way to update the trim version, since that's service