Browse Source
refactor code
refactor code
1. make volumeSizeLimit argument more clear 2. use humanize.MiByte instead of 1024 * 1024 3. constantized NodeType togetherpull/848/head
21 changed files with 100 additions and 39 deletions
-
3weed/command/filer_copy.go
-
2weed/command/fix.go
-
10weed/command/master.go
-
4weed/command/mount.go
-
5weed/command/mount_std.go
-
9weed/command/server.go
-
5weed/operation/submit.go
-
5weed/server/filer_server_handlers_write_autochunk.go
-
2weed/server/master_grpc_server.go
-
12weed/server/master_server.go
-
5weed/server/volume_grpc_sync.go
-
3weed/storage/needle/compact_map_perf_test.go
-
3weed/storage/types/needle_types.go
-
2weed/topology/data_center.go
-
2weed/topology/data_node.go
-
13weed/topology/node.go
-
2weed/topology/rack.go
-
2weed/topology/topology.go
-
24weed/util/arg.go
-
23weed/util/arg_test.go
-
3weed/weed.go
@ -0,0 +1,24 @@ |
|||
package util |
|||
|
|||
import ( |
|||
"github.com/chrislusf/seaweedfs/weed/glog" |
|||
"github.com/dustin/go-humanize" |
|||
) |
|||
|
|||
func ParseVolumeSizeLimit(volumeSizeLimitMiB uint, volumeSizeLimitArg string) uint64 { |
|||
volumeSizeLimit := uint64(volumeSizeLimitMiB) * humanize.MiByte |
|||
if volumeSizeLimitArg != "" { |
|||
var err error |
|||
volumeSizeLimit, err = humanize.ParseBytes(volumeSizeLimitArg) |
|||
Assert(err != nil, "Parse volumeSizeLimit %s : %s", volumeSizeLimitArg, err) |
|||
} |
|||
|
|||
Assert(volumeSizeLimit > 30*1000*humanize.MiByte, "volumeSizeLimit should be smaller than 30000MB") |
|||
return volumeSizeLimit |
|||
} |
|||
|
|||
func Assert(condition bool, format string, args ...interface{}) { |
|||
if condition { |
|||
glog.Fatalf(format, args...) |
|||
} |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
package util |
|||
|
|||
import ( |
|||
"github.com/dustin/go-humanize" |
|||
"testing" |
|||
) |
|||
|
|||
func TestParseVolumeSizeLimit(t *testing.T) { |
|||
volumeSizeLimit := ParseVolumeSizeLimit(10, "") |
|||
if volumeSizeLimit != 10*humanize.MiByte { |
|||
t.Fail() |
|||
} |
|||
|
|||
volumeSizeLimit = ParseVolumeSizeLimit(10, "11GiB") |
|||
if volumeSizeLimit != 11*humanize.GiByte { |
|||
t.Fail() |
|||
} |
|||
|
|||
volumeSizeLimit = ParseVolumeSizeLimit(10, "11811160064") |
|||
if volumeSizeLimit != 11*humanize.GiByte { |
|||
t.Fail() |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue