diff options
| author | Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> | 2022-04-04 17:51:51 +0500 |
|---|---|---|
| committer | Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> | 2022-04-04 17:51:51 +0500 |
| commit | 14dd97189011d2a8802d5c9cc1726802cf19f2b2 (patch) | |
| tree | 8f25cc1b33e27c96260b491de66057f9c4d44a65 /weed/command/master.go | |
| parent | c514710b7b0454c7a070ebf30aa865c9a5ad1591 (diff) | |
| download | seaweedfs-14dd97189011d2a8802d5c9cc1726802cf19f2b2.tar.xz seaweedfs-14dd97189011d2a8802d5c9cc1726802cf19f2b2.zip | |
hashicorp raft with state machine
Diffstat (limited to 'weed/command/master.go')
| -rw-r--r-- | weed/command/master.go | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/weed/command/master.go b/weed/command/master.go index 459d3e1cb..bbf9b1de2 100644 --- a/weed/command/master.go +++ b/weed/command/master.go @@ -1,7 +1,6 @@ package command import ( - "context" "net/http" "os" "sort" @@ -166,13 +165,14 @@ func startMaster(masterOption MasterOptions, masterWhiteList []string) { var raftServer *weed_server.RaftServer var err error if *m.raftHashicorp { - ctx := context.Background() - raftServer, err = weed_server.NewHashicorpRaftServer(ctx, raftServerOption) + if raftServer, err = weed_server.NewHashicorpRaftServer(raftServerOption); err != nil { + glog.Fatalf("NewHashicorpRaftServer: %s", err) + } } else { raftServer, err = weed_server.NewRaftServer(raftServerOption) - } - if raftServer == nil { - glog.Fatalf("please verify %s is writable, see https://github.com/chrislusf/seaweedfs/issues/717: %s", *masterOption.metaFolder, err) + if raftServer == nil { + glog.Fatalf("please verify %s is writable, see https://github.com/chrislusf/seaweedfs/issues/717: %s", *masterOption.metaFolder, err) + } } ms.SetRaftServer(raftServer) r.HandleFunc("/cluster/status", raftServer.StatusHandler).Methods("GET") @@ -199,14 +199,17 @@ func startMaster(masterOption MasterOptions, masterWhiteList []string) { } go grpcS.Serve(grpcL) - go func() { - time.Sleep(1500 * time.Millisecond) - if ms.Topo.RaftServer.Leader() == "" && ms.Topo.RaftServer.IsLogEmpty() && isTheFirstOne(myMasterAddress, peers) { - if ms.MasterClient.FindLeaderFromOtherPeers(myMasterAddress) == "" { - raftServer.DoJoinCommand() + timeSleep := 1500 * time.Millisecond + if !*m.raftHashicorp { + go func() { + time.Sleep(timeSleep) + if ms.Topo.RaftServer.Leader() == "" && ms.Topo.RaftServer.IsLogEmpty() && isTheFirstOne(myMasterAddress, peers) { + if ms.MasterClient.FindLeaderFromOtherPeers(myMasterAddress) == "" { + raftServer.DoJoinCommand() + } } - } - }() + }() + } go ms.MasterClient.KeepConnectedToMaster() |
