exclude replication from the concurrentUploadLimitMB
This commit is contained in:
@@ -24,6 +24,7 @@ type VolumeServer struct {
|
|||||||
inFlightDownloadDataSize int64
|
inFlightDownloadDataSize int64
|
||||||
concurrentUploadLimit int64
|
concurrentUploadLimit int64
|
||||||
concurrentDownloadLimit int64
|
concurrentDownloadLimit int64
|
||||||
|
inFlightUploadDataLimitCond *sync.Cond
|
||||||
inFlightDownloadDataLimitCond *sync.Cond
|
inFlightDownloadDataLimitCond *sync.Cond
|
||||||
|
|
||||||
SeedMasterNodes []pb.ServerAddress
|
SeedMasterNodes []pb.ServerAddress
|
||||||
@@ -84,6 +85,7 @@ func NewVolumeServer(adminMux, publicMux *http.ServeMux, ip string,
|
|||||||
fileSizeLimitBytes: int64(fileSizeLimitMB) * 1024 * 1024,
|
fileSizeLimitBytes: int64(fileSizeLimitMB) * 1024 * 1024,
|
||||||
isHeartbeating: true,
|
isHeartbeating: true,
|
||||||
stopChan: make(chan bool),
|
stopChan: make(chan bool),
|
||||||
|
inFlightUploadDataLimitCond: sync.NewCond(new(sync.Mutex)),
|
||||||
inFlightDownloadDataLimitCond: sync.NewCond(new(sync.Mutex)),
|
inFlightDownloadDataLimitCond: sync.NewCond(new(sync.Mutex)),
|
||||||
concurrentUploadLimit: concurrentUploadLimit,
|
concurrentUploadLimit: concurrentUploadLimit,
|
||||||
concurrentDownloadLimit: concurrentDownloadLimit,
|
concurrentDownloadLimit: concurrentDownloadLimit,
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package weed_server
|
package weed_server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -60,13 +59,15 @@ func (vs *VolumeServer) privateStoreHandler(w http.ResponseWriter, r *http.Reque
|
|||||||
contentLength := getContentLength(r)
|
contentLength := getContentLength(r)
|
||||||
|
|
||||||
// exclude the replication from the concurrentUploadLimitMB
|
// exclude the replication from the concurrentUploadLimitMB
|
||||||
if vs.concurrentUploadLimit != 0 && r.URL.Query().Get("type") != "replicate" &&
|
if r.URL.Query().Get("type") != "replicate" { //Non-Replication
|
||||||
atomic.LoadInt64(&vs.inFlightUploadDataSize) > vs.concurrentUploadLimit {
|
vs.inFlightUploadDataLimitCond.L.Lock()
|
||||||
err := fmt.Errorf("reject because inflight upload data %d > %d", vs.inFlightUploadDataSize, vs.concurrentUploadLimit)
|
for vs.concurrentUploadLimit != 0 && atomic.LoadInt64(&vs.inFlightUploadDataSize) > vs.concurrentUploadLimit {
|
||||||
glog.V(1).Infof("too many requests: %v", err)
|
glog.V(4).Infof("wait because inflight upload data %d > %d", vs.inFlightUploadDataSize, vs.concurrentUploadLimit)
|
||||||
writeJsonError(w, r, http.StatusTooManyRequests, err)
|
vs.inFlightUploadDataLimitCond.Wait()
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
vs.inFlightUploadDataLimitCond.L.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
atomic.AddInt64(&vs.inFlightUploadDataSize, contentLength)
|
atomic.AddInt64(&vs.inFlightUploadDataSize, contentLength)
|
||||||
defer func() {
|
defer func() {
|
||||||
atomic.AddInt64(&vs.inFlightUploadDataSize, -contentLength)
|
atomic.AddInt64(&vs.inFlightUploadDataSize, -contentLength)
|
||||||
|
|||||||
Reference in New Issue
Block a user