mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 02:00:56 +00:00
feat(falsh): check file size limits for warm up task
with: #1000383519 Signed-off-by: clinx <chenlin1@oppo.com>
This commit is contained in:
parent
97365b5b2e
commit
03ae1861c7
@ -278,17 +278,21 @@ func (m *Server) createFlashNodeManualTask(w http.ResponseWriter, r *http.Reques
|
||||
sendErrReply(w, r, &proto.HTTPReply{Code: proto.ErrCodeParamError, Msg: err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
// Validate file size limits
|
||||
if req.ManualTaskConfig.MinFileSizeLimit > req.ManualTaskConfig.MaxFileSizeLimit {
|
||||
err = fmt.Errorf("MinFileSizeLimit(%d) cannot be greater than MaxFileSizeLimit(%d)",
|
||||
req.ManualTaskConfig.MinFileSizeLimit, req.ManualTaskConfig.MaxFileSizeLimit)
|
||||
sendErrReply(w, r, &proto.HTTPReply{Code: proto.ErrCodeParamError, Msg: err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
var vol *Vol
|
||||
if vol, err = m.cluster.getVol(req.VolName); err != nil {
|
||||
sendErrReply(w, r, &proto.HTTPReply{Code: proto.ErrCodeVolNotExists, Msg: err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
if !vol.remoteCacheEnable {
|
||||
err = fmt.Errorf("distribute cache of vol[%v] unavailable", vol.Name)
|
||||
sendErrReply(w, r, &proto.HTTPReply{Code: proto.ErrCodeInvalidCfg, Msg: err.Error()})
|
||||
return
|
||||
}
|
||||
if m.cluster.flashNodeTopo == nil || !m.cluster.flashNodeTopo.CheckForActiveNode() {
|
||||
err = fmt.Errorf("no available distributed cache nodes")
|
||||
sendErrReply(w, r, &proto.HTTPReply{Code: proto.ErrCodeInvalidCfg, Msg: err.Error()})
|
||||
|
||||
@ -520,6 +520,8 @@ type ManualTaskConfig struct {
|
||||
TraverseFileConcurrency int
|
||||
HandlerFileConcurrency int
|
||||
TotalFileSizeLimit int64
|
||||
MinFileSizeLimit int64
|
||||
MaxFileSizeLimit int64
|
||||
}
|
||||
|
||||
type ManualTaskStatistics struct {
|
||||
|
||||
@ -308,6 +308,17 @@ func (s *ManualScanner) warmUp(i *proto.ScanItem) error {
|
||||
log.LogInfof("skip warmUp, size=0, inode(%v)", i.Inode)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Check file size limits
|
||||
config := s.manualTask.ManualTaskConfig
|
||||
if config.MinFileSizeLimit > 0 && int64(i.Size) < config.MinFileSizeLimit {
|
||||
log.LogInfof("skip warmUp, file size(%d) below MinFileSizeLimit(%d), inode(%v)", i.Size, config.MinFileSizeLimit, i.Inode)
|
||||
return nil
|
||||
}
|
||||
if config.MaxFileSizeLimit > 0 && int64(i.Size) > config.MaxFileSizeLimit {
|
||||
log.LogInfof("skip warmUp, file size(%d) above MaxFileSizeLimit(%d), inode(%v)", i.Size, config.MaxFileSizeLimit, i.Inode)
|
||||
return nil
|
||||
}
|
||||
_, _, extents, err = s.mw.GetExtents(i.Inode, false, false, false)
|
||||
if err != nil {
|
||||
log.LogWarnf("warmUp: mw GetExtents fail, inode(%v) err: %v ", i.Inode, err)
|
||||
|
||||
@ -67,6 +67,15 @@ func (f *FlashNode) handleSubmitTask(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
log.LogInfof("submit mannual task with http arg:%+v", &req)
|
||||
|
||||
// Validate file size limits
|
||||
if req.ManualTaskConfig.MinFileSizeLimit > req.ManualTaskConfig.MaxFileSizeLimit {
|
||||
err = fmt.Errorf("MinFileSizeLimit(%d) cannot be greater than MaxFileSizeLimit(%d)",
|
||||
req.ManualTaskConfig.MinFileSizeLimit, req.ManualTaskConfig.MaxFileSizeLimit)
|
||||
replyErr(w, r, proto.ErrCodeParamError, err.Error(), nil)
|
||||
return
|
||||
}
|
||||
|
||||
start := time.Now()
|
||||
req.StartTime = &start
|
||||
req.UpdateTime = &start
|
||||
|
||||
Loading…
Reference in New Issue
Block a user