Skip to content

Commit 04844d5

Browse files
committed
HADOOP-19278. fix the build, tune PutObjectOptions use
Change-Id: I8f30359068e464eb49810bbe964e2048c5962455
1 parent 537218c commit 04844d5

15 files changed

+27
-44
lines changed

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AFileSystem.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2140,8 +2140,7 @@ private FSDataOutputStream innerCreateFile(
21402140
committerIntegration.createTracker(path, key, outputStreamStatistics);
21412141
String destKey = putTracker.getDestKey();
21422142

2143-
// put options are derived from the path and the
2144-
// option builder.
2143+
// put options are derived from the option builder.
21452144
final PutObjectOptions putOptions =
21462145
new PutObjectOptions(null, options.getHeaders());
21472146

@@ -3578,7 +3577,7 @@ private void createFakeDirectoryIfNecessary(Path f)
35783577
// is mostly harmless to create a new one.
35793578
if (!key.isEmpty() && !s3Exists(f, StatusProbeEnum.DIRECTORIES)) {
35803579
LOG.debug("Creating new fake directory at {}", f);
3581-
createFakeDirectory(key, putOptionsForPath(f));
3580+
createFakeDirectory(key, PutObjectOptions.defaultOptions());
35823581
}
35833582
}
35843583

@@ -3806,7 +3805,7 @@ public void createFakeDirectory(final Path dir)
38063805
throws IOException {
38073806
S3AFileSystem.this.createFakeDirectory(
38083807
pathToKey(dir),
3809-
PutObjectOptions.keepingDirs());
3808+
PutObjectOptions.defaultOptions());
38103809
}
38113810
}
38123811

@@ -4210,7 +4209,8 @@ public void copyLocalFileFromTo(File file, Path from, Path to) throws IOExceptio
42104209
newPutObjectRequestBuilder(key, file.length(), false);
42114210
final String dest = to.toString();
42124211
S3AFileSystem.this.invoker.retry("putObject(" + dest + ")", dest, true, () ->
4213-
executePut(putObjectRequestBuilder.build(), null, putOptionsForPath(to), file));
4212+
executePut(putObjectRequestBuilder.build(), null,
4213+
PutObjectOptions.defaultOptions(), file));
42144214
return null;
42154215
});
42164216
}

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/WriteOperationHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ public CompleteMultipartUploadResponse commitUpload(
565565
uploadId,
566566
partETags,
567567
length,
568-
PutObjectOptions.keepingDirs(),
568+
PutObjectOptions.defaultOptions(),
569569
Invoker.NO_OP);
570570
}
571571

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/commit/impl/CommitOperations.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ public SinglePendingCommit uploadFileToPendingCommit(File localFile,
547547

548548
statistics.commitCreated();
549549
uploadId = writeOperations.initiateMultiPartUpload(destKey,
550-
PutObjectOptions.keepingDirs());
550+
PutObjectOptions.defaultOptions());
551551
long length = localFile.length();
552552

