| 697 | class LeaderElection { |
| 698 | public: |
| 699 | LeaderElection(Env& env, LogsDBStats& stats, bool noReplication, bool avoidBeingLeader, ReplicaId replicaId, LogMetadata& metadata, DataPartitions& data, ReqResp& reqResp) : |
| 700 | _env(env), |
| 701 | _stats(stats), |
| 702 | _noReplication(noReplication), |
| 703 | _avoidBeingLeader(avoidBeingLeader), |
| 704 | _replicaId(replicaId), |
| 705 | _metadata(metadata), |
| 706 | _data(data), |
| 707 | _reqResp(reqResp), |
| 708 | _state(LeadershipState::FOLLOWER), |
| 709 | _leaderLastActive(_noReplication ? 0 :ternNow()) {} |
| 710 | |
| 711 | bool isLeader() const { |
| 712 | return _state == LeadershipState::LEADER; |