Browse Source

rename

pull/2252/head
Chris Lu 3 years ago
parent
commit
96ce85f5ae
  1. 6
      weed/server/volume_server.go
  2. 16
      weed/server/volume_server_handlers.go

6
weed/server/volume_server.go

@ -17,9 +17,9 @@ import (
) )
type VolumeServer struct { type VolumeServer struct {
inFlightDataSize int64
inFlightUploadDataSize int64
concurrentUploadLimit int64 concurrentUploadLimit int64
inFlightDataLimitCond *sync.Cond
inFlightUploadDataLimitCond *sync.Cond
SeedMasterNodes []string SeedMasterNodes []string
currentMaster string currentMaster string
@ -78,7 +78,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),
inFlightDataLimitCond: sync.NewCond(new(sync.Mutex)),
inFlightUploadDataLimitCond: sync.NewCond(new(sync.Mutex)),
concurrentUploadLimit: concurrentUploadLimit, concurrentUploadLimit: concurrentUploadLimit,
} }
vs.SeedMasterNodes = masterNodes vs.SeedMasterNodes = masterNodes

16
weed/server/volume_server_handlers.go

@ -45,16 +45,16 @@ func (vs *VolumeServer) privateStoreHandler(w http.ResponseWriter, r *http.Reque
// wait until in flight data is less than the limit // wait until in flight data is less than the limit
contentLength := getContentLength(r) contentLength := getContentLength(r)
vs.inFlightDataLimitCond.L.Lock()
for vs.concurrentUploadLimit != 0 && atomic.LoadInt64(&vs.inFlightDataSize) > vs.concurrentUploadLimit {
glog.V(4).Infof("wait because inflight data %d > %d", vs.inFlightDataSize, vs.concurrentUploadLimit)
vs.inFlightDataLimitCond.Wait()
vs.inFlightUploadDataLimitCond.L.Lock()
for vs.concurrentUploadLimit != 0 && atomic.LoadInt64(&vs.inFlightUploadDataSize) > vs.concurrentUploadLimit {
glog.V(4).Infof("wait because inflight data %d > %d", vs.inFlightUploadDataSize, vs.concurrentUploadLimit)
vs.inFlightUploadDataLimitCond.Wait()
} }
atomic.AddInt64(&vs.inFlightDataSize, contentLength)
vs.inFlightDataLimitCond.L.Unlock()
atomic.AddInt64(&vs.inFlightUploadDataSize, contentLength)
vs.inFlightUploadDataLimitCond.L.Unlock()
defer func() { defer func() {
atomic.AddInt64(&vs.inFlightDataSize, -contentLength)
vs.inFlightDataLimitCond.Signal()
atomic.AddInt64(&vs.inFlightUploadDataSize, -contentLength)
vs.inFlightUploadDataLimitCond.Signal()
}() }()
// processs uploads // processs uploads

Loading…
Cancel
Save