diff options
| author | Chris Lu <chris.lu@gmail.com> | 2019-07-28 03:58:13 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2019-07-28 03:58:13 -0700 |
| commit | 8afd8d35b3230f6fc286967e8aa9641bd8c1460c (patch) | |
| tree | 8c134e958969a7aec6337c8c7bab120009006941 /weed/command/master.go | |
| parent | 2c6cf72e73861f3bdefaba28189fa2b15fa26d9e (diff) | |
| download | seaweedfs-8afd8d35b3230f6fc286967e8aa9641bd8c1460c.tar.xz seaweedfs-8afd8d35b3230f6fc286967e8aa9641bd8c1460c.zip | |
master: followers can also lookup and redirect
improve scalability
Diffstat (limited to 'weed/command/master.go')
| -rw-r--r-- | weed/command/master.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/weed/command/master.go b/weed/command/master.go index fb09a24b4..3d33f4f7a 100644 --- a/weed/command/master.go +++ b/weed/command/master.go @@ -100,8 +100,11 @@ func runMaster(cmd *Command, args []string) bool { } func startMaster(masterOption MasterOptions, masterWhiteList []string) { + + myMasterAddress, peers := checkPeers(*masterOption.ip, *masterOption.port, *masterOption.peers) + r := mux.NewRouter() - ms := weed_server.NewMasterServer(r, masterOption.toMasterOption(masterWhiteList)) + ms := weed_server.NewMasterServer(r, masterOption.toMasterOption(masterWhiteList), peers) listeningAddress := *masterOption.ipBind + ":" + strconv.Itoa(*masterOption.port) glog.V(0).Infof("Start Seaweed Master %s at %s", util.VERSION, listeningAddress) masterListener, e := util.NewListener(listeningAddress, 0) @@ -109,7 +112,6 @@ func startMaster(masterOption MasterOptions, masterWhiteList []string) { glog.Fatalf("Master startup error: %v", e) } // start raftServer - myMasterAddress, peers := checkPeers(*masterOption.ip, *masterOption.port, *masterOption.peers) raftServer := weed_server.NewRaftServer(security.LoadClientTLS(viper.Sub("grpc"), "master"), peers, myMasterAddress, *masterOption.metaFolder, ms.Topo, *masterOption.pulseSeconds) if raftServer == nil { @@ -131,6 +133,8 @@ func startMaster(masterOption MasterOptions, masterWhiteList []string) { glog.V(0).Infof("Start Seaweed Master %s grpc server at %s:%d", util.VERSION, *masterOption.ipBind, grpcPort) go grpcS.Serve(grpcL) + go ms.MasterClient.KeepConnectedToMaster() + // start http server httpS := &http.Server{Handler: r} go httpS.Serve(masterListener) @@ -152,11 +156,10 @@ func checkPeers(masterIp string, masterPort int, peers string) (masterAddress st } } - peerCount := len(cleanedPeers) if !hasSelf { - peerCount += 1 + cleanedPeers = append(cleanedPeers, masterAddress) } - if peerCount%2 == 0 { + if len(cleanedPeers)%2 == 0 { glog.Fatalf("Only odd number of masters are supported!") } return |
