aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author霍晓栋 <huoxd@jiedaibao.com>2016-08-09 20:12:39 +0800
committer霍晓栋 <huoxd@jiedaibao.com>2016-08-09 20:12:39 +0800
commitf04d8fcbcc7baea562e2afb526328a467cd37ab9 (patch)
tree1e4c27307b63ac0798bb0cecb864b621c347de04
parentd5b0538f7be5e4106e8d42062d08258d98172607 (diff)
downloadseaweedfs-f04d8fcbcc7baea562e2afb526328a467cd37ab9.tar.xz
seaweedfs-f04d8fcbcc7baea562e2afb526328a467cd37ab9.zip
if replicated volume has one copy in readonly mode at one node,it should be removed from writable list
-rw-r--r--weed/topology/data_node.go11
-rw-r--r--weed/topology/volume_layout.go13
2 files changed, 24 insertions, 0 deletions
diff --git a/weed/topology/data_node.go b/weed/topology/data_node.go
index 1404d4aa8..da6ed2895 100644
--- a/weed/topology/data_node.go
+++ b/weed/topology/data_node.go
@@ -79,6 +79,17 @@ func (dn *DataNode) GetVolumes() (ret []storage.VolumeInfo) {
return ret
}
+func (dn *DataNode) GetVolumesById(id storage.VolumeId) (storage.VolumeInfo, error) {
+ dn.RLock()
+ defer dn.RUnlock()
+ v_info, ok := dn.volumes[id]
+ if ok {
+ return v_info, nil
+ } else {
+ return storage.VolumeInfo{}, fmt.Errorf("volumeInfo not found")
+ }
+}
+
func (dn *DataNode) GetDataCenter() *DataCenter {
return dn.Parent().Parent().(*NodeImpl).value.(*DataCenter)
}
diff --git a/weed/topology/volume_layout.go b/weed/topology/volume_layout.go
index 066f5f69a..af8503b29 100644
--- a/weed/topology/volume_layout.go
+++ b/weed/topology/volume_layout.go
@@ -45,6 +45,19 @@ func (vl *VolumeLayout) RegisterVolume(v *storage.VolumeInfo, dn *DataNode) {
}
vl.vid2location[v.Id].Set(dn)
glog.V(4).Infoln("volume", v.Id, "added to dn", dn.Id(), "len", vl.vid2location[v.Id].Length(), "copy", v.ReplicaPlacement.GetCopyCount())
+ for _, dn := range vl.vid2location[v.Id].list {
+ if v_info, err := dn.GetVolumesById(v.Id); err == nil {
+ if v_info.ReadOnly {
+ glog.V(3).Infof("vid %d removed from writable", v.Id)
+ vl.removeFromWritable(v.Id)
+ return
+ }
+ } else {
+ glog.V(3).Infof("vid %d removed from writable", v.Id)
+ vl.removeFromWritable(v.Id)
+ return
+ }
+ }
if vl.vid2location[v.Id].Length() == vl.rp.GetCopyCount() && vl.isWritable(v) {
if _, ok := vl.oversizedVolumes[v.Id]; !ok {
vl.addToWritable(v.Id)