1 #ifndef __FAILBACKPOLLERSERVICE_HPP__ 2 #define __FAILBACKPOLLERSERVICE_HPP__ 24 std::string primaryUrl;
26 std::atomic<bool> is_running;
27 std::mutex service_mutex;
28 std::unique_ptr<std::thread> scheduler;
31 : db(db), primaryUrl(db.getPrimaryURL()), pollingInterval(pollingInterval), is_running(false) {}
37 void reset_cluster_pointers();
39 void handle_exception(
const std::exception& e);
41 inline void log_debug(
const std::string& msg) { std::cout << msg << std::endl; }
42 inline void log_info(
const std::string& msg) { std::cout << msg << std::endl; }
43 inline void log_warn(
const std::string& msg) { std::cout << msg << std::endl; }
44 inline void log_error(
const std::string& msg) { std::cout << msg << std::endl; }
51 FailbackPollerService(
const FailbackPollerService&) =
delete;
52 FailbackPollerService&
operator=(
const FailbackPollerService&) =
delete;
static constexpr int DEFAULT_POLLING_INTERVAL
static constexpr int DEFAULT_START_DELAY
static FailbackPollerService & get_instance(const gpudb::GPUdb &db, long pollingInterval=DEFAULT_POLLING_INTERVAL)
virtual ~FailbackPollerService()
FailbackPollerService & operator=(const FailbackPollerService &)=delete
void start()
Starts the poller service.
bool isRunning()
Checks whether the poller is running and returns true or false.
void stop()
Stops the poller service.