From 46303c36bfd3e353f70acbd756df2d47b6efe14d Mon Sep 17 00:00:00 2001 From: Konstantin Lebedev Date: Sat, 31 Oct 2020 02:48:25 +0500 Subject: [PATCH 1/2] When the volume server is stopped, the master server immediately sees the deletion of volumes --- weed/server/volume_grpc_client_to_master.go | 17 +++++++++++++++++ weed/storage/store.go | 7 ++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/weed/server/volume_grpc_client_to_master.go b/weed/server/volume_grpc_client_to_master.go index 199f8faba..b33fbcc64 100644 --- a/weed/server/volume_grpc_client_to_master.go +++ b/weed/server/volume_grpc_client_to_master.go @@ -216,6 +216,23 @@ func (vs *VolumeServer) doHeartbeat(masterNode, masterGrpcAddress string, grpcDi case err = <-doneChan: return case <-vs.stopChan: + var volumeMessages []*master_pb.VolumeInformationMessage + emptyBeat := &master_pb.Heartbeat{ + Ip: vs.store.Ip, + Port: uint32(vs.store.Port), + PublicUrl: vs.store.PublicUrl, + MaxVolumeCount: uint32(0), + MaxFileKey: uint64(0), + DataCenter: vs.store.GetDataCenter(), + Rack: vs.store.GetRack(), + Volumes: volumeMessages, + HasNoVolumes: len(volumeMessages) == 0, + } + glog.V(1).Infof("volume server %s:%d deletes all volumes", vs.store.Ip, vs.store.Port) + if err = stream.Send(emptyBeat); err != nil { + glog.V(0).Infof("Volume Server Failed to update to master %s: %v", masterNode, err) + return "", err + } return } } diff --git a/weed/storage/store.go b/weed/storage/store.go index 3a8c07e6e..946ba0df1 100644 --- a/weed/storage/store.go +++ b/weed/storage/store.go @@ -194,6 +194,12 @@ func (s *Store) SetDataCenter(dataCenter string) { func (s *Store) SetRack(rack string) { s.rack = rack } +func (s *Store) GetDataCenter() string { + return s.dataCenter +} +func (s *Store) GetRack() string { + return s.rack +} func (s *Store) CollectHeartbeat() *master_pb.Heartbeat { var volumeMessages []*master_pb.VolumeInformationMessage @@ -229,7 +235,6 @@ func (s *Store) CollectHeartbeat() *master_pb.Heartbeat { } } if v.IsReadOnly() { - collectionVolumeReadOnlyCount[v.Collection] = make(map[string]uint8) collectionVolumeReadOnlyCount[v.Collection]["IsReadOnly"] += 1 if v.noWriteOrDelete { collectionVolumeReadOnlyCount[v.Collection]["noWriteOrDelete"] += 1 From d2a4ffdd6071eb1cda383a8b0b6f1af77bef8dcb Mon Sep 17 00:00:00 2001 From: Konstantin Lebedev Date: Sat, 31 Oct 2020 03:21:54 +0500 Subject: [PATCH 2/2] glog --- weed/server/volume_grpc_client_to_master.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weed/server/volume_grpc_client_to_master.go b/weed/server/volume_grpc_client_to_master.go index b33fbcc64..84467ec1c 100644 --- a/weed/server/volume_grpc_client_to_master.go +++ b/weed/server/volume_grpc_client_to_master.go @@ -228,7 +228,7 @@ func (vs *VolumeServer) doHeartbeat(masterNode, masterGrpcAddress string, grpcDi Volumes: volumeMessages, HasNoVolumes: len(volumeMessages) == 0, } - glog.V(1).Infof("volume server %s:%d deletes all volumes", vs.store.Ip, vs.store.Port) + glog.V(1).Infof("volume server %s:%d stops and deletes all volumes", vs.store.Ip, vs.store.Port) if err = stream.Send(emptyBeat); err != nil { glog.V(0).Infof("Volume Server Failed to update to master %s: %v", masterNode, err) return "", err