mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-09-20 14:27:59 +08:00
better way to detect a master isLeader
This commit is contained in:
@@ -50,6 +50,9 @@ func NewTopology(id string, seq sequence.Sequencer, volumeSizeLimit uint64, puls
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Topology) IsLeader() bool {
|
func (t *Topology) IsLeader() bool {
|
||||||
|
if t.RaftServer!=nil {
|
||||||
|
return t.RaftServer.State() == raft.Leader
|
||||||
|
}
|
||||||
if leader, e := t.Leader(); e == nil {
|
if leader, e := t.Leader(); e == nil {
|
||||||
return leader == t.RaftServer.Name()
|
return leader == t.RaftServer.Name()
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user