ZihanLi58 commented on code in PR #3598: URL: https://github.com/apache/gobblin/pull/3598#discussion_r1030929621
########## gobblin-data-management/src/main/java/org/apache/gobblin/data/management/copy/ManifestBasedDataset.java: ########## @@ -0,0 +1,145 @@ +/* + * 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.gobblin.data.management.copy; + +import com.google.common.base.Optional; +import com.google.common.collect.Iterators; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.gson.Gson; +import com.google.gson.JsonIOException; +import com.google.gson.JsonObject; +import com.google.gson.JsonSyntaxException; +import com.google.gson.stream.JsonReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Properties; +import lombok.extern.slf4j.Slf4j; +import org.apache.gobblin.commit.CommitStep; +import org.apache.gobblin.data.management.copy.entities.PrePublishStep; +import org.apache.gobblin.data.management.partition.FileSet; +import org.apache.gobblin.util.commit.DeleteFileCommitStep; +import org.apache.hadoop.fs.FileStatus; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; + + +/** + * A dataset that based on Manifest. We expect the Manifest contains the list of all the files for this dataset. + * At first phase, we only support copy across different clusters to the same location. (We can add more feature to support rename in the future) + */ +@Slf4j +public class ManifestBasedDataset implements IterableCopyableDataset { + + public static final String CONFIG_PREFIX = CopyConfiguration.COPY_PREFIX + ".manifestBased"; + private static final String DELETE_FILE_NOT_EXIST_ON_SOURCE = CONFIG_PREFIX + ".deleteFileNotExistOnSource"; + /** If true, will delete newly empty directories up to the config set in DELETE_EMPTY_DIRECTORIES_UPTO. */ + public static final String DELETE_EMPTY_DIRECTORIES_KEY = CONFIG_PREFIX + ".deleteEmptyDirectories"; + public static final String DELETE_EMPTY_DIRECTORIES_UPTO = CONFIG_PREFIX + ".deleteEmptyDirectoriesUpTo"; + private final FileSystem fs; + private final Path manifestPath; + private final Properties properties; + private final boolean deleteEmptyDirectories; + private Gson GSON = new Gson(); + + public ManifestBasedDataset(final FileSystem fs, Path manifestPath, Properties properties) { + this.fs = fs; + this.manifestPath = manifestPath; + this.properties = properties; + this.deleteEmptyDirectories = Boolean.parseBoolean(properties.getProperty(DELETE_EMPTY_DIRECTORIES_KEY, "false")) + && properties.containsKey(DELETE_EMPTY_DIRECTORIES_UPTO); Review Comment: It will be files not exists on source are deleted but no empty dir will be deleted -- 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: dev-unsubscr...@gobblin.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org