Konstantin Lebedev
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
6 additions and
4 deletions
-
weed/topology/volume_layout.go
|
|
@ -6,6 +6,7 @@ import ( |
|
|
|
"github.com/seaweedfs/seaweedfs/weed/storage/types" |
|
|
|
"math/rand" |
|
|
|
"sync" |
|
|
|
"sync/atomic" |
|
|
|
"time" |
|
|
|
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/glog" |
|
|
@ -114,7 +115,7 @@ type VolumeLayout struct { |
|
|
|
volumeSizeLimit uint64 |
|
|
|
replicationAsMin bool |
|
|
|
accessLock sync.RWMutex |
|
|
|
growRequestCount int |
|
|
|
growRequestCount int32 |
|
|
|
growRequestTime time.Time |
|
|
|
} |
|
|
|
|
|
|
@ -319,18 +320,19 @@ func (vl *VolumeLayout) PickForWrite(count uint64, option *VolumeGrowOption) (*n |
|
|
|
} |
|
|
|
|
|
|
|
func (vl *VolumeLayout) HasGrowRequest() bool { |
|
|
|
if vl.growRequestCount > 0 && vl.growRequestTime.Add(time.Minute).After(time.Now()) { |
|
|
|
if atomic.LoadInt32(&vl.growRequestCount) > 0 && |
|
|
|
vl.growRequestTime.Add(time.Minute).After(time.Now()) { |
|
|
|
return true |
|
|
|
} |
|
|
|
return false |
|
|
|
} |
|
|
|
func (vl *VolumeLayout) AddGrowRequest() { |
|
|
|
vl.growRequestTime = time.Now() |
|
|
|
vl.growRequestCount++ |
|
|
|
atomic.AddInt32(&vl.growRequestCount, 1) |
|
|
|
} |
|
|
|
func (vl *VolumeLayout) DoneGrowRequest() { |
|
|
|
vl.growRequestTime = time.Unix(0, 0) |
|
|
|
vl.growRequestCount = 0 |
|
|
|
atomic.StoreInt32(&vl.growRequestCount, 0) |
|
|
|
} |
|
|
|
|
|
|
|
func (vl *VolumeLayout) ShouldGrowVolumes(option *VolumeGrowOption) bool { |
|
|
|