swaminathanmanish commented on code in PR #14300: URL: https://github.com/apache/pinot/pull/14300#discussion_r1822220251
########## pinot-plugins/pinot-minion-tasks/pinot-minion-builtin-tasks/src/main/java/org/apache/pinot/plugin/minion/tasks/segmentrefresh/SegmentRefreshTaskGenerator.java: ########## @@ -0,0 +1,167 @@ +/** + * 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.plugin.minion.tasks.segmentrefresh; + +import com.google.common.base.Preconditions; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.apache.pinot.common.data.Segment; +import org.apache.pinot.common.metadata.segment.SegmentZKMetadata; +import org.apache.pinot.controller.helix.core.PinotHelixResourceManager; +import org.apache.pinot.controller.helix.core.minion.generator.BaseTaskGenerator; +import org.apache.pinot.controller.helix.core.minion.generator.TaskGeneratorUtils; +import org.apache.pinot.core.common.MinionConstants; +import org.apache.pinot.core.common.MinionConstants.SegmentRefreshTask; +import org.apache.pinot.core.minion.PinotTaskConfig; +import org.apache.pinot.spi.annotations.minion.TaskGenerator; +import org.apache.pinot.spi.config.table.TableConfig; +import org.apache.pinot.spi.config.table.TableTaskConfig; +import org.apache.pinot.spi.config.table.TableType; +import org.apache.pinot.spi.data.Schema; +import org.apache.zookeeper.data.Stat; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +@TaskGenerator +public class SegmentRefreshTaskGenerator extends BaseTaskGenerator { + private static final Logger LOGGER = LoggerFactory.getLogger(SegmentRefreshTaskGenerator.class); + + @Override + public String getTaskType() { + return MinionConstants.SegmentRefreshTask.TASK_TYPE; + } + + @Override + public List<PinotTaskConfig> generateTasks(List<TableConfig> tableConfigs) { + String taskType = MinionConstants.SegmentRefreshTask.TASK_TYPE; + List<PinotTaskConfig> pinotTaskConfigs = new ArrayList<>(); + int tableNumTasks = 0; + + for (TableConfig tableConfig : tableConfigs) { + String tableNameWithType = tableConfig.getTableName(); + LOGGER.info("Start generating SegmentRefresh tasks for table: {}", tableNameWithType); + + // Get the task configs for the table. This is used to restrict the maximum number of allowed tasks per table at + // any given point. + Map<String, String> taskConfigs; + TableTaskConfig tableTaskConfig = tableConfig.getTaskConfig(); + if (tableTaskConfig == null) { + LOGGER.warn("Failed to find task config for table: {}", tableNameWithType); + continue; + } + taskConfigs = tableTaskConfig.getConfigsForTaskType(MinionConstants.SegmentRefreshTask.TASK_TYPE); + Preconditions.checkNotNull(taskConfigs, "Task config shouldn't be null for Table: %s", tableNameWithType); + int tableMaxNumTasks = Integer.MAX_VALUE; Review Comment: For a large table with a number of segments (eg: 50K segments), you could end up kicking off large number of tasks and overwhelm Zk. Perhaps have a resonable upper bound for the default, given this is a scheduled task which will come back and kick off the next batch ? -- 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