-
Notifications
You must be signed in to change notification settings - Fork 485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add builder support to Compose object api #979
Add builder support to Compose object api #979
Conversation
@Override | ||
protected void validate(ComposeSourceArgs args) { | ||
super.validate(args); | ||
validateBucketName(args.bucket()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not required as super.validate(args)
internally invokes validateBucketName
anyway
0cf5205
to
8c65613
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, apart for one small comment. Also, you need to rebase and resolve conflicts.
/** Argument builder of {@link ComposeSource}. */ | ||
public static final class Builder extends ObjectVersionArgs.Builder<Builder, ComposeSource> { | ||
@Override | ||
protected void validate(ComposeSource args) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this method is not doing anything apart from calling the super method, it is not required anymore.
2e013da
to
31168c1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
functional/FunctionalTest.java
Outdated
private static void deleteFilesAndObjects(String bucketName, String files[]) throws Exception { | ||
for (String filename : files) { | ||
Files.delete(Paths.get(filename)); | ||
client.removeObject(RemoveObjectArgs.builder().bucket(bucketName).object(filename).build()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is not necessary. you could use removeObjects()
then this for
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is used to make the functional Test less verbose as the same code was repeating 6 composeObject
test . I have used removeObjects
now.
788562e
to
21d5df8
Compare
src.buildHeaders(stat.length(), stat.etag()); | ||
|
||
if (i != 0 && src.headers().containsKey("x-amz-meta-x-amz-key")) { | ||
if (i != 0 && src.extraHeaders().containsKey("x-amz-meta-x-amz-key")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You would need to use headers()
not extraHeaders()
. headers
member data is updated in ComposeSource.buildHeaders()
e22aef8
to
0a93db6
Compare
0a93db6
to
40934b0
Compare
@@ -2647,49 +2715,45 @@ public void composeObject( | |||
} | |||
} | |||
|
|||
if (partsCount == 1) { | |||
if (args.sources().size() == 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- You would need to do
if (args.sources.size() == 1 && src.offset() == null && src.length() == null) {
- No need to use
sources.get(0)
becausesrc
is already pointing tosources.get(0)
"bytes=" + src.offset() + "-" + (src.offset() + src.length() - 1)); | ||
Multimap<String, String> headers = HashMultimap.create(); | ||
headers.putAll(args.extraHeaders()); | ||
headers.putAll(args.headers); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Isn't it
headers.putAll(args.headers())
? Not sure why there is no compiler error to this line. - Why is it required to create combined headers here? Can't you use them directly like
.extraHeaders(args.extraHeaders()).headers(args.headers())
?
} | ||
|
||
String uploadId = createMultipartUpload(bucketName, objectName, headerMap); | ||
String uploadId = createMultipartUpload(args.bucket(), null, args.object(), headerMap, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- use
createMultipartUpload()
likeString uploadId = createMultipartUpload(args.bucket(), args.region(), args.object(), args.genHeaders(), args.extraQueryParams());
- move this line at 1242
if (args.sse() != null) { | ||
sseHeaders.putAll(Multimaps.forMap(args.sse().headers())); | ||
headerMap.putAll(args.extraHeaders()); | ||
headerMap.putAll(args.headers); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it headers.putAll(args.headers())
? Not sure why there is no compiler error to this line.
throw e; | ||
} catch (Exception e) { | ||
abortMultipartUpload(bucketName, objectName, uploadId); | ||
abortMultipartUpload(args.bucket(), args.object(), uploadId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
abortMultipartUpload()
should be called not if (args.sources.size() == 1 && src.offset() == null && src.length() == null) {
} catch (RuntimeException e) { | ||
abortMultipartUpload(bucketName, objectName, uploadId); | ||
abortMultipartUpload(args.bucket(), args.object(), uploadId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
abortMultipartUpload()
should be called not if (args.sources.size() == 1 && src.offset() == null && src.length() == null) {
65557a6
to
105b906
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Changes with this PR
ComposeSource
class changed , the copyCondition is removed.ComposeSource
class extends ObjectVersionArgs and builder pattern is used to initialise it.ComposeObject
usescopyObject
in casepartsCount
is 1.uploadPartCopy
andcreateMultipartUpload
started usingMultiMap
.ObjectWriteResponse
for copyObject andcomposeObject