[ML] Order GET job stats response by job id (#36841)
This commit is contained in:
parent
42ea644903
commit
42bb2bae21
|
@ -37,6 +37,7 @@ import org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcessManage
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -91,6 +92,7 @@ public class TransportGetJobsStatsAction extends TransportTasksAction<TransportO
|
||||||
for (QueryPage<JobStats> task : tasks) {
|
for (QueryPage<JobStats> task : tasks) {
|
||||||
stats.addAll(task.results());
|
stats.addAll(task.results());
|
||||||
}
|
}
|
||||||
|
Collections.sort(stats, Comparator.comparing(GetJobsStatsAction.Response.JobStats::getJobId));
|
||||||
return new GetJobsStatsAction.Response(taskOperationFailures, failedNodeExceptions, new QueryPage<>(stats, stats.size(),
|
return new GetJobsStatsAction.Response(taskOperationFailures, failedNodeExceptions, new QueryPage<>(stats, stats.size(),
|
||||||
Job.RESULTS_FIELD));
|
Job.RESULTS_FIELD));
|
||||||
}
|
}
|
||||||
|
@ -148,6 +150,7 @@ public class TransportGetJobsStatsAction extends TransportTasksAction<TransportO
|
||||||
if (counter.decrementAndGet() == 0) {
|
if (counter.decrementAndGet() == 0) {
|
||||||
List<JobStats> results = response.getResponse().results();
|
List<JobStats> results = response.getResponse().results();
|
||||||
results.addAll(jobStats.asList());
|
results.addAll(jobStats.asList());
|
||||||
|
Collections.sort(results, Comparator.comparing(GetJobsStatsAction.Response.JobStats::getJobId));
|
||||||
listener.onResponse(new GetJobsStatsAction.Response(response.getTaskFailures(), response.getNodeFailures(),
|
listener.onResponse(new GetJobsStatsAction.Response(response.getTaskFailures(), response.getNodeFailures(),
|
||||||
new QueryPage<>(results, results.size(), Job.RESULTS_FIELD)));
|
new QueryPage<>(results, results.size(), Job.RESULTS_FIELD)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,7 +151,9 @@ setup:
|
||||||
ml.get_job_stats:
|
ml.get_job_stats:
|
||||||
job_id: _all
|
job_id: _all
|
||||||
- match: { count: 2 }
|
- match: { count: 2 }
|
||||||
|
- match: { jobs.0.job_id : job-stats-test }
|
||||||
- match: { jobs.0.state: opened }
|
- match: { jobs.0.state: opened }
|
||||||
|
- match: { jobs.1.job_id : jobs-get-stats-datafeed-job }
|
||||||
- match: { jobs.1.state: opened }
|
- match: { jobs.1.state: opened }
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -161,7 +163,9 @@ setup:
|
||||||
ml.get_job_stats:
|
ml.get_job_stats:
|
||||||
job_id: "*"
|
job_id: "*"
|
||||||
- match: { count: 2 }
|
- match: { count: 2 }
|
||||||
|
- match: { jobs.0.job_id : job-stats-test }
|
||||||
- match: { jobs.0.state: opened }
|
- match: { jobs.0.state: opened }
|
||||||
|
- match: { jobs.1.job_id : jobs-get-stats-datafeed-job }
|
||||||
- match: { jobs.1.state: opened }
|
- match: { jobs.1.state: opened }
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -311,6 +315,7 @@ setup:
|
||||||
- do:
|
- do:
|
||||||
ml.get_job_stats: {}
|
ml.get_job_stats: {}
|
||||||
- match: { count: 2 }
|
- match: { count: 2 }
|
||||||
|
- match: { jobs.0.job_id : job-stats-test }
|
||||||
- match: { jobs.0.data_counts.processed_record_count: 0 }
|
- match: { jobs.0.data_counts.processed_record_count: 0 }
|
||||||
- match: { jobs.0.data_counts.processed_field_count: 0 }
|
- match: { jobs.0.data_counts.processed_field_count: 0 }
|
||||||
- match: { jobs.0.data_counts.input_field_count: 0 }
|
- match: { jobs.0.data_counts.input_field_count: 0 }
|
||||||
|
@ -318,6 +323,7 @@ setup:
|
||||||
- match: { jobs.0.state: closed }
|
- match: { jobs.0.state: closed }
|
||||||
- is_false: jobs.0.node
|
- is_false: jobs.0.node
|
||||||
- is_false: jobs.0.open_time
|
- is_false: jobs.0.open_time
|
||||||
|
- match: { jobs.1.job_id : jobs-get-stats-datafeed-job }
|
||||||
- match: { jobs.1.data_counts.processed_record_count: 0 }
|
- match: { jobs.1.data_counts.processed_record_count: 0 }
|
||||||
- match: { jobs.1.data_counts.processed_field_count: 0 }
|
- match: { jobs.1.data_counts.processed_field_count: 0 }
|
||||||
- match: { jobs.1.data_counts.input_field_count: 0 }
|
- match: { jobs.1.data_counts.input_field_count: 0 }
|
||||||
|
@ -325,5 +331,3 @@ setup:
|
||||||
- match: { jobs.1.state: closed }
|
- match: { jobs.1.state: closed }
|
||||||
- is_false: jobs.1.node
|
- is_false: jobs.1.node
|
||||||
- is_false: jobs.1.open_time
|
- is_false: jobs.1.open_time
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue