diff --git a/weed-fs/src/cmd/weeds.go b/weed-fs/src/cmd/weeds.go index 0a1b78f0e..b41a5d437 100644 --- a/weed-fs/src/cmd/weeds.go +++ b/weed-fs/src/cmd/weeds.go @@ -18,6 +18,7 @@ var ( capacity = flag.Int("capacity", 100, "maximum number of volumes to hold") mapper *directory.Mapper IsDebug = flag.Bool("debug", false, "verbose debug information") + volumeSizeLimitMB = flag.Uint("volumeSizeLimitMB", 32*1024, "Default Volume Size in MegaBytes") ) func dirLookupHandler(w http.ResponseWriter, r *http.Request) { @@ -69,12 +70,11 @@ func writeJson(w http.ResponseWriter, r *http.Request, obj interface{}) { fmt.Fprint(w, string(bytes)) w.Write([]uint8(")")) } - //log.Println("JSON Response", string(bytes)) } func main() { flag.Parse() - mapper = directory.NewMapper(*metaFolder, "directory") + mapper = directory.NewMapper(*metaFolder, "directory", uint32(*volumeSizeLimitMB*1024*1024)) http.HandleFunc("/dir/assign", dirAssignHandler) http.HandleFunc("/dir/lookup", dirLookupHandler) http.HandleFunc("/dir/join", dirJoinHandler) diff --git a/weed-fs/src/pkg/directory/volume_mapping.go b/weed-fs/src/pkg/directory/volume_mapping.go index a51294411..828975b97 100644 --- a/weed-fs/src/pkg/directory/volume_mapping.go +++ b/weed-fs/src/pkg/directory/volume_mapping.go @@ -12,7 +12,6 @@ import ( ) const ( - ChunkSizeLimit = 32 * 1024 * 1024 //32G, can not be more than max(uint32)*8 FileIdSaveInterval = 10000 ) @@ -36,15 +35,18 @@ type Mapper struct { FileIdSequence uint64 fileIdCounter uint64 + + volumeSizeLimit uint32 } func NewMachine(server, publicUrl string, volumes []storage.VolumeInfo) *Machine { return &Machine{Server: MachineInfo{Url: server, PublicUrl: publicUrl}, Volumes: volumes} } -func NewMapper(dirname string, filename string) (m *Mapper) { +func NewMapper(dirname string, filename string, volumeSizeLimit uint32) (m *Mapper) { m = &Mapper{dir: dirname, fileName: filename} m.vid2machineId = make(map[uint32]int) + m.volumeSizeLimit = volumeSizeLimit m.Writers = *new([]int) m.Machines = *new([]*Machine) @@ -116,7 +118,7 @@ func (m *Mapper) Add(machine Machine){ var writers []int for machine_index, machine_entry := range m.Machines { for _, v := range machine_entry.Volumes { - if v.Size < ChunkSizeLimit { + if v.Size < int64(m.volumeSizeLimit) { writers = append(writers, machine_index) } }