diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-09-16 01:27:05 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-09-16 01:27:05 -0700 |
| commit | 913a16268d595f591dd46bf5fb43a09514b30f7d (patch) | |
| tree | ab6e34b11576ed9da2fd23f75e512c067c7522fa | |
| parent | c9202c4b3d5db57a8ab1ee8c87de2f8a01973261 (diff) | |
| download | seaweedfs-913a16268d595f591dd46bf5fb43a09514b30f7d.tar.xz seaweedfs-913a16268d595f591dd46bf5fb43a09514b30f7d.zip | |
volume: load configuration from master at the start
fix https://github.com/chrislusf/seaweedfs/issues/1469
| -rw-r--r-- | weed/server/volume_grpc_client_to_master.go | 22 | ||||
| -rw-r--r-- | weed/server/volume_server.go | 3 |
2 files changed, 25 insertions, 0 deletions
diff --git a/weed/server/volume_grpc_client_to_master.go b/weed/server/volume_grpc_client_to_master.go index 7f3a1635c..05b7d9dca 100644 --- a/weed/server/volume_grpc_client_to_master.go +++ b/weed/server/volume_grpc_client_to_master.go @@ -2,6 +2,7 @@ package weed_server import ( "fmt" + "github.com/chrislusf/seaweedfs/weed/operation" "time" "google.golang.org/grpc" @@ -21,6 +22,27 @@ import ( func (vs *VolumeServer) GetMaster() string { return vs.currentMaster } + +func (vs *VolumeServer) checkWithMaster() (err error) { + for _, master := range vs.SeedMasterNodes { + err = operation.WithMasterServerClient(master, vs.grpcDialOption, func(masterClient master_pb.SeaweedClient) error { + resp, err := masterClient.GetMasterConfiguration(context.Background(), &master_pb.GetMasterConfigurationRequest{}) + if err != nil { + return fmt.Errorf("get master %s configuration: %v", master, err) + } + vs.MetricsAddress, vs.MetricsIntervalSec = resp.MetricsAddress, int(resp.MetricsIntervalSeconds) + backend.LoadFromPbStorageBackends(resp.StorageBackends) + return nil + }) + if err == nil { + return + } else { + glog.V(0).Infof("checkWithMaster %s: %v", master, err) + } + } + return +} + func (vs *VolumeServer) heartbeat() { glog.V(0).Infof("Volume server start with seed master nodes: %v", vs.SeedMasterNodes) diff --git a/weed/server/volume_server.go b/weed/server/volume_server.go index e9d815579..787cedc65 100644 --- a/weed/server/volume_server.go +++ b/weed/server/volume_server.go @@ -72,6 +72,9 @@ func NewVolumeServer(adminMux, publicMux *http.ServeMux, ip string, stopChan: make(chan bool), } vs.SeedMasterNodes = masterNodes + + vs.checkWithMaster() + vs.store = storage.NewStore(vs.grpcDialOption, port, ip, publicUrl, folders, maxCounts, minFreeSpacePercents, vs.needleMapKind) vs.guard = security.NewGuard(whiteList, signingKey, expiresAfterSec, readSigningKey, readExpiresAfterSec) |
