using ceph::timespan_str;
static ostream& _prefix(std::ostream *_dout, const Monitor &mon,
- const ConfigKeyService *service) {
+ const ConfigKeyService *service)
+{
return *_dout << "mon." << mon.name << "@" << mon.rank
- << "(" << mon.get_state_name() << ")." << service->get_name()
- << "(" << service->get_epoch() << ") ";
+ << "(" << mon.get_state_name() << ")." << service->get_name();
}
const string CONFIG_PREFIX = "mon_config_key";
ConfigKeyService::ConfigKeyService(Monitor &m, Paxos &p)
: mon(m),
- paxos(p),
- tick_period(g_conf()->mon_tick_interval)
+ paxos(p)
{}
-void ConfigKeyService::start(epoch_t new_epoch)
-{
- epoch = new_epoch;
- start_epoch();
-}
-
-void ConfigKeyService::finish()
-{
- generic_dout(20) << "ConfigKeyService::finish" << dendl;
- finish_epoch();
-}
-
-epoch_t ConfigKeyService::get_epoch() const {
- return epoch;
-}
-
bool ConfigKeyService::dispatch(MonOpRequestRef op) {
return service_dispatch(op);
}
return (mon.is_leader() || mon.is_peon());
}
-void ConfigKeyService::start_tick()
-{
- generic_dout(10) << __func__ << dendl;
-
- cancel_tick();
- if (tick_period <= 0)
- return;
-
- tick_event = new C_MonContext{&mon, [this](int r) {
- if (r < 0) {
- return;
- }
- tick();
- }};
- mon.timer.add_event_after(tick_period, tick_event);
-}
-
-void ConfigKeyService::set_update_period(double t)
-{
- tick_period = t;
-}
-
-void ConfigKeyService::cancel_tick()
-{
- if (tick_event)
- mon.timer.cancel_event(tick_event);
- tick_event = nullptr;
-}
-
-void ConfigKeyService::tick()
-{
- service_tick();
- start_tick();
-}
-
-void ConfigKeyService::shutdown()
-{
- generic_dout(0) << "quorum service shutdown" << dendl;
- cancel_tick();
- service_shutdown();
-}
-
int ConfigKeyService::store_get(const string &key, bufferlist &bl)
{
return mon.store->get(CONFIG_PREFIX, key, bl);
class ConfigKeyService
{
public:
- enum {
- SERVICE_HEALTH = 0x01,
- SERVICE_TIMECHECK = 0x02,
- SERVICE_CONFIG_KEY = 0x03,
- };
ConfigKeyService(Monitor &m, Paxos &p);
~ConfigKeyService() {}
- void start(epoch_t new_epoch);
- void finish();
- void shutdown();
-
- void init() { }
bool dispatch(MonOpRequestRef op);
bool service_dispatch(MonOpRequestRef op);
- void start_epoch() { }
- void finish_epoch() { }
- epoch_t get_epoch() const;
- void cleanup() { }
- void service_tick() { }
-
int validate_osd_destroy(const int32_t id, const uuid_d& uuid);
void do_osd_destroy(int32_t id, uuid_d& uuid);
int validate_osd_new(
std::stringstream& ss);
void do_osd_new(const uuid_d& uuid, const std::string& dmcrypt_key);
- int get_type() {
- return SERVICE_CONFIG_KEY;
- }
-
std::string get_name() const {
return "config_key";
}
void get_store_prefixes(std::set<std::string>& s) const;
-protected:
- void service_shutdown() { }
-
private:
Monitor &mon;
Paxos &paxos;
- epoch_t epoch = 0;
bool in_quorum() const;
- void start_tick();
- void cancel_tick();
- void tick();
- void set_update_period(double t);
-
- Context *tick_event = nullptr;
- double tick_period;
-
int store_get(const std::string &key, ceph::buffer::list &bl);
void store_put(const std::string &key, ceph::buffer::list &bl, Context *cb = NULL);
void store_delete(MonitorDBStore::TransactionRef t, const std::string &key);