zhtaoxiang commented on code in PR #9825: URL: https://github.com/apache/pinot/pull/9825#discussion_r1025503700
########## pinot-plugins/pinot-minion-tasks/pinot-minion-builtin-tasks/src/main/java/org/apache/pinot/plugin/minion/tasks/BaseMultipleSegmentsConversionExecutor.java: ########## @@ -242,6 +255,10 @@ public List<SegmentConversionResult> executeTask(PinotTaskConfig pinotTaskConfig new BasicHeader(FileUploadDownloadClient.CustomHeaders.SEGMENT_ZK_METADATA_CUSTOM_MAP_MODIFIER, segmentZKMetadataCustomMapModifier.toJsonString()); + URI outputSegmentTarURI = moveSegmentToOutputPinotFS(pinotTaskConfig.getConfigs(), convertedTarredSegmentFile); Review Comment: I feel that we should check push mode first before moving the segment. Otherwise, this middle step is not needed. ########## pinot-plugins/pinot-minion-tasks/pinot-minion-builtin-tasks/src/main/java/org/apache/pinot/plugin/minion/tasks/mergerollup/MergeRollupTaskGenerator.java: ########## @@ -571,6 +577,40 @@ private List<PinotTaskConfig> createPinotTaskConfigs(List<SegmentZKMetadata> sel return pinotTaskConfigs; } + private Map<String, String> getPushTaskConfig(Map<String, String> batchConfigMap, String downloadUrls) { + try { + String[] downloadURLList = downloadUrls.split(MinionConstants.SEGMENT_NAME_SEPARATOR); + if (downloadURLList.length > 0) { + String downloadUrl = downloadURLList[0]; + URI downloadURI = URI.create(downloadUrl); + URI outputDirURI = null; + if (!downloadURI.getScheme().contentEquals("http")) { Review Comment: Maybe I misunderstand something, but I don't fully follow the logic here. Why is the outputDir decided by the downloadUrl? ########## pinot-plugins/pinot-minion-tasks/pinot-minion-builtin-tasks/src/main/java/org/apache/pinot/plugin/minion/tasks/mergerollup/MergeRollupTaskGenerator.java: ########## @@ -571,6 +577,40 @@ private List<PinotTaskConfig> createPinotTaskConfigs(List<SegmentZKMetadata> sel return pinotTaskConfigs; } + private Map<String, String> getPushTaskConfig(Map<String, String> batchConfigMap, String downloadUrls) { + try { + String[] downloadURLList = downloadUrls.split(MinionConstants.SEGMENT_NAME_SEPARATOR); + if (downloadURLList.length > 0) { + String downloadUrl = downloadURLList[0]; + URI downloadURI = URI.create(downloadUrl); + URI outputDirURI = null; + if (!downloadURI.getScheme().contentEquals("http")) { + String outputDir = downloadUrl.substring(0, downloadUrl.lastIndexOf("/")); + outputDirURI = URI.create(outputDir); + } + String pushMode = IngestionConfigUtils.getPushMode(batchConfigMap); + + Map<String, String> singleFileGenerationTaskConfig = new HashMap<>(batchConfigMap); + if (outputDirURI != null) { + URI outputSegmentDirURI = SegmentGenerationUtils.getRelativeOutputPath( + outputDirURI, downloadURI, outputDirURI); + singleFileGenerationTaskConfig.put( + BatchConfigProperties.OUTPUT_SEGMENT_DIR_URI, outputSegmentDirURI.toString()); + } + if ((outputDirURI == null) || (pushMode == null)) { Review Comment: When push mode is MetadataPush, we should set the default location `data_dir/tablename` when OUTPUT_SEGMENT_DIR_URI is not set by users. Most of the time, users will not need to set it. ########## pinot-plugins/pinot-minion-tasks/pinot-minion-builtin-tasks/src/main/java/org/apache/pinot/plugin/minion/tasks/TaskUtils.java: ########## @@ -0,0 +1,73 @@ +/** + * 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; + +import java.net.URI; +import java.util.Map; +import org.apache.pinot.spi.env.PinotConfiguration; +import org.apache.pinot.spi.filesystem.LocalPinotFS; +import org.apache.pinot.spi.filesystem.PinotFS; +import org.apache.pinot.spi.filesystem.PinotFSFactory; +import org.apache.pinot.spi.ingestion.batch.BatchConfigProperties; +import org.apache.pinot.spi.plugin.PluginManager; +import org.apache.pinot.spi.utils.IngestionConfigUtils; + + +public class TaskUtils { + private TaskUtils() { + } + + static PinotFS getInputPinotFS(Map<String, String> taskConfigs, URI fileURI) Review Comment: It seems that this is not used anywhere? ########## pinot-plugins/pinot-minion-tasks/pinot-minion-builtin-tasks/src/main/java/org/apache/pinot/plugin/minion/tasks/MinionPushUtils.java: ########## @@ -0,0 +1,371 @@ +/** + * 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; + +import com.google.common.base.Preconditions; +import java.io.File; +import java.io.InputStream; +import java.io.Serializable; +import java.net.URI; +import java.net.URISyntaxException; +import java.nio.file.FileSystems; +import java.nio.file.PathMatcher; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.http.Header; +import org.apache.http.NameValuePair; +import org.apache.http.message.BasicHeader; +import org.apache.pinot.common.exception.HttpErrorStatusException; +import org.apache.pinot.common.utils.FileUploadDownloadClient; +import org.apache.pinot.common.utils.SimpleHttpResponse; +import org.apache.pinot.common.utils.TarGzCompressionUtils; +import org.apache.pinot.common.utils.http.HttpClient; +import org.apache.pinot.segment.spi.V1Constants; +import org.apache.pinot.segment.spi.creator.name.SegmentNameUtils; +import org.apache.pinot.spi.config.table.TableType; +import org.apache.pinot.spi.filesystem.PinotFS; +import org.apache.pinot.spi.filesystem.PinotFSFactory; +import org.apache.pinot.spi.ingestion.batch.spec.Constants; +import org.apache.pinot.spi.ingestion.batch.spec.PinotClusterSpec; +import org.apache.pinot.spi.ingestion.batch.spec.PushJobSpec; +import org.apache.pinot.spi.ingestion.batch.spec.SegmentGenerationJobSpec; +import org.apache.pinot.spi.utils.retry.AttemptsExceededException; +import org.apache.pinot.spi.utils.retry.RetriableOperationException; +import org.apache.pinot.spi.utils.retry.RetryPolicies; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class MinionPushUtils implements Serializable { Review Comment: Just curious: why don't we reuse `org.apache.pinot.segment.local.utils.SegmentPushUtils` directly? -- 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