mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 02:00:56 +00:00
chore(master): delete unsave count and calculate freeze count realtime.#1000230160
Signed-off-by: Wu Huocheng <wuhuocheng@oppo.com>
This commit is contained in:
parent
9f9969f43d
commit
4bb9b73817
@ -269,16 +269,33 @@ func (m *Server) getCleanMetaPartitionTask(w http.ResponseWriter, r *http.Reques
|
||||
m.cluster.mu.Lock()
|
||||
defer m.cluster.mu.Unlock()
|
||||
|
||||
taskList := make([]*CleanTask, 0, len(m.cluster.cleanTask))
|
||||
if name == "" {
|
||||
sendOkReply(w, r, newSuccessHTTPReply(m.cluster.cleanTask))
|
||||
for key, val := range m.cluster.cleanTask {
|
||||
task, err := m.cluster.CalculateMetaPartitionFreezeCount(key)
|
||||
if err != nil {
|
||||
log.LogWarnf("CalculateMetaPartitionFreezeCount volume(%s) err: %s", key, err.Error())
|
||||
continue
|
||||
}
|
||||
task.Status = val.Status
|
||||
taskList = append(taskList, task)
|
||||
}
|
||||
} else {
|
||||
task, ok := m.cluster.cleanTask[name]
|
||||
val, ok := m.cluster.cleanTask[name]
|
||||
if !ok {
|
||||
sendErrReply(w, r, &proto.HTTPReply{Code: proto.ErrCodeParamError, Msg: fmt.Sprintf("Can't find task for volume(%s)", name)})
|
||||
return
|
||||
}
|
||||
sendOkReply(w, r, newSuccessHTTPReply(task))
|
||||
task, err := m.cluster.CalculateMetaPartitionFreezeCount(name)
|
||||
if err != nil {
|
||||
sendErrReply(w, r, &proto.HTTPReply{Code: proto.ErrCodeInternalError, Msg: err.Error()})
|
||||
return
|
||||
}
|
||||
task.Status = val.Status
|
||||
taskList = append(taskList, task)
|
||||
}
|
||||
|
||||
sendOkReply(w, r, newSuccessHTTPReply(taskList))
|
||||
}
|
||||
|
||||
func parseMigratePartitionParam(r *http.Request) (srcAddr, targetAddr string, id uint64, err error) {
|
||||
|
||||
@ -126,11 +126,14 @@ type ClusterDecommission struct {
|
||||
type CleanTask struct {
|
||||
Name string `json:"name"`
|
||||
Status string `json:"status"`
|
||||
TaskCnt int `json:"taskCount"`
|
||||
FreezeCnt int `json:"freezeCount"`
|
||||
CleanCnt int `json:"cleanCount"`
|
||||
ResetCnt int `json:"resetCount"`
|
||||
TaskCnt int `json:"-"`
|
||||
FreezeCnt int `json:"-"`
|
||||
CleanCnt int `json:"-"`
|
||||
ResetCnt int `json:"-"`
|
||||
Timeout time.Time `json:"-"`
|
||||
UnFreeze int `json:"unfreeze"`
|
||||
Freezing int `json:"freezing"`
|
||||
Freezed int `json:"freezed"`
|
||||
}
|
||||
|
||||
// Cluster stores all the cluster-level information.
|
||||
|
||||
@ -1758,3 +1758,37 @@ func verifyDestinationInMetaReplicas(mp *MetaPartition, dst string) bool {
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (c *Cluster) CalculateMetaPartitionFreezeCount(name string) (*CleanTask, error) {
|
||||
vol, err := c.getVol(name)
|
||||
if err != nil {
|
||||
log.LogErrorf("CalculateMetaPartitionFreezeCount get volume(%s) error: %s", name, err.Error())
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if vol.Status == proto.VolStatusMarkDelete {
|
||||
err = fmt.Errorf("volume(%s) is deleted before cleaned empty meta partitions.", name)
|
||||
log.LogInfof(err.Error())
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ret := &CleanTask{
|
||||
Name: name,
|
||||
UnFreeze: 0,
|
||||
Freezing: 0,
|
||||
Freezed: 0,
|
||||
}
|
||||
mps := vol.cloneMetaPartitionMap()
|
||||
for _, mp := range mps {
|
||||
switch mp.Freeze {
|
||||
case proto.FreezeMetaPartitionInit:
|
||||
ret.UnFreeze += 1
|
||||
case proto.FreezingMetaPartition:
|
||||
ret.Freezing += 1
|
||||
case proto.FreezedMetaPartition:
|
||||
ret.Freezed += 1
|
||||
}
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user