mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
Use BackoffSchedule for getLookupFileId
This commit is contained in:
parent
01996bccf8
commit
7b1497ee63
|
@ -18,6 +18,12 @@ import (
|
||||||
"github.com/chrislusf/seaweedfs/weed/wdclient"
|
"github.com/chrislusf/seaweedfs/weed/wdclient"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var getLookupFileIdBackoffSchedule = []time.Duration{
|
||||||
|
150 * time.Millisecond,
|
||||||
|
600 * time.Millisecond,
|
||||||
|
1800 * time.Millisecond,
|
||||||
|
}
|
||||||
|
|
||||||
func HasData(entry *filer_pb.Entry) bool {
|
func HasData(entry *filer_pb.Entry) bool {
|
||||||
|
|
||||||
if len(entry.Content) > 0 {
|
if len(entry.Content) > 0 {
|
||||||
|
@ -69,7 +75,15 @@ func StreamContent(masterClient wdclient.HasLookupFileIdFunction, writer io.Writ
|
||||||
fileId2Url := make(map[string][]string)
|
fileId2Url := make(map[string][]string)
|
||||||
|
|
||||||
for _, chunkView := range chunkViews {
|
for _, chunkView := range chunkViews {
|
||||||
urlStrings, err := masterClient.GetLookupFileIdFunction()(chunkView.FileId)
|
var urlStrings []string
|
||||||
|
var err error
|
||||||
|
for _, backoff := range getLookupFileIdBackoffSchedule {
|
||||||
|
urlStrings, err = masterClient.GetLookupFileIdFunction()(chunkView.FileId)
|
||||||
|
if err == nil && len(urlStrings) > 0 {
|
||||||
|
time.Sleep(backoff)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.V(1).Infof("operation LookupFileId %s failed, err: %v", chunkView.FileId, err)
|
glog.V(1).Infof("operation LookupFileId %s failed, err: %v", chunkView.FileId, err)
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in a new issue