rajagopr commented on code in PR #14340:
URL: https://github.com/apache/pinot/pull/14340#discussion_r1828165485


##########
pinot-controller/src/main/java/org/apache/pinot/controller/util/TaskConfigUtils.java:
##########
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.controller.util;
+
+import java.util.Map;
+import org.apache.pinot.controller.helix.core.minion.PinotTaskManager;
+import 
org.apache.pinot.controller.helix.core.minion.generator.PinotTaskGenerator;
+import 
org.apache.pinot.controller.helix.core.minion.generator.TaskGeneratorRegistry;
+import org.apache.pinot.spi.config.table.TableConfig;
+import org.apache.pinot.spi.config.table.TableTaskConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class TaskConfigUtils {
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(TaskConfigUtils.class);
+
+  private TaskConfigUtils() {
+  }
+
+  public static void validateTaskConfigs(TableConfig tableConfig, 
PinotTaskManager pinotTaskManager) {
+    if (tableConfig == null || tableConfig.getTaskConfig() == null) {
+      return;
+    }
+    TableTaskConfig taskConfig = tableConfig.getTaskConfig();
+    for (Map.Entry<String, Map<String, String>> taskConfigEntry : 
taskConfig.getTaskTypeConfigsMap().entrySet()) {
+      String taskType = taskConfigEntry.getKey();
+      TaskGeneratorRegistry taskRegistry = 
pinotTaskManager.getTaskGeneratorRegistry();
+      if (taskRegistry != null) {
+        PinotTaskGenerator taskGenerator = 
taskRegistry.getTaskGenerator(taskType);
+        if (taskGenerator != null) {
+          taskGenerator.validateTaskConfigs(tableConfig);
+        } else {
+          LOGGER.warn("Task generator not found for task type: {}, while 
validating table configs for table: {}",

Review Comment:
   This is more of a safety check and ideally should not happen. However, it 
can happen under the following scenarios:
   
   1) Required pinot task plugin is missing from the deployment. As a result, 
the relevant task is not registered.
   2) In the task config, the user makes a typo. 
   
   It won't be validated anywhere as tasks are registered dynamically based on 
reflection.



-- 
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: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to