bogthe commented on a change in pull request #3101: URL: https://github.com/apache/hadoop/pull/3101#discussion_r671396075
########## File path: hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/impl/CopyFromLocalOperation.java ########## @@ -0,0 +1,520 @@ +/* + * 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.hadoop.fs.s3a.impl; + +import org.apache.commons.collections.comparators.ReverseComparator; +import org.apache.hadoop.fs.FileStatus; +import org.apache.hadoop.fs.LocatedFileStatus; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.fs.PathExistsException; +import org.apache.hadoop.fs.PathIOException; +import org.apache.hadoop.fs.RemoteIterator; +import org.apache.hadoop.fs.s3a.Retries; +import org.apache.hadoop.io.IOUtils; +import org.apache.hadoop.thirdparty.com.google.common.util.concurrent.ListeningExecutorService; +import org.apache.hadoop.thirdparty.com.google.common.util.concurrent.MoreExecutors; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.Closeable; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.Serializable; +import java.net.URI; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashSet; +import java.util.List; +import java.util.Optional; +import java.util.Set; +import java.util.Stack; +import java.util.concurrent.CompletableFuture; + +import static org.apache.hadoop.fs.s3a.impl.CallableSupplier.submit; +import static org.apache.hadoop.fs.s3a.impl.CallableSupplier.waitForCompletion; +import static org.apache.hadoop.fs.store.audit.AuditingFunctions.callableWithinAuditSpan; + +/** + * <p>Implementation of CopyFromLocalOperation</p> + * <p> + * This operation copies a file or directory (recursively) from a local + * FS to an object store. Initially, this operation has been developed for + * S3 (s3a) interaction, however, there's minimal work needed for it to + * work with other stores. + * </p> + * <p>How the uploading of files works:</p> + * <ul> + * <li> all source files and directories are scanned through;</li> + * <li> the LARGEST_N_FILES start uploading; </li> + * <li> the remaining files are shuffled and uploaded; </li> + * <li> + * any remaining empty directory is uploaded too to preserve local + * tree structure. + * </li> + * </ul> + */ +public class CopyFromLocalOperation extends ExecutingStoreOperation<Void> { + + /** + * Largest N files to be uploaded first + */ + private static final int LARGEST_N_FILES = 5; Review comment: No reason, it looked like a safe starting point. Since it's very case by case specific one improvement that can be added later on would be to look at all the files and pick only the "bigger" ones when compared to others. -- 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]
