fix calc migration task progress info with a large number of sub task
This commit is contained in:
parent
c8aab5c566
commit
ef36af329f
|
@ -76,7 +76,7 @@ func (h *APIHandler) getDataMigrationTaskInfo(w http.ResponseWriter, req *http.R
|
|||
for i, index := range taskConfig.Indices {
|
||||
indexName := index.Source.GetUniqueIndexName()
|
||||
count := indexState[indexName].IndexDocs
|
||||
sourceDocs := indexState[indexName].SourceDocs
|
||||
sourceDocs := index.Source.Docs
|
||||
var percent float64
|
||||
if sourceDocs <= 0 {
|
||||
percent = 100
|
||||
|
@ -86,7 +86,7 @@ func (h *APIHandler) getDataMigrationTaskInfo(w http.ResponseWriter, req *http.R
|
|||
percent = 100
|
||||
}
|
||||
}
|
||||
taskConfig.Indices[i].Source.Docs = sourceDocs
|
||||
//taskConfig.Indices[i].Source.Docs = sourceDocs
|
||||
taskConfig.Indices[i].Target.Docs = count
|
||||
taskConfig.Indices[i].Percent = util.ToFixed(percent, 2)
|
||||
taskConfig.Indices[i].ErrorPartitions = indexState[indexName].ErrorPartitions
|
||||
|
@ -257,8 +257,26 @@ We count data from two sources:
|
|||
- realtime bulk indexing info is only available for running index_migrations
|
||||
*/
|
||||
func (h *APIHandler) getMigrationMajorTaskInfo(id string) (taskStats migration_model.ClusterMigrationTaskState, indexState map[string]MigrationIndexStateInfo, err error) {
|
||||
var pipelineTaskIDs = map[string][]string{}
|
||||
var pipelineIndexNames = map[string]string{}
|
||||
indexState = map[string]MigrationIndexStateInfo{}
|
||||
const size = 500
|
||||
var (
|
||||
from = -size
|
||||
hasMore = true
|
||||
)
|
||||
for hasMore {
|
||||
from += size
|
||||
taskQuery := util.MapStr{
|
||||
"size": 500,
|
||||
"from": from,
|
||||
"size": size,
|
||||
"sort": []util.MapStr{
|
||||
{
|
||||
"created": util.MapStr{
|
||||
"order": "asc",
|
||||
},
|
||||
},
|
||||
},
|
||||
"query": util.MapStr{
|
||||
"bool": util.MapStr{
|
||||
"must": []util.MapStr{
|
||||
|
@ -284,9 +302,11 @@ func (h *APIHandler) getMigrationMajorTaskInfo(id string) (taskStats migration_m
|
|||
if err != nil {
|
||||
return taskStats, indexState, err
|
||||
}
|
||||
if len(subTasks) < size {
|
||||
hasMore = false
|
||||
}
|
||||
|
||||
var indexMigrationTaskIDs []string
|
||||
indexState = map[string]MigrationIndexStateInfo{}
|
||||
for _, subTask := range subTasks {
|
||||
taskLabels := util.MapStr(subTask.Metadata.Labels)
|
||||
indexName := migration_util.GetMapStringValue(taskLabels, "unique_index_name")
|
||||
|
@ -323,11 +343,11 @@ func (h *APIHandler) getMigrationMajorTaskInfo(id string) (taskStats migration_m
|
|||
}
|
||||
|
||||
if len(indexMigrationTaskIDs) == 0 {
|
||||
return taskStats, indexState, nil
|
||||
continue
|
||||
}
|
||||
|
||||
taskQuery = util.MapStr{
|
||||
"size": 500,
|
||||
"size": len(indexMigrationTaskIDs),
|
||||
"query": util.MapStr{
|
||||
"bool": util.MapStr{
|
||||
"must": []util.MapStr{
|
||||
|
@ -352,8 +372,6 @@ func (h *APIHandler) getMigrationMajorTaskInfo(id string) (taskStats migration_m
|
|||
return taskStats, indexState, err
|
||||
}
|
||||
|
||||
var pipelineTaskIDs = map[string][]string{}
|
||||
var pipelineIndexNames = map[string]string{}
|
||||
for _, subTask := range subTasks {
|
||||
taskLabels := util.MapStr(subTask.Metadata.Labels)
|
||||
indexName := migration_util.GetMapStringValue(taskLabels, "unique_index_name")
|
||||
|
@ -367,6 +385,7 @@ func (h *APIHandler) getMigrationMajorTaskInfo(id string) (taskStats migration_m
|
|||
pipelineTaskIDs[instID] = append(pipelineTaskIDs[instID], subTask.ID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pipelineContexts := h.getChildPipelineInfosFromGateway(pipelineTaskIDs)
|
||||
for pipelineID, pipelineContext := range pipelineContexts {
|
||||
|
|
Loading…
Reference in New Issue