xiangfu0 commented on code in PR #8465:
URL: https://github.com/apache/pinot/pull/8465#discussion_r847830015
##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/minion/PinotTaskManager.java:
##########
@@ -128,6 +132,68 @@ public PinotTaskManager(PinotHelixTaskResourceManager
helixTaskResourceManager,
}
}
+ public Map<String, String> createTask(String taskType, String tableName,
@Nullable String taskName,
+ Map<String, String> taskConfigs)
+ throws Exception {
+ if (taskName == null) {
+ taskName = tableName + "_" + UUID.randomUUID();
+ LOGGER.info("Task name is missing, auto-generate one: {}", taskName);
+ }
+ String minionInstanceTag =
+ taskConfigs.getOrDefault("minionInstanceTag",
CommonConstants.Helix.UNTAGGED_MINION_INSTANCE);
+ String parentTaskName =
_helixTaskResourceManager.getParentTaskName(taskType, taskName);
+ TaskState taskState =
_helixTaskResourceManager.getTaskState(parentTaskName);
+ if (taskState != null) {
+ throw new RuntimeException(
Review Comment:
added a few exceptions to handle those cases and throw 4xx error code.
##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/minion/PinotTaskManager.java:
##########
@@ -128,6 +132,68 @@ public PinotTaskManager(PinotHelixTaskResourceManager
helixTaskResourceManager,
}
}
+ public Map<String, String> createTask(String taskType, String tableName,
@Nullable String taskName,
+ Map<String, String> taskConfigs)
+ throws Exception {
+ if (taskName == null) {
+ taskName = tableName + "_" + UUID.randomUUID();
+ LOGGER.info("Task name is missing, auto-generate one: {}", taskName);
+ }
+ String minionInstanceTag =
+ taskConfigs.getOrDefault("minionInstanceTag",
CommonConstants.Helix.UNTAGGED_MINION_INSTANCE);
+ String parentTaskName =
_helixTaskResourceManager.getParentTaskName(taskType, taskName);
+ TaskState taskState =
_helixTaskResourceManager.getTaskState(parentTaskName);
+ if (taskState != null) {
+ throw new RuntimeException(
+ "Task [" + taskName + "] of type [" + taskType + "] is already
created. Current state is " + taskState);
+ }
+ List<String> tableNameWithTypes = new ArrayList<>();
+ if (TableNameBuilder.getTableTypeFromTableName(tableName) == null) {
+ String offlineTableName =
TableNameBuilder.OFFLINE.tableNameWithType(tableName);
+ if (_pinotHelixResourceManager.hasOfflineTable(offlineTableName)) {
+ tableNameWithTypes.add(offlineTableName);
+ }
+ String realtimeTableName =
TableNameBuilder.REALTIME.tableNameWithType(tableName);
+ if (_pinotHelixResourceManager.hasRealtimeTable(realtimeTableName)) {
+ tableNameWithTypes.add(realtimeTableName);
+ }
+ } else {
+ if (_pinotHelixResourceManager.hasTable(tableName)) {
+ tableNameWithTypes.add(tableName);
+ }
+ }
+ if (tableNameWithTypes.isEmpty()) {
+ throw new NotFoundException("'tableName' " + tableName + " is not
found");
Review Comment:
done
##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/minion/PinotTaskManager.java:
##########
@@ -128,6 +132,68 @@ public PinotTaskManager(PinotHelixTaskResourceManager
helixTaskResourceManager,
}
}
+ public Map<String, String> createTask(String taskType, String tableName,
@Nullable String taskName,
+ Map<String, String> taskConfigs)
+ throws Exception {
+ if (taskName == null) {
+ taskName = tableName + "_" + UUID.randomUUID();
+ LOGGER.info("Task name is missing, auto-generate one: {}", taskName);
+ }
+ String minionInstanceTag =
+ taskConfigs.getOrDefault("minionInstanceTag",
CommonConstants.Helix.UNTAGGED_MINION_INSTANCE);
+ String parentTaskName =
_helixTaskResourceManager.getParentTaskName(taskType, taskName);
+ TaskState taskState =
_helixTaskResourceManager.getTaskState(parentTaskName);
+ if (taskState != null) {
+ throw new RuntimeException(
+ "Task [" + taskName + "] of type [" + taskType + "] is already
created. Current state is " + taskState);
+ }
+ List<String> tableNameWithTypes = new ArrayList<>();
+ if (TableNameBuilder.getTableTypeFromTableName(tableName) == null) {
+ String offlineTableName =
TableNameBuilder.OFFLINE.tableNameWithType(tableName);
+ if (_pinotHelixResourceManager.hasOfflineTable(offlineTableName)) {
+ tableNameWithTypes.add(offlineTableName);
+ }
+ String realtimeTableName =
TableNameBuilder.REALTIME.tableNameWithType(tableName);
+ if (_pinotHelixResourceManager.hasRealtimeTable(realtimeTableName)) {
+ tableNameWithTypes.add(realtimeTableName);
+ }
+ } else {
+ if (_pinotHelixResourceManager.hasTable(tableName)) {
+ tableNameWithTypes.add(tableName);
+ }
+ }
+ if (tableNameWithTypes.isEmpty()) {
+ throw new NotFoundException("'tableName' " + tableName + " is not
found");
+ }
+
+ PinotTaskGenerator taskGenerator =
_taskGeneratorRegistry.getTaskGenerator(taskType);
+ // Generate each type of tasks
+ if (taskGenerator == null) {
+ throw new UnsupportedOperationException(
Review Comment:
done
--
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]