mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-09-19 06:47:53 +08:00
mount: configurable read wait time
This commit is contained in:
@@ -2,6 +2,7 @@ package command
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MountOptions struct {
|
type MountOptions struct {
|
||||||
@@ -25,9 +26,10 @@ type MountOptions struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
mountOptions MountOptions
|
mountOptions MountOptions
|
||||||
mountCpuProfile *string
|
mountCpuProfile *string
|
||||||
mountMemProfile *string
|
mountMemProfile *string
|
||||||
|
mountReadRetryTime *time.Duration
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -46,11 +48,13 @@ func init() {
|
|||||||
mountOptions.allowOthers = cmdMount.Flag.Bool("allowOthers", true, "allows other users to access the file system")
|
mountOptions.allowOthers = cmdMount.Flag.Bool("allowOthers", true, "allows other users to access the file system")
|
||||||
mountOptions.umaskString = cmdMount.Flag.String("umask", "022", "octal umask, e.g., 022, 0111")
|
mountOptions.umaskString = cmdMount.Flag.String("umask", "022", "octal umask, e.g., 022, 0111")
|
||||||
mountOptions.nonempty = cmdMount.Flag.Bool("nonempty", false, "allows the mounting over a non-empty directory")
|
mountOptions.nonempty = cmdMount.Flag.Bool("nonempty", false, "allows the mounting over a non-empty directory")
|
||||||
mountCpuProfile = cmdMount.Flag.String("cpuprofile", "", "cpu profile output file")
|
|
||||||
mountMemProfile = cmdMount.Flag.String("memprofile", "", "memory profile output file")
|
|
||||||
mountOptions.outsideContainerClusterMode = cmdMount.Flag.Bool("outsideContainerClusterMode", false, "allows other users to access the file system")
|
mountOptions.outsideContainerClusterMode = cmdMount.Flag.Bool("outsideContainerClusterMode", false, "allows other users to access the file system")
|
||||||
mountOptions.uidMap = cmdMount.Flag.String("map.uid", "", "map local uid to uid on filer, comma-separated <local_uid>:<filer_uid>")
|
mountOptions.uidMap = cmdMount.Flag.String("map.uid", "", "map local uid to uid on filer, comma-separated <local_uid>:<filer_uid>")
|
||||||
mountOptions.gidMap = cmdMount.Flag.String("map.gid", "", "map local gid to gid on filer, comma-separated <local_gid>:<filer_gid>")
|
mountOptions.gidMap = cmdMount.Flag.String("map.gid", "", "map local gid to gid on filer, comma-separated <local_gid>:<filer_gid>")
|
||||||
|
|
||||||
|
mountCpuProfile = cmdMount.Flag.String("cpuprofile", "", "cpu profile output file")
|
||||||
|
mountMemProfile = cmdMount.Flag.String("memprofile", "", "memory profile output file")
|
||||||
|
mountReadRetryTime = cmdMount.Flag.Duration("readRetryTime", 6*time.Second, "maximum read retry wait time")
|
||||||
}
|
}
|
||||||
|
|
||||||
var cmdMount = &Command{
|
var cmdMount = &Command{
|
||||||
|
@@ -5,6 +5,7 @@ package command
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/filer"
|
||||||
"github.com/chrislusf/seaweedfs/weed/filesys/meta_cache"
|
"github.com/chrislusf/seaweedfs/weed/filesys/meta_cache"
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
@@ -29,6 +30,10 @@ import (
|
|||||||
func runMount(cmd *Command, args []string) bool {
|
func runMount(cmd *Command, args []string) bool {
|
||||||
|
|
||||||
grace.SetupProfiling(*mountCpuProfile, *mountMemProfile)
|
grace.SetupProfiling(*mountCpuProfile, *mountMemProfile)
|
||||||
|
if *mountReadRetryTime < time.Second {
|
||||||
|
*mountReadRetryTime = time.Second
|
||||||
|
}
|
||||||
|
filer.ReadWaitTime = *mountReadRetryTime
|
||||||
|
|
||||||
umask, umaskErr := strconv.ParseUint(*mountOptions.umaskString, 8, 64)
|
umask, umaskErr := strconv.ParseUint(*mountOptions.umaskString, 8, 64)
|
||||||
if umaskErr != nil {
|
if umaskErr != nil {
|
||||||
|
@@ -98,7 +98,7 @@ func retriedFetchChunkData(urlStrings []string, cipherKey []byte, isGzipped bool
|
|||||||
var err error
|
var err error
|
||||||
var buffer bytes.Buffer
|
var buffer bytes.Buffer
|
||||||
|
|
||||||
for waitTime := time.Second; waitTime < 10*time.Second; waitTime += waitTime / 2 {
|
for waitTime := time.Second; waitTime < ReadWaitTime; waitTime += waitTime / 2 {
|
||||||
for _, urlString := range urlStrings {
|
for _, urlString := range urlStrings {
|
||||||
err = util.ReadUrlAsStream(urlString, cipherKey, isGzipped, isFullChunk, offset, size, func(data []byte) {
|
err = util.ReadUrlAsStream(urlString, cipherKey, isGzipped, isFullChunk, offset, size, func(data []byte) {
|
||||||
buffer.Write(data)
|
buffer.Write(data)
|
||||||
|
@@ -14,6 +14,10 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
ReadWaitTime = 6 * time.Second
|
||||||
|
)
|
||||||
|
|
||||||
type ChunkReadAt struct {
|
type ChunkReadAt struct {
|
||||||
masterClient *wdclient.MasterClient
|
masterClient *wdclient.MasterClient
|
||||||
chunkViews []*ChunkView
|
chunkViews []*ChunkView
|
||||||
@@ -39,7 +43,7 @@ func LookupFn(filerClient filer_pb.FilerClient) LookupFileIdFunctionType {
|
|||||||
locations, found := vidCache[vid]
|
locations, found := vidCache[vid]
|
||||||
|
|
||||||
waitTime := time.Second
|
waitTime := time.Second
|
||||||
for !found && waitTime < 6*time.Second {
|
for !found && waitTime < ReadWaitTime {
|
||||||
// println("looking up volume", vid)
|
// println("looking up volume", vid)
|
||||||
err = filerClient.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err = filerClient.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
||||||
resp, err := client.LookupVolume(context.Background(), &filer_pb.LookupVolumeRequest{
|
resp, err := client.LookupVolume(context.Background(), &filer_pb.LookupVolumeRequest{
|
||||||
|
Reference in New Issue
Block a user