From 7a493bbefa8aafe08ce9a7035c6fd0cf2e206e6c Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 28 Jan 2019 10:36:16 -0800 Subject: [PATCH] better way to detect a master isLeader --- weed/topology/topology.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/weed/topology/topology.go b/weed/topology/topology.go index 4242bfa05..ff23be1ff 100644 --- a/weed/topology/topology.go +++ b/weed/topology/topology.go @@ -50,6 +50,9 @@ func NewTopology(id string, seq sequence.Sequencer, volumeSizeLimit uint64, puls } func (t *Topology) IsLeader() bool { + if t.RaftServer!=nil { + return t.RaftServer.State() == raft.Leader + } if leader, e := t.Leader(); e == nil { return leader == t.RaftServer.Name() }