|
|
@ -1,7 +1,6 @@ |
|
|
|
package weed_server |
|
|
|
|
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"net/http" |
|
|
|
"strconv" |
|
|
|
"strings" |
|
|
@ -60,13 +59,15 @@ func (vs *VolumeServer) privateStoreHandler(w http.ResponseWriter, r *http.Reque |
|
|
|
contentLength := getContentLength(r) |
|
|
|
|
|
|
|
// exclude the replication from the concurrentUploadLimitMB
|
|
|
|
if vs.concurrentUploadLimit != 0 && r.URL.Query().Get("type") != "replicate" && |
|
|
|
atomic.LoadInt64(&vs.inFlightUploadDataSize) > vs.concurrentUploadLimit { |
|
|
|
err := fmt.Errorf("reject because inflight upload data %d > %d", vs.inFlightUploadDataSize, vs.concurrentUploadLimit) |
|
|
|
glog.V(1).Infof("too many requests: %v", err) |
|
|
|
writeJsonError(w, r, http.StatusTooManyRequests, err) |
|
|
|
return |
|
|
|
if r.URL.Query().Get("type") != "replicate" { //Non-Replication
|
|
|
|
vs.inFlightUploadDataLimitCond.L.Lock() |
|
|
|
for vs.concurrentUploadLimit != 0 && atomic.LoadInt64(&vs.inFlightUploadDataSize) > vs.concurrentUploadLimit { |
|
|
|
glog.V(4).Infof("wait because inflight upload data %d > %d", vs.inFlightUploadDataSize, vs.concurrentUploadLimit) |
|
|
|
vs.inFlightUploadDataLimitCond.Wait() |
|
|
|
} |
|
|
|
vs.inFlightUploadDataLimitCond.L.Unlock() |
|
|
|
} |
|
|
|
|
|
|
|
atomic.AddInt64(&vs.inFlightUploadDataSize, contentLength) |
|
|
|
defer func() { |
|
|
|
atomic.AddInt64(&vs.inFlightUploadDataSize, -contentLength) |
|
|
|