From 2dceb44ae44cddd435cc6c8bdc813a26176adc51 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 27 Aug 2012 13:52:02 -0700 Subject: [PATCH] add more for volume placement fix possible nil volume cases --- weed-fs/src/pkg/replication/volume_growth.go | 29 +++++++++++++++++++ weed-fs/src/pkg/storage/storage_limit.go | 10 +------ weed-fs/src/pkg/storage/storage_limit_test.go | 11 ------- weed-fs/src/pkg/storage/store.go | 18 ++++++++++-- weed-fs/src/pkg/topology/node.go | 15 ++++++++++ weed-fs/src/pkg/topology/topology.go | 9 +++++- 6 files changed, 68 insertions(+), 24 deletions(-) create mode 100644 weed-fs/src/pkg/replication/volume_growth.go delete mode 100644 weed-fs/src/pkg/storage/storage_limit_test.go 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 000000000..49afc741c --- /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