adarshsanjeev commented on code in PR #15953: URL: https://github.com/apache/druid/pull/15953#discussion_r1545965661
########## extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/exec/ExportMetadataManager.java: ########## @@ -0,0 +1,91 @@ +/* + * 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.msq.exec; + +import org.apache.druid.error.DruidException; +import org.apache.druid.java.util.common.StringUtils; +import org.apache.druid.java.util.common.logger.Logger; +import org.apache.druid.storage.ExportStorageProvider; +import org.apache.druid.storage.StorageConnector; + +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.nio.charset.StandardCharsets; +import java.util.List; + +/** + * Manages writing of metadata files during export queries. + */ +public class ExportMetadataManager +{ + public static final String SYMLINK_DIR = "_symlink_format_manifest"; + public static final String MANIFEST_FILE = SYMLINK_DIR + "/manifest"; + public static final String META_FILE = SYMLINK_DIR + "/druid_export_meta"; + public static final int MANIFEST_FILE_VERSION = 1; + private static final Logger log = new Logger(ExportMetadataManager.class); + private final ExportStorageProvider exportStorageProvider; + + public ExportMetadataManager(final ExportStorageProvider exportStorageProvider) + { + this.exportStorageProvider = exportStorageProvider; + } + + public void writeMetadata(List<String> exportedFiles) throws IOException + { + final StorageConnector storageConnector = exportStorageProvider.get(); + log.info("Writing manifest file at [%s]", exportStorageProvider.getBasePath()); + + if (storageConnector.pathExists(MANIFEST_FILE) || storageConnector.pathExists(META_FILE)) { + throw DruidException.defensive("Found existing manifest file already present at path."); + } + + createManifestFile(storageConnector, exportedFiles); + createDruidMetadataFile(storageConnector); Review Comment: Yes, it would create manifest file, but not the metadata one and the query should fail. I think this should be fine, since the metadata file itself is for druid to track the version which had previously created the import only -- 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...@druid.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org For additional commands, e-mail: commits-h...@druid.apache.org