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 | |
| 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')
| -rw-r--r-- | weed/command/benchmark.go | 2 | ||||
| -rw-r--r-- | weed/command/filer.go | 4 | ||||
| -rw-r--r-- | weed/command/iam.go | 2 | ||||
| -rw-r--r-- | weed/command/master.go | 12 | ||||
| -rw-r--r-- | weed/command/master_follower.go | 2 | ||||
| -rw-r--r-- | weed/command/server.go | 2 |
6 files changed, 12 insertions, 12 deletions
diff --git a/weed/command/benchmark.go b/weed/command/benchmark.go index af5919adf..7091463cc 100644 --- a/weed/command/benchmark.go +++ b/weed/command/benchmark.go @@ -129,7 +129,7 @@ func runBenchmark(cmd *Command, args []string) bool { defer pprof.StopCPUProfile() } - b.masterClient = wdclient.NewMasterClient(b.grpcDialOption, "client", "", "", pb.ServerAddresses(*b.masters).ToAddresses()) + b.masterClient = wdclient.NewMasterClient(b.grpcDialOption, "client", "", "", pb.ServerAddresses(*b.masters).ToAddressMap()) go b.masterClient.KeepConnectedToMaster() b.masterClient.WaitUntilConnected() diff --git a/weed/command/filer.go b/weed/command/filer.go index 4f8fd947a..0a768944b 100644 --- a/weed/command/filer.go +++ b/weed/command/filer.go @@ -29,7 +29,7 @@ var ( ) type FilerOptions struct { - masters []pb.ServerAddress + masters map[string]pb.ServerAddress mastersString *string ip *string bindIp *string @@ -171,7 +171,7 @@ func runFiler(cmd *Command, args []string) bool { }() } - f.masters = pb.ServerAddresses(*f.mastersString).ToAddresses() + f.masters = pb.ServerAddresses(*f.mastersString).ToAddressMap() f.startFiler() diff --git a/weed/command/iam.go b/weed/command/iam.go index 88b17b1a2..968d23095 100644 --- a/weed/command/iam.go +++ b/weed/command/iam.go @@ -67,7 +67,7 @@ func (iamopt *IamOptions) startIamServer() bool { } } - masters := pb.ServerAddresses(*iamopt.masters).ToAddresses() + masters := pb.ServerAddresses(*iamopt.masters).ToAddressMap() router := mux.NewRouter().SkipClean(true) _, iamApiServer_err := iamapi.NewIamApiServer(router, &iamapi.IamServerOption{ Masters: masters, 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"), diff --git a/weed/command/master_follower.go b/weed/command/master_follower.go index f182d7ce4..ec7d2758f 100644 --- a/weed/command/master_follower.go +++ b/weed/command/master_follower.go @@ -83,7 +83,7 @@ func runMasterFollower(cmd *Command, args []string) bool { func startMasterFollower(masterOptions MasterOptions) { // collect settings from main masters - masters := pb.ServerAddresses(*mf.peers).ToAddresses() + masters := pb.ServerAddresses(*mf.peers).ToAddressMap() var err error grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.master") diff --git a/weed/command/server.go b/weed/command/server.go index a1b495c5f..0cc60fd30 100644 --- a/weed/command/server.go +++ b/weed/command/server.go @@ -191,7 +191,7 @@ func runServer(cmd *Command, args []string) bool { // ip address masterOptions.ip = serverIp masterOptions.ipBind = serverBindIp - filerOptions.masters = pb.ServerAddresses(*masterOptions.peers).ToAddresses() + filerOptions.masters = pb.ServerAddresses(*masterOptions.peers).ToAddressMap() filerOptions.ip = serverIp filerOptions.bindIp = serverBindIp s3Options.bindIp = serverBindIp |
