diff options
| author | chrislu <chris.lu@gmail.com> | 2022-03-26 13:33:17 -0700 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2022-03-26 13:33:17 -0700 |
| commit | 21e08986317995a89274b5fc7dad80a42006bc16 (patch) | |
| tree | ccc6f6a1c00282011697e7a7f004cfd78ec1362f /weed/command/master.go | |
| parent | 4ba7127ab1bf8fa045d623d0c6293a083f209ad7 (diff) | |
| download | seaweedfs-21e08986317995a89274b5fc7dad80a42006bc16.tar.xz seaweedfs-21e08986317995a89274b5fc7dad80a42006bc16.zip | |
refactor: change masters from a slice to a map
Diffstat (limited to 'weed/command/master.go')
| -rw-r--r-- | weed/command/master.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/weed/command/master.go b/weed/command/master.go index 9792ce0ba..e56ee19fe 100644 --- a/weed/command/master.go +++ b/weed/command/master.go @@ -132,8 +132,13 @@ func startMaster(masterOption MasterOptions, masterWhiteList []string) { myMasterAddress, peers := checkPeers(*masterOption.ip, *masterOption.port, *masterOption.portGrpc, *masterOption.peers) + masterPeers := make(map[string]pb.ServerAddress) + for _, peer := range peers { + masterPeers[peer.String()] = peer + } + r := mux.NewRouter() - ms := weed_server.NewMasterServer(r, masterOption.toMasterOption(masterWhiteList), peers) + ms := weed_server.NewMasterServer(r, masterOption.toMasterOption(masterWhiteList), masterPeers) listeningAddress := util.JoinHostPort(*masterOption.ipBind, *masterOption.port) glog.V(0).Infof("Start Seaweed Master %s at %s", util.Version(), listeningAddress) masterListener, masterLocalListner, e := util.NewIpAndLocalListeners(*masterOption.ipBind, *masterOption.port, 0) @@ -141,11 +146,6 @@ func startMaster(masterOption MasterOptions, masterWhiteList []string) { glog.Fatalf("Master startup error: %v", e) } - masterPeers := make(map[string]pb.ServerAddress) - for _, peer := range peers { - masterPeers[peer.String()] = peer - } - // start raftServer raftServerOption := &weed_server.RaftServerOption{ GrpcDialOption: security.LoadClientTLS(util.GetViper(), "grpc.master"), |
