AmatyaAvadhanula commented on code in PR #12404:
URL: https://github.com/apache/druid/pull/12404#discussion_r859640491
##########
server/src/test/java/org/apache/druid/metadata/SQLMetadataStorageActionHandlerTest.java:
##########
@@ -450,4 +465,149 @@ public void testRemoveTasksOlderThan() throws Exception
Assert.assertEquals(1, handler.getLogs(entryId2).size());
Assert.assertEquals(1, handler.getLogs(entryId3).size());
}
+
+ @Test
+ public void testGetTaskStatusPlusList()
+ {
+ // SETUP
+ TaskInfo<Map<String, Object>, Map<String, Object>> activeUnaltered =
getRandomTaskInfo(true);
+ insertTaskInfo(activeUnaltered, false);
+
+ TaskInfo<Map<String, Object>, Map<String, Object>> completedUnaltered =
getRandomTaskInfo(false);
+ insertTaskInfo(completedUnaltered, false);
+
+ TaskInfo<Map<String, Object>, Map<String, Object>> activeAltered =
getRandomTaskInfo(true);
+ insertTaskInfo(activeAltered, true);
+
+ TaskInfo<Map<String, Object>, Map<String, Object>> completedAltered =
getRandomTaskInfo(false);
+ insertTaskInfo(completedAltered, true);
+
+ Map<TaskLookup.TaskLookupType, TaskLookup> taskLookups = new HashMap<>();
+ taskLookups.put(TaskLookup.TaskLookupType.ACTIVE,
ActiveTaskLookup.getInstance());
+ taskLookups.put(TaskLookup.TaskLookupType.COMPLETE,
CompleteTaskLookup.of(null, Duration.millis(86400000)));
+
+ List<TaskStatusPlus> taskStatusPlusList;
+
+ // BEFORE MIGRATION
+
+ // Payload based fetch. task type and groupid will be populated
+ taskStatusPlusList = handler.getTaskStatusPlusList(taskLookups, null,
true);
+ Assert.assertEquals(4, taskStatusPlusList.size());
+ verify(completedUnaltered, taskStatusPlusList, false, false, true);
+ verify(completedAltered, taskStatusPlusList, false, true, false);
+ verify(activeUnaltered, taskStatusPlusList, true, false, false);
+ verify(activeAltered, taskStatusPlusList, true, true, false);
+
+ // New columns based fetch before migration is complete. type and payload
are null when altered = false
+ taskStatusPlusList = handler.getTaskStatusPlusList(taskLookups, null,
false);
+ Assert.assertEquals(4, taskStatusPlusList.size());
+ verify(completedUnaltered, taskStatusPlusList, false, false, true);
+ verify(completedAltered, taskStatusPlusList, false, true, true);
+ verify(activeUnaltered, taskStatusPlusList, true, false, true);
+ verify(activeAltered, taskStatusPlusList, true, true, true);
+
+ // MIGRATION
+ derbyConnectorRule.getConnector().migrateTaskTable(entryTable);
+
+ // Payload based fetch. task type and groupid will still be populated
+ taskStatusPlusList = handler.getTaskStatusPlusList(taskLookups, null,
true);
+ Assert.assertEquals(4, taskStatusPlusList.size());
+ verify(completedUnaltered, taskStatusPlusList, false, false, false);
+ verify(completedAltered, taskStatusPlusList, false, true, false);
+ verify(activeUnaltered, taskStatusPlusList, true, false, false);
+ verify(activeAltered, taskStatusPlusList, true, true, false);
+
+ // New columns based fetch before migration is complete.
+ // type and payload are not null for completed task but are still null for
active ones since they aren't migrated
+ // An active task will be eventually updated on its own due to insertion
Review Comment:
This means that there will be two boolean states for the query / mapper
combination.
1) Which query to use for completed tasks determinted by completion of
migration of completed tasks
2) Which query to use for active tasks determined by whether there exist any
active tasks with null type. Once set to true, this check need not happen. This
should be far more efficient than trying to use the payload query for each call
to active tasks when the number of active tasks themselves can be high
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]