Browse Source

treat it as a single node cluster if empty raft server name

possible fix for https://github.com/chrislusf/seaweedfs/issues/1118
pull/1189/head
Chris Lu 5 years ago
parent
commit
d1ab16b6e3
  1. 11
      weed/topology/topology.go

11
weed/topology/topology.go

@ -60,7 +60,12 @@ func NewTopology(id string, seq sequence.Sequencer, volumeSizeLimit uint64, puls
func (t *Topology) IsLeader() bool { func (t *Topology) IsLeader() bool {
if t.RaftServer != nil { if t.RaftServer != nil {
return t.RaftServer.State() == raft.Leader
if t.RaftServer.State() == raft.Leader {
return true
}
if t.RaftServer.Leader() == "" {
return true
}
} }
return false return false
} }
@ -75,7 +80,7 @@ func (t *Topology) Leader() (string, error) {
if l == "" { if l == "" {
// We are a single node cluster, we are the leader // We are a single node cluster, we are the leader
return t.RaftServer.Name(), errors.New("Raft Server not initialized!")
return t.RaftServer.Name(), nil
} }
return l, nil return l, nil
@ -152,7 +157,7 @@ func (t *Topology) ListCollections(includeNormalVolumes, includeEcVolumes bool)
t.ecShardMapLock.RUnlock() t.ecShardMapLock.RUnlock()
} }
for k, _ := range mapOfCollections {
for k := range mapOfCollections {
ret = append(ret, k) ret = append(ret, k)
} }
return ret return ret

Loading…
Cancel
Save