diff options
| author | Chris Lu <chris.lu@gmail.com> | 2014-03-10 11:43:54 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2014-03-10 11:43:54 -0700 |
| commit | cd10c277b2146a7d01449dfe8825e7f1f12d7d7d (patch) | |
| tree | 3f9bb75988e50aa2ddfc492fd45d27c6a748680f /go/topology/volume_layout.go | |
| parent | a121453188f14ac3580bf61b47268bf029d61390 (diff) | |
| download | seaweedfs-cd10c277b2146a7d01449dfe8825e7f1f12d7d7d.tar.xz seaweedfs-cd10c277b2146a7d01449dfe8825e7f1f12d7d7d.zip | |
can now delete a collection! Is this a dangerous feature? Only enabling
deleting "benchmark" collections for now.
Diffstat (limited to 'go/topology/volume_layout.go')
| -rw-r--r-- | go/topology/volume_layout.go | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/go/topology/volume_layout.go b/go/topology/volume_layout.go index 40628b4a0..1a35faa5c 100644 --- a/go/topology/volume_layout.go +++ b/go/topology/volume_layout.go @@ -8,6 +8,7 @@ import ( "sync" ) +// mapping from volume to its locations, inverted from server to volume type VolumeLayout struct { rp *storage.ReplicaPlacement vid2location map[storage.VolumeId]*VolumeLocationList @@ -56,6 +57,13 @@ func (vl *VolumeLayout) Lookup(vid storage.VolumeId) []*DataNode { return nil } +func (vl *VolumeLayout) ListVolumeServers() (nodes []*DataNode) { + for _, location := range vl.vid2location { + nodes = append(nodes, location.list...) + } + return +} + func (vl *VolumeLayout) PickForWrite(count int, dataCenter string) (*storage.VolumeId, int, *VolumeLocationList, error) { len_writers := len(vl.writables) if len_writers <= 0 { @@ -134,10 +142,12 @@ func (vl *VolumeLayout) SetVolumeUnavailable(dn *DataNode, vid storage.VolumeId) vl.accessLock.Lock() defer vl.accessLock.Unlock() - if vl.vid2location[vid].Remove(dn) { - if vl.vid2location[vid].Length() < vl.rp.GetCopyCount() { - glog.V(0).Infoln("Volume", vid, "has", vl.vid2location[vid].Length(), "replica, less than required", vl.rp.GetCopyCount()) - return vl.removeFromWritable(vid) + if location, ok := vl.vid2location[vid]; ok { + if location.Remove(dn) { + if location.Length() < vl.rp.GetCopyCount() { + glog.V(0).Infoln("Volume", vid, "has", location.Length(), "replica, less than required", vl.rp.GetCopyCount()) + return vl.removeFromWritable(vid) + } } } return false |
