aboutsummaryrefslogtreecommitdiff
path: root/go/topology/data_node.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2014-03-10 11:43:54 -0700
committerChris Lu <chris.lu@gmail.com>2014-03-10 11:43:54 -0700
commitcd10c277b2146a7d01449dfe8825e7f1f12d7d7d (patch)
tree3f9bb75988e50aa2ddfc492fd45d27c6a748680f /go/topology/data_node.go
parenta121453188f14ac3580bf61b47268bf029d61390 (diff)
downloadseaweedfs-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/data_node.go')
-rw-r--r--go/topology/data_node.go24
1 files changed, 22 insertions, 2 deletions
diff --git a/go/topology/data_node.go b/go/topology/data_node.go
index 3a6edb447..a83647939 100644
--- a/go/topology/data_node.go
+++ b/go/topology/data_node.go
@@ -1,8 +1,8 @@
package topology
import (
+ "code.google.com/p/weed-fs/go/glog"
"code.google.com/p/weed-fs/go/storage"
- _ "fmt"
"strconv"
)
@@ -28,12 +28,32 @@ func (dn *DataNode) AddOrUpdateVolume(v storage.VolumeInfo) {
if _, ok := dn.volumes[v.Id]; !ok {
dn.volumes[v.Id] = v
dn.UpAdjustVolumeCountDelta(1)
- dn.UpAdjustActiveVolumeCountDelta(1)
+ if !v.ReadOnly {
+ dn.UpAdjustActiveVolumeCountDelta(1)
+ }
dn.UpAdjustMaxVolumeId(v.Id)
} else {
dn.volumes[v.Id] = v
}
}
+func (dn *DataNode) UpdateVolumes(actualVolumes []storage.VolumeInfo) {
+ actualVolumeMap := make(map[storage.VolumeId]storage.VolumeInfo)
+ for _, v := range actualVolumes {
+ actualVolumeMap[v.Id] = v
+ }
+ for vid, _ := range dn.volumes {
+ glog.V(2).Infoln("Checking volume id:", vid)
+ if _, ok := actualVolumeMap[vid]; !ok {
+ glog.V(0).Infoln("Deleting volume id:", vid)
+ delete(dn.volumes, vid)
+ dn.UpAdjustVolumeCountDelta(-1)
+ dn.UpAdjustActiveVolumeCountDelta(-1)
+ }
+ } //TODO: adjust max volume id, if need to reclaim volume ids
+ for _, v := range actualVolumes {
+ dn.AddOrUpdateVolume(v)
+ }
+}
func (dn *DataNode) GetDataCenter() *DataCenter {
return dn.Parent().Parent().(*NodeImpl).value.(*DataCenter)
}