mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
refactor
This commit is contained in:
parent
cae998eda1
commit
4ba7127ab1
|
@ -141,10 +141,15 @@ func startMaster(masterOption MasterOptions, masterWhiteList []string) {
|
||||||
glog.Fatalf("Master startup error: %v", e)
|
glog.Fatalf("Master startup error: %v", e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
masterPeers := make(map[string]pb.ServerAddress)
|
||||||
|
for _, peer := range peers {
|
||||||
|
masterPeers[peer.String()] = peer
|
||||||
|
}
|
||||||
|
|
||||||
// start raftServer
|
// start raftServer
|
||||||
raftServerOption := &weed_server.RaftServerOption{
|
raftServerOption := &weed_server.RaftServerOption{
|
||||||
GrpcDialOption: security.LoadClientTLS(util.GetViper(), "grpc.master"),
|
GrpcDialOption: security.LoadClientTLS(util.GetViper(), "grpc.master"),
|
||||||
Peers: peers,
|
Peers: masterPeers,
|
||||||
ServerAddr: myMasterAddress,
|
ServerAddr: myMasterAddress,
|
||||||
DataDir: util.ResolvePath(*masterOption.metaFolder),
|
DataDir: util.ResolvePath(*masterOption.metaFolder),
|
||||||
Topo: ms.Topo,
|
Topo: ms.Topo,
|
||||||
|
|
|
@ -19,7 +19,7 @@ import (
|
||||||
|
|
||||||
type RaftServerOption struct {
|
type RaftServerOption struct {
|
||||||
GrpcDialOption grpc.DialOption
|
GrpcDialOption grpc.DialOption
|
||||||
Peers []pb.ServerAddress
|
Peers map[string]pb.ServerAddress
|
||||||
ServerAddr pb.ServerAddress
|
ServerAddr pb.ServerAddress
|
||||||
DataDir string
|
DataDir string
|
||||||
Topo *topology.Topology
|
Topo *topology.Topology
|
||||||
|
@ -62,12 +62,8 @@ func (s StateMachine) Recovery(data []byte) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRaftServer(option *RaftServerOption) (*RaftServer, error) {
|
func NewRaftServer(option *RaftServerOption) (*RaftServer, error) {
|
||||||
peers := make(map[string]pb.ServerAddress)
|
|
||||||
for _, peer := range option.Peers {
|
|
||||||
peers[peer.String()] = peer
|
|
||||||
}
|
|
||||||
s := &RaftServer{
|
s := &RaftServer{
|
||||||
peers: peers,
|
peers: option.Peers,
|
||||||
serverAddr: option.ServerAddr,
|
serverAddr: option.ServerAddr,
|
||||||
dataDir: option.DataDir,
|
dataDir: option.DataDir,
|
||||||
topo: option.Topo,
|
topo: option.Topo,
|
||||||
|
|
Loading…
Reference in a new issue