From 0a233e0408f57f623146a0d00e106647749bf7f2 Mon Sep 17 00:00:00 2001 From: hr2904 Date: Mon, 28 Oct 2024 18:45:20 +0530 Subject: [PATCH] Added refactors based on PR comments - 2 --- .../src/main/java/org/apache/atlas/tasks/TaskRegistry.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/repository/src/main/java/org/apache/atlas/tasks/TaskRegistry.java b/repository/src/main/java/org/apache/atlas/tasks/TaskRegistry.java index 441aa9c52d..8c08a26121 100644 --- a/repository/src/main/java/org/apache/atlas/tasks/TaskRegistry.java +++ b/repository/src/main/java/org/apache/atlas/tasks/TaskRegistry.java @@ -60,6 +60,7 @@ public class TaskRegistry { private static final Logger LOG = LoggerFactory.getLogger(TaskRegistry.class); public static final int TASK_FETCH_BATCH_SIZE = 100; + public static final List> SORT_ARRAY = Collections.singletonList(mapOf(Constants.TASK_CREATED_TIME, mapOf("order", "asc"))); private AtlasGraph graph; private TaskService taskService; @@ -137,11 +138,11 @@ public List getInProgressTasks() { public List getInProgressTasksES() { AtlasPerfMetrics.MetricRecorder metric = RequestContext.get().startMetricRecord("getInProgressTasksES"); List ret = new ArrayList<>(); + Map dsl = mapOf("query", QUERY_MAP); + dsl.put("sort", SORT_ARRAY); + dsl.put("size", TASK_FETCH_BATCH_SIZE); int from = 0; while(true) { - Map dsl = mapOf("query", QUERY_MAP); - dsl.put("sort", Collections.singletonList(mapOf(Constants.TASK_CREATED_TIME, mapOf("order", "asc")))); - dsl.put("size", TASK_FETCH_BATCH_SIZE); dsl.put("from", from); TaskSearchParams taskSearchParams = new TaskSearchParams(); taskSearchParams.setDsl(dsl);