/************************************************************************ * * Copyright (c) 2019 Alibaba.com, Inc. All Rights Reserved * $Id: paxos_option.h,v 1.0 12/19/2019 10:04:06 PM jarry.zj(jarry.zj@alibaba-inc.com) $ * ************************************************************************/ /** * @file paxos_option.h * @author jarry.zj(jarry.zj@alibaba-inc.com) * @date 12/19/2019 10:04:06 PM * @version 1.0 * @brief * **/ #ifndef paxos_option_INC #define paxos_option_INC #include #include #include namespace alisql { class Paxos; class RemoteServer; /* store extra information from upper module */ class ExtraStore { public: ExtraStore() {}; virtual ~ExtraStore() {}; /* remote info received from leader */ virtual std::string getRemote() = 0; virtual void setRemote(const std::string &) = 0; /* local info to send to others */ virtual std::string getLocal() = 0; }; class DefaultExtraStore: public ExtraStore { virtual std::string getRemote() { return ""; } virtual void setRemote(const std::string &) {} /* local info to send to others */ virtual std::string getLocal() { return ""; } }; class PaxosOption { friend class Paxos; friend class RemoteServer; public: PaxosOption() :enableLearnerHeartbeat_(false) ,enableAutoLeaderTransfer_(false) ,autoLeaderTransferCheckSeconds_(60) ,maxPipeliningEntrySize_(2ULL*1024*1024 /* default 2M */) { extraStore = std::make_shared(); } ~PaxosOption() {} private: std::atomic enableLearnerHeartbeat_; std::atomic enableAutoLeaderTransfer_; std::atomic autoLeaderTransferCheckSeconds_; std::atomic maxPipeliningEntrySize_; std::shared_ptr extraStore; }; } //namespace alisql #endif //#ifndef paxos_option_INC