553553
SinglePendingCommit commitData = new SinglePendingCommit();

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/commit/magic/S3MagicCommitTracker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public boolean aboutToComplete(String uploadId,
117117
@Retries.RetryTranslated
118118
private void upload(PutObjectRequest request, byte[] bytes) throws IOException {
119119
trackDurationOfInvocation(getTrackerStatistics(), COMMITTER_MAGIC_MARKER_PUT.getSymbol(),
120-
() -> getWriter().putObject(request, PutObjectOptions.keepingDirs(),
120+
() -> getWriter().putObject(request, PutObjectOptions.defaultOptions(),
121121
new S3ADataBlocks.BlockUploadData(bytes, null), null));
122122
}
123123
}

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/impl/PutObjectOptions.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,25 +63,18 @@ public String toString() {
6363
'}';
6464
}
6565

66-
private static final PutObjectOptions KEEP_DIRS = new PutObjectOptions(
67-
null, null);
68-
private static final PutObjectOptions DELETE_DIRS = new PutObjectOptions(
69-
null, null);
70-
7166
/**
72-
* Get the options to keep directories.
73-
* @return an instance which keeps dirs
67+
* Empty options.
7468
*/
75-
public static PutObjectOptions keepingDirs() {
76-
return KEEP_DIRS;
77-
}
69+
private static final PutObjectOptions EMPTY_OPTIONS = new PutObjectOptions(
70+
null, null);
7871

7972
/**
80-
* Get the options to delete directory markers.
81-
* @return an instance which deletes dirs
73+
* Get the default options.
74+
* @return an instance with no storage class or headers.
8275
*/
83-
public static PutObjectOptions deletingDirs() {
84-
return DELETE_DIRS;
76+
public static PutObjectOptions defaultOptions() {
77+
return EMPTY_OPTIONS;
8578
}
8679

8780
}

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/impl/S3AMultipartUploader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public CompletableFuture<UploadHandle> startUpload(
128128
return context.submit(new CompletableFuture<>(),
129129
trackDurationOfCallable(statistics, OBJECT_MULTIPART_UPLOAD_INITIATED.getSymbol(), () -> {
130130
String uploadId = writeOperations.initiateMultiPartUpload(key,
131-
PutObjectOptions.keepingDirs());
131+
PutObjectOptions.defaultOptions());
132132
statistics.uploadStarted();
133133
return BBUploadHandle.from(ByteBuffer.wrap(
134134
uploadId.getBytes(StandardCharsets.UTF_8)));

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AFileOperationCost.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,13 @@
2626
import org.apache.hadoop.fs.s3a.performance.AbstractS3ACostTest;
2727

2828
import org.junit.Test;
29-
import org.junit.runner.RunWith;
30-
import org.junit.runners.Parameterized;
3129
import org.assertj.core.api.Assertions;
3230
import org.slf4j.Logger;
3331
import org.slf4j.LoggerFactory;
3432

3533
import java.io.File;
3634
import java.io.FileNotFoundException;
3735
import java.net.URI;
38-
import java.util.Arrays;
39-
import java.util.Collection;
4036
import java.util.EnumSet;
4137

4238

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AMiscOperations.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public void testPutObjectDirect() throws Throwable {
108108
LambdaTestUtils.intercept(IllegalStateException.class,
109109
() -> fs.putObjectDirect(
110110
putObjectRequestBuilder.build(),
111-
PutObjectOptions.keepingDirs(),
111+
PutObjectOptions.defaultOptions(),
112112
new S3ADataBlocks.BlockUploadData("PUT".getBytes(), null),
113113
null));
114114
assertPathDoesNotExist("put object was created", path);

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/MockS3AFileSystem.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import org.apache.hadoop.fs.s3a.auth.delegation.EncryptionSecrets;
4242
import org.apache.hadoop.fs.s3a.commit.staging.StagingTestBase;
4343
import org.apache.hadoop.fs.s3a.impl.ClientManager;
44-
import org.apache.hadoop.fs.s3a.impl.PutObjectOptions;
4544
import org.apache.hadoop.fs.s3a.impl.RequestFactoryImpl;
4645
import org.apache.hadoop.fs.s3a.impl.StoreContext;
4746
import org.apache.hadoop.fs.s3a.impl.StoreContextBuilder;

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/MultipartTestUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public static IdKey createPartUpload(S3AFileSystem fs, String key, int len,
9090
WriteOperationHelper writeHelper = fs.getWriteOperationHelper();
9191
byte[] data = dataset(len, 'a', 'z');
9292
InputStream in = new ByteArrayInputStream(data);
93-
String uploadId = writeHelper.initiateMultiPartUpload(key, PutObjectOptions.keepingDirs());
93+
String uploadId = writeHelper.initiateMultiPartUpload(key, PutObjectOptions.defaultOptions());
9494
UploadPartRequest req = writeHelper.newUploadPartRequestBuilder(key, uploadId,
9595
partNo, len).build();
9696
RequestBody body = RequestBody.fromInputStream(in, len);

0 commit comments

Comments
 (0)