mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
add locking when adjusting topology
This commit is contained in:
parent
6f606bb350
commit
9782ace1bd
|
@ -7,6 +7,7 @@ import (
|
||||||
"pkg/operation"
|
"pkg/operation"
|
||||||
"pkg/storage"
|
"pkg/storage"
|
||||||
"pkg/topology"
|
"pkg/topology"
|
||||||
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -22,6 +23,8 @@ type VolumeGrowth struct {
|
||||||
copy2factor int
|
copy2factor int
|
||||||
copy3factor int
|
copy3factor int
|
||||||
copyAll int
|
copyAll int
|
||||||
|
|
||||||
|
accessLock sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDefaultVolumeGrowth() *VolumeGrowth {
|
func NewDefaultVolumeGrowth() *VolumeGrowth {
|
||||||
|
@ -46,6 +49,9 @@ func (vg *VolumeGrowth) GrowByType(repType storage.ReplicationType, topo *topolo
|
||||||
return 0, errors.New("Unknown Replication Type!")
|
return 0, errors.New("Unknown Replication Type!")
|
||||||
}
|
}
|
||||||
func (vg *VolumeGrowth) GrowByCountAndType(count int, repType storage.ReplicationType, topo *topology.Topology) (counter int, err error) {
|
func (vg *VolumeGrowth) GrowByCountAndType(count int, repType storage.ReplicationType, topo *topology.Topology) (counter int, err error) {
|
||||||
|
vg.accessLock.Lock()
|
||||||
|
defer vg.accessLock.Unlock()
|
||||||
|
|
||||||
counter = 0
|
counter = 0
|
||||||
switch repType {
|
switch repType {
|
||||||
case storage.Copy000:
|
case storage.Copy000:
|
||||||
|
|
Loading…
Reference in a new issue