1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2013 Inktank, Inc
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
14 #ifndef CEPH_MON_QUORUM_SERVICE_H
15 #define CEPH_MON_QUORUM_SERVICE_H
19 #include "include/types.h"
20 #include "include/Context.h"
21 #include "common/RefCountedObj.h"
22 #include "common/config.h"
24 #include "mon/Monitor.h"
28 Context *tick_event = nullptr;
33 SERVICE_HEALTH = 0x01,
34 SERVICE_TIMECHECK = 0x02,
35 SERVICE_CONFIG_KEY = 0x03,
42 QuorumService(Monitor *m) :
43 tick_period(g_conf->mon_tick_interval),
51 mon->timer.cancel_event(tick_event);
56 generic_dout(10) << __func__ << dendl;
62 tick_event = new C_MonContext(mon, [this](int r) {
67 mon->timer.add_event_after(tick_period, tick_event);
70 void set_update_period(double t) {
75 return (mon->is_leader() || mon->is_peon());
78 virtual bool service_dispatch(MonOpRequestRef op) = 0;
79 virtual void service_tick() = 0;
80 virtual void service_shutdown() = 0;
82 virtual void start_epoch() = 0;
83 virtual void finish_epoch() = 0;
84 virtual void cleanup() = 0;
87 virtual ~QuorumService() { }
89 void start(epoch_t new_epoch) {
95 generic_dout(20) << "QuorumService::finish" << dendl;
99 epoch_t get_epoch() const {
103 bool dispatch(MonOpRequestRef op) {
104 return service_dispatch(op);
113 generic_dout(0) << "quorum service shutdown" << dendl;
118 virtual void init() { }
120 virtual void get_health(list<pair<health_status_t,string> >& summary,
121 list<pair<health_status_t,string> > *detail) = 0;
122 virtual int get_type() = 0;
123 virtual string get_name() const = 0;
127 #endif /* CEPH_MON_QUORUM_SERVICE_H */