aboutsummaryrefslogtreecommitdiff
path: root/weed/topology/collection.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/topology/collection.go')
-rw-r--r--weed/topology/collection.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/weed/topology/collection.go b/weed/topology/collection.go
index cea3d3b21..e197ce1a2 100644
--- a/weed/topology/collection.go
+++ b/weed/topology/collection.go
@@ -44,6 +44,28 @@ func (c *Collection) GetOrCreateVolumeLayout(rp *super_block.ReplicaPlacement, t
return vl.(*VolumeLayout)
}
+func (c *Collection) GetVolumeLayout(rp *super_block.ReplicaPlacement, ttl *needle.TTL, diskType types.DiskType) (*VolumeLayout, bool) {
+ keyString := rp.String()
+ if ttl != nil {
+ keyString += ttl.String()
+ }
+ if diskType != types.HardDriveType {
+ keyString += string(diskType)
+ }
+ vl, ok := c.storageType2VolumeLayout.Find(keyString)
+ return vl.(*VolumeLayout), ok
+}
+
+func (c *Collection) GetAllVolumeLayouts() []*VolumeLayout {
+ var vls []*VolumeLayout
+ for _, vl := range c.storageType2VolumeLayout.Items() {
+ if vl != nil {
+ vls = append(vls, vl.(*VolumeLayout))
+ }
+ }
+ return vls
+}
+
func (c *Collection) DeleteVolumeLayout(rp *super_block.ReplicaPlacement, ttl *needle.TTL, diskType types.DiskType) {
keyString := rp.String()
if ttl != nil {