diff --git a/weed/topology/node.go b/weed/topology/node.go index a23729dd3..4556b4165 100644 --- a/weed/topology/node.go +++ b/weed/topology/node.go @@ -242,9 +242,9 @@ func (n *NodeImpl) CollectDeadNodeAndFullVolumes(freshThreshHold int64, volumeSi for _, v := range dn.GetVolumes() { if v.Size >= volumeSizeLimit { //fmt.Println("volume",v.Id,"size",v.Size,">",volumeSizeLimit) - n.GetTopology().chanFullVolumes <- &v + n.GetTopology().chanFullVolumes <- v }else if float64(v.Size) > float64(volumeSizeLimit) * growThreshold { - n.GetTopology().chanCrowdedVolumes <- &v + n.GetTopology().chanCrowdedVolumes <- v } } } diff --git a/weed/topology/topology.go b/weed/topology/topology.go index 3932e3fbb..d704a5636 100644 --- a/weed/topology/topology.go +++ b/weed/topology/topology.go @@ -34,8 +34,8 @@ type Topology struct { Sequence sequence.Sequencer - chanFullVolumes chan *storage.VolumeInfo - chanCrowdedVolumes chan *storage.VolumeInfo + chanFullVolumes chan storage.VolumeInfo + chanCrowdedVolumes chan storage.VolumeInfo Configuration *Configuration @@ -57,8 +57,8 @@ func NewTopology(id string, seq sequence.Sequencer, volumeSizeLimit uint64, puls t.Sequence = seq - t.chanFullVolumes = make(chan *storage.VolumeInfo) - t.chanCrowdedVolumes = make(chan *storage.VolumeInfo) + t.chanFullVolumes = make(chan storage.VolumeInfo) + t.chanCrowdedVolumes = make(chan storage.VolumeInfo) t.Configuration = &Configuration{} diff --git a/weed/topology/topology_event_handling.go b/weed/topology/topology_event_handling.go index 2f4fba932..0f1db74df 100644 --- a/weed/topology/topology_event_handling.go +++ b/weed/topology/topology_event_handling.go @@ -39,7 +39,7 @@ func (t *Topology) StartRefreshWritableVolumes(grpcDialOption grpc.DialOption, g } }() } -func (t *Topology) SetVolumeCapacityFull(volumeInfo *storage.VolumeInfo) bool { +func (t *Topology) SetVolumeCapacityFull(volumeInfo storage.VolumeInfo) bool { diskType := types.ToDiskType(volumeInfo.DiskType) vl := t.GetVolumeLayout(volumeInfo.Collection, volumeInfo.ReplicaPlacement, volumeInfo.Ttl, diskType) if !vl.SetVolumeCapacityFull(volumeInfo.Id) { @@ -68,7 +68,7 @@ func (t *Topology) SetVolumeCapacityFull(volumeInfo *storage.VolumeInfo) bool { return true } -func (t *Topology) SetVolumeCrowded(volumeInfo *storage.VolumeInfo) { +func (t *Topology) SetVolumeCrowded(volumeInfo storage.VolumeInfo) { diskType := types.ToDiskType(volumeInfo.DiskType) vl := t.GetVolumeLayout(volumeInfo.Collection, volumeInfo.ReplicaPlacement, volumeInfo.Ttl, diskType) vl.SetVolumeCrowded(volumeInfo.Id) diff --git a/weed/topology/volume_layout.go b/weed/topology/volume_layout.go index 57e511fa0..f315cb7e4 100644 --- a/weed/topology/volume_layout.go +++ b/weed/topology/volume_layout.go @@ -108,7 +108,7 @@ type VolumeLayout struct { diskType types.DiskType vid2location map[needle.VolumeId]*VolumeLocationList writables []needle.VolumeId // transient array of writable volume id - crowded map[needle.VolumeId]interface{} + crowded map[needle.VolumeId]struct{} readonlyVolumes *volumesBinaryState // readonly volumes oversizedVolumes *volumesBinaryState // oversized volumes volumeSizeLimit uint64 @@ -129,7 +129,7 @@ func NewVolumeLayout(rp *super_block.ReplicaPlacement, ttl *needle.TTL, diskType diskType: diskType, vid2location: make(map[needle.VolumeId]*VolumeLocationList), writables: *new([]needle.VolumeId), - crowded: make(map[needle.VolumeId]interface{}), + crowded: make(map[needle.VolumeId]struct{}), readonlyVolumes: NewVolumesBinaryState(readOnlyState, rp, ExistCopies()), oversizedVolumes: NewVolumesBinaryState(oversizedState, rp, ExistCopies()), volumeSizeLimit: volumeSizeLimit, @@ -421,7 +421,7 @@ func (vl *VolumeLayout) removeFromCrowded(vid needle.VolumeId) { func (vl *VolumeLayout) setVolumeCrowded(vid needle.VolumeId) { if _, ok := vl.crowded[vid]; !ok { - vl.crowded[vid] = nil + vl.crowded[vid] = struct{}{} glog.V(0).Infoln("Volume", vid, "becomes crowded") } }