create volume grow request if the selected volume is close to full
This commit is contained in:
@@ -119,12 +119,15 @@ func (ms *MasterServer) dirAssignHandler(w http.ResponseWriter, r *http.Request)
|
||||
|
||||
vl := ms.Topo.GetVolumeLayout(option.Collection, option.ReplicaPlacement, option.Ttl, option.DiskType)
|
||||
|
||||
if !vl.HasGrowRequest() && vl.ShouldGrowVolumes(option) {
|
||||
fid, count, dnList, shouldGrow, err := ms.Topo.PickForWrite(requestedCount, option, vl)
|
||||
if shouldGrow && !vl.HasGrowRequest() {
|
||||
// if picked volume is almost full, trigger a volume-grow request
|
||||
glog.V(0).Infof("dirAssign volume growth %v from %v", option.String(), r.RemoteAddr)
|
||||
if ms.Topo.AvailableSpaceFor(option) <= 0 {
|
||||
writeJsonQuiet(w, r, http.StatusNotFound, operation.AssignResult{Error: "No free volumes left for " + option.String()})
|
||||
return
|
||||
}
|
||||
|
||||
errCh := make(chan error, 1)
|
||||
vl.AddGrowRequest()
|
||||
ms.vgCh <- &topology.VolumeGrowRequest{
|
||||
@@ -137,10 +140,10 @@ func (ms *MasterServer) dirAssignHandler(w http.ResponseWriter, r *http.Request)
|
||||
return
|
||||
}
|
||||
}
|
||||
fid, count, dnList, err := ms.Topo.PickForWrite(requestedCount, option)
|
||||
if err == nil {
|
||||
ms.maybeAddJwtAuthorization(w, fid, true)
|
||||
dn := dnList.Head()
|
||||
|
||||
writeJsonQuiet(w, r, http.StatusOK, operation.AssignResult{Fid: fid, Url: dn.Url(), PublicUrl: dn.PublicUrl, Count: count})
|
||||
} else {
|
||||
writeJsonQuiet(w, r, http.StatusNotAcceptable, operation.AssignResult{Error: err.Error()})
|
||||
|
||||
Reference in New Issue
Block a user