diff --git a/weed/command/master.go b/weed/command/master.go index bed55e334..4eb43ee09 100644 --- a/weed/command/master.go +++ b/weed/command/master.go @@ -54,7 +54,7 @@ func init() { m.volumeSizeLimitMB = cmdMaster.Flag.Uint("volumeSizeLimitMB", 30*1000, "Master stops directing writes to oversized volumes.") m.volumePreallocate = cmdMaster.Flag.Bool("volumePreallocate", false, "Preallocate disk space for volumes.") // m.pulseSeconds = cmdMaster.Flag.Int("pulseSeconds", 5, "number of seconds between heartbeats") - m.defaultReplication = cmdMaster.Flag.String("defaultReplication", "000", "Default replication type if not specified.") + m.defaultReplication = cmdMaster.Flag.String("defaultReplication", "", "Default replication type if not specified.") m.garbageThreshold = cmdMaster.Flag.Float64("garbageThreshold", 0.3, "threshold to vacuum and reclaim spaces") m.whiteList = cmdMaster.Flag.String("whiteList", "", "comma separated Ip addresses having write permission. No limit if empty.") m.disableHttp = cmdMaster.Flag.Bool("disableHttp", false, "disable http requests, only gRPC operations are allowed.") diff --git a/weed/command/server.go b/weed/command/server.go index fe10b24f7..c784d90b9 100644 --- a/weed/command/server.go +++ b/weed/command/server.go @@ -89,7 +89,7 @@ func init() { masterOptions.peers = cmdServer.Flag.String("master.peers", "", "all master nodes in comma separated ip:masterPort list") masterOptions.volumeSizeLimitMB = cmdServer.Flag.Uint("master.volumeSizeLimitMB", 30*1000, "Master stops directing writes to oversized volumes.") masterOptions.volumePreallocate = cmdServer.Flag.Bool("master.volumePreallocate", false, "Preallocate disk space for volumes.") - masterOptions.defaultReplication = cmdServer.Flag.String("master.defaultReplication", "000", "Default replication type if not specified.") + masterOptions.defaultReplication = cmdServer.Flag.String("master.defaultReplication", "", "Default replication type if not specified.") masterOptions.garbageThreshold = cmdServer.Flag.Float64("garbageThreshold", 0.3, "threshold to vacuum and reclaim spaces") masterOptions.metricsAddress = cmdServer.Flag.String("metrics.address", "", "Prometheus gateway address") masterOptions.metricsIntervalSec = cmdServer.Flag.Int("metrics.intervalSeconds", 15, "Prometheus push interval in seconds") diff --git a/weed/server/filer_server_handlers_write.go b/weed/server/filer_server_handlers_write.go index 8d11e664a..39d983ab7 100644 --- a/weed/server/filer_server_handlers_write.go +++ b/weed/server/filer_server_handlers_write.go @@ -116,18 +116,6 @@ func (fs *FilerServer) DeleteHandler(w http.ResponseWriter, r *http.Request) { } func (fs *FilerServer) detectStorageOption(requestURI, qCollection, qReplication string, ttlSeconds int32, diskType, dataCenter, rack string) (*operation.StorageOption, error) { - collection := util.Nvl(qCollection, fs.option.Collection) - replication := util.Nvl(qReplication, fs.option.DefaultReplication) - - // required by buckets folder - bucketDefaultReplication, fsync := "", false - if strings.HasPrefix(requestURI, fs.filer.DirBucketsPath+"/") { - collection = fs.filer.DetectBucket(util.FullPath(requestURI)) - bucketDefaultReplication, fsync = fs.filer.ReadBucketOption(collection) - } - if replication == "" { - replication = bucketDefaultReplication - } rule := fs.filer.FilerConf.MatchStorageRule(requestURI) @@ -135,6 +123,13 @@ func (fs *FilerServer) detectStorageOption(requestURI, qCollection, qReplication return nil, ErrReadOnly } + // required by buckets folder + bucketDefaultCollection, bucketDefaultReplication, fsync := "", "", false + if strings.HasPrefix(requestURI, fs.filer.DirBucketsPath+"/") { + bucketDefaultCollection = fs.filer.DetectBucket(util.FullPath(requestURI)) + bucketDefaultReplication, fsync = fs.filer.ReadBucketOption(bucketDefaultCollection) + } + if ttlSeconds == 0 { ttl, err := needle.ReadTTL(rule.GetTtl()) if err != nil { @@ -144,8 +139,8 @@ func (fs *FilerServer) detectStorageOption(requestURI, qCollection, qReplication } return &operation.StorageOption{ - Replication: util.Nvl(replication, rule.Replication), - Collection: util.Nvl(collection, rule.Collection), + Replication: util.Nvl(qReplication, rule.Replication, bucketDefaultReplication, fs.option.DefaultReplication), + Collection: util.Nvl(qCollection, rule.Collection, bucketDefaultCollection, fs.option.Collection), DataCenter: util.Nvl(dataCenter, fs.option.DataCenter), Rack: util.Nvl(rack, fs.option.Rack), TtlSeconds: ttlSeconds,