mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
move to util.RetryWaitTime
This commit is contained in:
parent
ef908e166b
commit
8750cac090
|
@ -5,8 +5,6 @@ package command
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/chrislusf/seaweedfs/weed/filer"
|
||||
"github.com/chrislusf/seaweedfs/weed/filesys/meta_cache"
|
||||
"os"
|
||||
"os/user"
|
||||
"path"
|
||||
|
@ -15,6 +13,8 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/chrislusf/seaweedfs/weed/filesys/meta_cache"
|
||||
|
||||
"github.com/seaweedfs/fuse"
|
||||
"github.com/seaweedfs/fuse/fs"
|
||||
|
||||
|
@ -33,7 +33,7 @@ func runMount(cmd *Command, args []string) bool {
|
|||
if *mountReadRetryTime < time.Second {
|
||||
*mountReadRetryTime = time.Second
|
||||
}
|
||||
filer.ReadWaitTime = *mountReadRetryTime
|
||||
util.RetryWaitTime = *mountReadRetryTime
|
||||
|
||||
umask, umaskErr := strconv.ParseUint(*mountOptions.umaskString, 8, 64)
|
||||
if umaskErr != nil {
|
||||
|
|
|
@ -99,7 +99,7 @@ func retriedFetchChunkData(urlStrings []string, cipherKey []byte, isGzipped bool
|
|||
var buffer bytes.Buffer
|
||||
var shouldRetry bool
|
||||
|
||||
for waitTime := time.Second; waitTime < ReadWaitTime; waitTime += waitTime / 2 {
|
||||
for waitTime := time.Second; waitTime < util.RetryWaitTime; waitTime += waitTime / 2 {
|
||||
for _, urlString := range urlStrings {
|
||||
shouldRetry, err = util.ReadUrlAsStream(urlString+"?readDeleted=true", cipherKey, isGzipped, isFullChunk, offset, size, func(data []byte) {
|
||||
buffer.Write(data)
|
||||
|
|
|
@ -3,20 +3,16 @@ package filer
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"math/rand"
|
||||
"sync"
|
||||
|
||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||
"github.com/chrislusf/seaweedfs/weed/util"
|
||||
"github.com/chrislusf/seaweedfs/weed/util/chunk_cache"
|
||||
"github.com/chrislusf/seaweedfs/weed/wdclient"
|
||||
"github.com/golang/groupcache/singleflight"
|
||||
"io"
|
||||
"math/rand"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
ReadWaitTime = 6 * time.Second
|
||||
)
|
||||
|
||||
type ChunkReadAt struct {
|
||||
|
@ -47,7 +43,7 @@ func LookupFn(filerClient filer_pb.FilerClient) LookupFileIdFunctionType {
|
|||
vicCacheLock.RUnlock()
|
||||
|
||||
if !found {
|
||||
util.Retry("lookup volume "+vid, ReadWaitTime, func() error {
|
||||
util.Retry("lookup volume "+vid, func() error {
|
||||
err = filerClient.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
||||
resp, err := client.LookupVolume(context.Background(), &filer_pb.LookupVolumeRequest{
|
||||
VolumeIds: []string{vid},
|
||||
|
|
|
@ -16,7 +16,7 @@ func EnsureVisited(mc *MetaCache, client filer_pb.FilerClient, dirPath util.Full
|
|||
|
||||
glog.V(4).Infof("ReadDirAllEntries %s ...", path)
|
||||
|
||||
util.Retry("ReadDirAllEntries", filer.ReadWaitTime, func() error {
|
||||
util.Retry("ReadDirAllEntries", func() error {
|
||||
err = filer_pb.ReadDirAllEntries(client, dirPath, "", func(pbEntry *filer_pb.Entry, isLast bool) error {
|
||||
entry := filer.FromPbEntry(string(dirPath), pbEntry)
|
||||
if err := mc.doInsertEntry(context.Background(), entry); err != nil {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package filesys
|
||||
|
||||
import (
|
||||
"github.com/chrislusf/seaweedfs/weed/filer"
|
||||
"github.com/chrislusf/seaweedfs/weed/util"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
|
@ -13,7 +12,7 @@ var _ = filer_pb.FilerClient(&WFS{})
|
|||
|
||||
func (wfs *WFS) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) error) error {
|
||||
|
||||
err := util.Retry("filer grpc", filer.ReadWaitTime, func() error {
|
||||
err := util.Retry("filer grpc", func() error {
|
||||
return pb.WithCachedGrpcClient(func(grpcConnection *grpc.ClientConn) error {
|
||||
client := filer_pb.NewSeaweedFilerClient(grpcConnection)
|
||||
return fn(client)
|
||||
|
|
|
@ -7,10 +7,12 @@ import (
|
|||
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||
)
|
||||
|
||||
func Retry(name string, waitTimeLimit time.Duration, job func() error) (err error) {
|
||||
var RetryWaitTime = 6 * time.Second
|
||||
|
||||
func Retry(name string, job func() error) (err error) {
|
||||
waitTime := time.Second
|
||||
hasErr := false
|
||||
for waitTime < waitTimeLimit {
|
||||
for waitTime < RetryWaitTime {
|
||||
err = job()
|
||||
if err == nil {
|
||||
if hasErr {
|
||||
|
@ -26,4 +28,4 @@ func Retry(name string, waitTimeLimit time.Duration, job func() error) (err erro
|
|||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
|
@ -151,7 +151,7 @@ func (mc *MasterClient) tryConnectToMaster(master string) (nextHintedLeader stri
|
|||
}
|
||||
|
||||
func (mc *MasterClient) WithClient(fn func(client master_pb.SeaweedClient) error) error {
|
||||
return util.Retry("master grpc", 6*time.Second, func() error {
|
||||
return util.Retry("master grpc", func() error {
|
||||
for mc.currentMaster == "" {
|
||||
time.Sleep(3 * time.Second)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue