reduce locks

This commit is contained in:
Chris Lu
2020-10-24 19:40:35 -07:00
parent e9d40b80b2
commit 9104cfa744
2 changed files with 33 additions and 17 deletions

View File

@@ -206,11 +206,12 @@ func (s *Store) CollectHeartbeat() *master_pb.Heartbeat {
maxVolumeCount = maxVolumeCount + location.MaxVolumeCount
location.volumesLock.RLock()
for _, v := range location.volumes {
if maxFileKey < v.MaxFileKey() {
maxFileKey = v.MaxFileKey()
curMaxFileKey, volumeMessage := v.ToVolumeInformationMessage()
if maxFileKey < curMaxFileKey {
maxFileKey = curMaxFileKey
}
if !v.expired(s.GetVolumeSizeLimit()) {
volumeMessages = append(volumeMessages, v.ToVolumeInformationMessage())
if !v.expired(volumeMessage.Size, s.GetVolumeSizeLimit()) {
volumeMessages = append(volumeMessages, volumeMessage)
} else {
if v.expiredLongEnough(MAX_TTL_VOLUME_REMOVAL_DELAY) {
deleteVids = append(deleteVids, v.Id)
@@ -218,8 +219,7 @@ func (s *Store) CollectHeartbeat() *master_pb.Heartbeat {
glog.V(0).Infoln("volume", v.Id, "is expired.")
}
}
fileSize, _, _ := v.FileStat()
collectionVolumeSize[v.Collection] += fileSize
collectionVolumeSize[v.Collection] += volumeMessage.Size
if v.IsReadOnly() {
collectionVolumeReadOnlyCount[v.Collection] += 1
}