diff options
| author | yourchanges <yourchanges@gmail.com> | 2014-10-21 15:50:48 +0800 |
|---|---|---|
| committer | yourchanges <yourchanges@gmail.com> | 2014-10-21 15:50:48 +0800 |
| commit | f7bcd8e958ef185baeca0c455a397d49fcb62256 (patch) | |
| tree | bb2a2de4fcb7f9ac7e1d65a78e82cbe1f5f17e36 /go/topology/collection.go | |
| parent | 78ccbbf3d0766e1ececf91fa00766d1ed33050cc (diff) | |
| parent | a3c17f17b144c4298409fddda2d6bc4b39d38ca5 (diff) | |
| download | seaweedfs-f7bcd8e958ef185baeca0c455a397d49fcb62256.tar.xz seaweedfs-f7bcd8e958ef185baeca0c455a397d49fcb62256.zip | |
Merge pull request #1 from chrislusf/master
update
Diffstat (limited to 'go/topology/collection.go')
| -rw-r--r-- | go/topology/collection.go | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/go/topology/collection.go b/go/topology/collection.go index b21122d22..506f43fbf 100644 --- a/go/topology/collection.go +++ b/go/topology/collection.go @@ -1,33 +1,34 @@ 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/storage" ) type Collection struct { Name string volumeSizeLimit uint64 - replicaType2VolumeLayout []*VolumeLayout + storageType2VolumeLayout map[string]*VolumeLayout } func NewCollection(name string, volumeSizeLimit uint64) *Collection { c := &Collection{Name: name, volumeSizeLimit: volumeSizeLimit} - c.replicaType2VolumeLayout = make([]*VolumeLayout, storage.ReplicaPlacementCount) + c.storageType2VolumeLayout = make(map[string]*VolumeLayout) return c } -func (c *Collection) GetOrCreateVolumeLayout(rp *storage.ReplicaPlacement) *VolumeLayout { - replicaPlacementIndex := rp.GetReplicationLevelIndex() - if c.replicaType2VolumeLayout[replicaPlacementIndex] == nil { - glog.V(0).Infoln("collection", c.Name, "adding replication type", rp) - c.replicaType2VolumeLayout[replicaPlacementIndex] = NewVolumeLayout(rp, c.volumeSizeLimit) +func (c *Collection) GetOrCreateVolumeLayout(rp *storage.ReplicaPlacement, ttl *storage.TTL) *VolumeLayout { + keyString := rp.String() + if ttl != nil { + keyString += ttl.String() } - return c.replicaType2VolumeLayout[replicaPlacementIndex] + if c.storageType2VolumeLayout[keyString] == nil { + c.storageType2VolumeLayout[keyString] = NewVolumeLayout(rp, ttl, c.volumeSizeLimit) + } + return c.storageType2VolumeLayout[keyString] } func (c *Collection) Lookup(vid storage.VolumeId) []*DataNode { - for _, vl := range c.replicaType2VolumeLayout { + for _, vl := range c.storageType2VolumeLayout { if vl != nil { if list := vl.Lookup(vid); list != nil { return list @@ -38,7 +39,7 @@ func (c *Collection) Lookup(vid storage.VolumeId) []*DataNode { } func (c *Collection) ListVolumeServers() (nodes []*DataNode) { - for _, vl := range c.replicaType2VolumeLayout { + for _, vl := range c.storageType2VolumeLayout { if vl != nil { if list := vl.ListVolumeServers(); list != nil { nodes = append(nodes, list...) |
