Browse Source

refactor

pull/2827/head
chrislu 3 years ago
parent
commit
4ba7127ab1
  1. 7
      weed/command/master.go
  2. 8
      weed/server/raft_server.go

7
weed/command/master.go

@ -141,10 +141,15 @@ 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"),
Peers: peers,
Peers: masterPeers,
ServerAddr: myMasterAddress,
DataDir: util.ResolvePath(*masterOption.metaFolder),
Topo: ms.Topo,

8
weed/server/raft_server.go

@ -19,7 +19,7 @@ import (
type RaftServerOption struct {
GrpcDialOption grpc.DialOption
Peers []pb.ServerAddress
Peers map[string]pb.ServerAddress
ServerAddr pb.ServerAddress
DataDir string
Topo *topology.Topology
@ -62,12 +62,8 @@ func (s StateMachine) Recovery(data []byte) error {
}
func NewRaftServer(option *RaftServerOption) (*RaftServer, error) {
peers := make(map[string]pb.ServerAddress)
for _, peer := range option.Peers {
peers[peer.String()] = peer
}
s := &RaftServer{
peers: peers,
peers: option.Peers,
serverAddr: option.ServerAddr,
dataDir: option.DataDir,
topo: option.Topo,

Loading…
Cancel
Save