Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

add more for volume placement

Chris Lu2dceb44ae44c
diff --git a/weed-fs/src/pkg/replication/volume_growth.go b/weed-fs/src/pkg/replication/volume_growth.go
new file mode 100644
index 0000000000..49afc741c8
--- /dev/null
+++ b/weed-fs/src/pkg/replication/volume_growth.go
@@ -0,0 +1,29 @@
+package replication
+
+import (
+ "pkg/topology"
+)
+
+/*
+This package is created to resolve these replica placement issues:
+1. growth factor for each replica level, e.g., add 10 volumes for 1 copy, 20 volumes for 2 copies, 30 volumes for 3 copies
+2. in time of tight storage, how to reduce replica level
+3. optimizing for hot data on faster disk, cold data on cheaper storage,
+4. volume allocation for each bucket
+*/
+
+type VolumeGrowth struct {
+ copy1factor int
+ copy2factor int
+ copy3factor int
+ copyAll int
+}
+
+func (vg *VolumeGrowth) GrowVolumeCopy(copyLevel int, topo topology.Topology) {
+ if copyLevel == 1 {
+ for i := 0; i <vg.copy1factor; i++ {
+ topo.RandomlyCreateOneVolume()
+ }
+ }
+
+}
diff --git a/weed-fs/src/pkg/storage/storage_limit.go b/weed-fs/src/pkg/storage/storage_limit.go
index 915ec48a33..b40618046c 100644
--- a/weed-fs/src/pkg/storage/storage_limit.go
+++ b/weed-fs/src/pkg/storage/storage_limit.go
@@ -1,21 +1,13 @@
package storage
import (
- "syscall"
)
type StorageLimit struct {
sizeLimit uint64
- detectedLimit uint64
}
func NewStorageLimit(desiredLimit uint64) *StorageLimit {
- s := syscall.Statfs_t{}
- errNo := syscall.Statfs(".", &s)
- detected := uint64(0)
- if errNo==nil {
- detected = s.Bavail*uint64(s.Bsize)
- }
- sl := &StorageLimit{sizeLimit: desiredLimit, detectedLimit: detected}
+ sl := &StorageLimit{sizeLimit: desiredLimit}
return sl
}
diff --git a/weed-fs/src/pkg/storage/storage_limit_test.go b/weed-fs/src/pkg/storage/storage_limit_test.go
deleted file mode 100644
index c818356f91..0000000000
--- a/weed-fs/src/pkg/storage/storage_limit_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package storage
-
-import (
- "testing"
-)
-
-func TestReadStorageLimit(t *testing.T) {
- sl := NewStorageLimit(1000)
- println("detected:",sl.detectedLimit)
-}
-
diff --git a/weed-fs/src/pkg/storage/store.go b/weed-fs/src/pkg/storage/store.go
index 1c3ba4a515..1dbb89c06c 100644
--- a/weed-fs/src/pkg/storage/store.go
+++ b/weed-fs/src/pkg/storage/store.go
@@ -89,11 +89,23 @@ func (s *Store) Close() {
}
}
func (s *Store) Write(i VolumeId, n *Needle) uint32 {
- return s.volumes[i].write(n)
+ v := s.volumes[i]
+ if v!=nil{
+ return v.write(n)
+ }
+ return 0
}
func (s *Store) Delete(i VolumeId, n *Needle) uint32 {
- return s.volumes[i].delete(n)
+ v := s.volumes[i]
+ if v!=nil{
+ return v.delete(n)
+ }
+ return 0
}
func (s *Store) Read(i VolumeId, n *Needle) (int, error) {
- return s.volumes[i].read(n)
+ v := s.volumes[i]
+ if v!=nil{
+ return v.read(n)
+ }
+ return 0, errors.New("Not Found")
}
diff --git a/weed-fs/src/pkg/topology/node.go b/weed-fs/src/pkg/topology/node.go
index 4eccdbf650..9c1a87f898 100644
--- a/weed-fs/src/pkg/topology/node.go
+++ b/weed-fs/src/pkg/topology/node.go
@@ -11,4 +11,19 @@ type Node struct {
Ip string
Port int
PublicUrl string
+
+ //transient
+ allocation *Allocation
}
+type Allocation struct {
+ count int
+ limit int
+}
+
+func (n *Node) GetAllocation() *Allocation{
+ if n.allocation == nil {
+ n.allocation = &Allocation{count:len(n.volumes), limit : n.volumeLimit}
+ }
+ return n.allocation
+}
+
diff --git a/weed-fs/src/pkg/topology/topology.go b/weed-fs/src/pkg/topology/topology.go
index 7db3d0e32f..7d903b961e 100644
--- a/weed-fs/src/pkg/topology/topology.go
+++ b/weed-fs/src/pkg/topology/topology.go
@@ -1,9 +1,16 @@
package topology
import (
-
+ "pkg/storage"
)
type Topology struct {
datacenters map[DataCenterId]*DataCenter
}
+//FIXME
+func (t *Topology) RandomlyCreateOneVolume() storage.VolumeId{
+ return t.findMaxVolumeId()
+}
+func (t *Topology) findMaxVolumeId() storage.VolumeId{
+ return storage.VolumeId(0);
+}