diff options
| author | Chris Lu <chrislusf@users.noreply.github.com> | 2018-07-21 20:14:38 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-07-21 20:14:38 -0700 |
| commit | 3423c1da18487e4dc3d77a024f9c0d5d3b7599cf (patch) | |
| tree | cc72caa73fadbdb81659c1f13bb87f33c502fbc1 /weed/command/mount_std.go | |
| parent | c98df05ed0fc78e8585c6dd7d2ae317c7c42d9c3 (diff) | |
| parent | 49375d603177e4134d0cb4128324a2dd70521290 (diff) | |
| download | seaweedfs-3423c1da18487e4dc3d77a024f9c0d5d3b7599cf.tar.xz seaweedfs-3423c1da18487e4dc3d77a024f9c0d5d3b7599cf.zip | |
Merge pull request #693 from chrislusf/add_s3
Add "weed s3" to support S3 API
Diffstat (limited to 'weed/command/mount_std.go')
| -rw-r--r-- | weed/command/mount_std.go | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/weed/command/mount_std.go b/weed/command/mount_std.go index 4905df986..242ed4dc8 100644 --- a/weed/command/mount_std.go +++ b/weed/command/mount_std.go @@ -11,8 +11,8 @@ import ( "github.com/chrislusf/seaweedfs/weed/filesys" "github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/util" - "strings" "strconv" + "strings" ) func runMount(cmd *Command, args []string) bool { @@ -53,27 +53,14 @@ func runMount(cmd *Command, args []string) bool { c.Close() }) - hostnameAndPort := strings.Split(*mountOptions.filer, ":") - if len(hostnameAndPort) != 2 { - fmt.Printf("The filer should have hostname:port format: %v\n", hostnameAndPort) - return false - } - - filerPort, parseErr := strconv.ParseUint(hostnameAndPort[1], 10, 64) - if parseErr != nil { - fmt.Printf("The filer filer port parse error: %v\n", parseErr) + filerGrpcAddress, err := parseFilerGrpcAddress(*mountOptions.filer, *mountOptions.filerGrpcPort) + if err != nil { + glog.Fatal(err) return false } - filerGrpcPort := filerPort + 10000 - if *mountOptions.filerGrpcPort != 0 { - filerGrpcPort = uint64(*copy.filerGrpcPort) - } - - filerAddress := fmt.Sprintf("%s:%d", hostnameAndPort[0], filerGrpcPort) - err = fs.Serve(c, filesys.NewSeaweedFileSystem( - filerAddress, *mountOptions.filerMountRootPath, *mountOptions.collection, *mountOptions.replication, int32(*mountOptions.ttlSec), + filerGrpcAddress, *mountOptions.filerMountRootPath, *mountOptions.collection, *mountOptions.replication, int32(*mountOptions.ttlSec), *mountOptions.chunkSizeLimitMB, *mountOptions.dataCenter)) if err != nil { fuse.Unmount(*mountOptions.dir) @@ -87,3 +74,22 @@ func runMount(cmd *Command, args []string) bool { return true } + +func parseFilerGrpcAddress(filer string, optionalGrpcPort int) (filerGrpcAddress string, err error) { + hostnameAndPort := strings.Split(filer, ":") + if len(hostnameAndPort) != 2 { + return "", fmt.Errorf("The filer should have hostname:port format: %v", hostnameAndPort) + } + + filerPort, parseErr := strconv.ParseUint(hostnameAndPort[1], 10, 64) + if parseErr != nil { + return "", fmt.Errorf("The filer filer port parse error: %v", parseErr) + } + + filerGrpcPort := int(filerPort) + 10000 + if optionalGrpcPort != 0 { + filerGrpcPort = optionalGrpcPort + } + + return fmt.Sprintf("%s:%d", hostnameAndPort[0], filerGrpcPort), nil +} |
