YongGang commented on code in PR #16510:
URL: https://github.com/apache/druid/pull/16510#discussion_r1631702512


##########
extensions-contrib/kubernetes-overlord-extensions/src/main/java/org/apache/druid/k8s/overlord/execution/PodTemplateSelectStrategy.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.druid.k8s.overlord.execution;
+
+import com.fasterxml.jackson.annotation.JsonSubTypes;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import io.fabric8.kubernetes.api.model.PodTemplate;
+import org.apache.druid.indexing.common.task.Task;
+import org.apache.druid.java.util.common.Pair;
+
+import java.util.Map;
+
+/**
+ * Defines a strategy for selecting the Pod template of tasks based on 
specific conditions.
+ */
+@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", defaultImpl = 
TaskTypePodTemplateSelectStrategy.class)
+@JsonSubTypes(value = {
+    @JsonSubTypes.Type(name = "default", value = 
TaskTypePodTemplateSelectStrategy.class),
+    @JsonSubTypes.Type(name = "dynamicTask", value = 
DynamicTaskPodTemplateSelectStrategy.class),
+})
+public interface PodTemplateSelectStrategy
+{
+  /**
+   * Determines the appropriate Pod template for a task by evaluating its 
properties. This selection
+   * allows for customized resource allocation and management tailored to the 
task's specific requirements.
+   *
+   * @param task The task for which the Pod template is determined.
+   * @return A key-value pair representing the selected Pod template. If no 
matching template is found,
+   *         the method falls back to a base template.
+   */
+  Pair<String, PodTemplate> getPodTemplateForTask(Task task, Map<String, 
PodTemplate> templates);
+
+  default Pair<String, PodTemplate> getTemplateOrDefault(String templateKey, 
Map<String, PodTemplate> templates)
+  {
+    if (templates == null) {
+      return null;
+    }
+
+    PodTemplate podTemplate = templates.get(templateKey);
+    if (podTemplate != null) {
+      return Pair.of(templateKey, podTemplate);
+    } else {
+      return Pair.of("base", templates.get("base"));

Review Comment:
   We still have this logic in `PodTemplateTaskAdapter` which also make sure 
there is base template configured.



-- 
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]

Reply via email to