refactoring

This commit is contained in:
Chris Lu
2021-04-02 01:10:24 -07:00
parent cc0df36a9e
commit 7e8edc3c4a
4 changed files with 64 additions and 91 deletions

View File

@@ -5,8 +5,8 @@ import (
"hash"
"io"
"io/ioutil"
"math/rand"
"net/http"
"runtime"
"strings"
"sync"
"time"
@@ -20,6 +20,10 @@ import (
"github.com/chrislusf/seaweedfs/weed/util"
)
var (
limitedUploadProcessor = util.NewLimitedOutOfOrderProcessor(int32(runtime.NumCPU()))
)
func (fs *FilerServer) uploadReaderToChunks(w http.ResponseWriter, r *http.Request, reader io.Reader, chunkSize int32, fileName, contentType string, contentLength int64, so *operation.StorageOption) (fileChunks []*filer_pb.FileChunk, md5Hash hash.Hash, dataSize int64, err error, smallContent []byte) {
md5Hash = md5.New()
@@ -58,7 +62,7 @@ func (fs *FilerServer) uploadReaderToChunks(w http.ResponseWriter, r *http.Reque
for readErr == nil {
wg.Add(1)
operation.AsyncOutOfOrderProcess(rand.Uint32(), func() {
limitedUploadProcessor.Execute(func() {
defer wg.Done()
var localOffset int64