aboutsummaryrefslogtreecommitdiff
path: root/go/topology/volume_layout.go
diff options
context:
space:
mode:
authoryourchanges <yourchanges@gmail.com>2014-10-21 15:50:48 +0800
committeryourchanges <yourchanges@gmail.com>2014-10-21 15:50:48 +0800
commitf7bcd8e958ef185baeca0c455a397d49fcb62256 (patch)
treebb2a2de4fcb7f9ac7e1d65a78e82cbe1f5f17e36 /go/topology/volume_layout.go
parent78ccbbf3d0766e1ececf91fa00766d1ed33050cc (diff)
parenta3c17f17b144c4298409fddda2d6bc4b39d38ca5 (diff)
downloadseaweedfs-f7bcd8e958ef185baeca0c455a397d49fcb62256.tar.xz
seaweedfs-f7bcd8e958ef185baeca0c455a397d49fcb62256.zip
Merge pull request #1 from chrislusf/master
update
Diffstat (limited to 'go/topology/volume_layout.go')
-rw-r--r--go/topology/volume_layout.go17
1 files changed, 14 insertions, 3 deletions
diff --git a/go/topology/volume_layout.go b/go/topology/volume_layout.go
index 538acb54c..7bb0cf7e3 100644
--- a/go/topology/volume_layout.go
+++ b/go/topology/volume_layout.go
@@ -1,8 +1,8 @@
package topology
import (
- "code.google.com/p/weed-fs/go/glog"
- "code.google.com/p/weed-fs/go/storage"
+ "github.com/chrislusf/weed-fs/go/glog"
+ "github.com/chrislusf/weed-fs/go/storage"
"errors"
"math/rand"
"sync"
@@ -11,15 +11,17 @@ import (
// mapping from volume to its locations, inverted from server to volume
type VolumeLayout struct {
rp *storage.ReplicaPlacement
+ ttl *storage.TTL
vid2location map[storage.VolumeId]*VolumeLocationList
writables []storage.VolumeId // transient array of writable volume id
volumeSizeLimit uint64
accessLock sync.Mutex
}
-func NewVolumeLayout(rp *storage.ReplicaPlacement, volumeSizeLimit uint64) *VolumeLayout {
+func NewVolumeLayout(rp *storage.ReplicaPlacement, ttl *storage.TTL, volumeSizeLimit uint64) *VolumeLayout {
return &VolumeLayout{
rp: rp,
+ ttl: ttl,
vid2location: make(map[storage.VolumeId]*VolumeLocationList),
writables: *new([]storage.VolumeId),
volumeSizeLimit: volumeSizeLimit,
@@ -42,6 +44,14 @@ func (vl *VolumeLayout) RegisterVolume(v *storage.VolumeInfo, dn *DataNode) {
}
}
+func (vl *VolumeLayout) UnRegisterVolume(v *storage.VolumeInfo, dn *DataNode) {
+ vl.accessLock.Lock()
+ defer vl.accessLock.Unlock()
+
+ vl.removeFromWritable(v.Id)
+ delete(vl.vid2location, v.Id)
+}
+
func (vl *VolumeLayout) AddToWritable(vid storage.VolumeId) {
for _, id := range vl.writables {
if vid == id {
@@ -192,6 +202,7 @@ func (vl *VolumeLayout) SetVolumeCapacityFull(vid storage.VolumeId) bool {
func (vl *VolumeLayout) ToMap() map[string]interface{} {
m := make(map[string]interface{})
m["replication"] = vl.rp.String()
+ m["ttl"] = vl.ttl.String()
m["writables"] = vl.writables
//m["locations"] = vl.vid2location
return m