Skip to content
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

Merged
merged 8 commits into from
Jun 22, 2020

Conversation

sinhaashish
Copy link
Contributor

@sinhaashish sinhaashish commented Jun 11, 2020

Changes with this PR

  1. ComposeSource class changed , the copyCondition is removed.
  2. ComposeSource class extends ObjectVersionArgs and builder pattern is used to initialise it.
  3. ComposeObject uses copyObject in case partsCount is 1.
  4. uploadPartCopy and createMultipartUpload started using MultiMap.
  5. Returns ObjectWriteResponse for copyObject and composeObject

api/src/main/java/io/minio/BaseArgs.java Outdated Show resolved Hide resolved
api/src/main/java/io/minio/ComposeSourceArgs.java Outdated Show resolved Hide resolved
api/src/main/java/io/minio/ComposeSourceArgs.java Outdated Show resolved Hide resolved
@Override
protected void validate(ComposeSourceArgs args) {
super.validate(args);
validateBucketName(args.bucket());
Copy link
Contributor

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

api/src/main/java/io/minio/MinioClient.java Outdated Show resolved Hide resolved
api/src/main/java/io/minio/MinioClient.java Outdated Show resolved Hide resolved
api/src/main/java/io/minio/MinioClient.java Outdated Show resolved Hide resolved
functional/FunctionalTest.java Outdated Show resolved Hide resolved
functional/FunctionalTest.java Show resolved Hide resolved
@sinhaashish sinhaashish force-pushed the add-builder-compose-object branch 2 times, most recently from 0cf5205 to 8c65613 Compare June 15, 2020 09:54
anjalshireesh
anjalshireesh previously approved these changes Jun 16, 2020
Copy link
Contributor

@anjalshireesh anjalshireesh left a 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) {
Copy link
Contributor

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.

anjalshireesh
anjalshireesh previously approved these changes Jun 17, 2020
Copy link
Contributor

@anjalshireesh anjalshireesh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

docs/API.md Outdated Show resolved Hide resolved
docs/API.md Outdated Show resolved Hide resolved
docs/API.md Outdated Show resolved Hide resolved
api/src/main/java/io/minio/ComposeObjectArgs.java Outdated Show resolved Hide resolved
api/src/main/java/io/minio/ComposeSource.java Outdated Show resolved Hide resolved
api/src/main/java/io/minio/MinioClient.java Outdated Show resolved Hide resolved
api/src/main/java/io/minio/MinioClient.java Outdated Show resolved Hide resolved
api/src/main/java/io/minio/MinioClient.java Outdated Show resolved Hide resolved
functional/FunctionalTest.java Outdated Show resolved Hide resolved
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());
Copy link
Member

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

Copy link
Contributor Author

@sinhaashish sinhaashish Jun 18, 2020

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.

api/src/main/java/io/minio/ComposeObjectArgs.java Outdated Show resolved Hide resolved
docs/API.md Outdated Show resolved Hide resolved
docs/API.md Outdated Show resolved Hide resolved
docs/API.md Outdated Show resolved Hide resolved
docs/API.md Outdated Show resolved Hide resolved
api/src/main/java/io/minio/MinioClient.java Outdated Show resolved Hide resolved
api/src/main/java/io/minio/MinioClient.java Outdated Show resolved Hide resolved
api/src/main/java/io/minio/MinioClient.java Outdated Show resolved Hide resolved
functional/FunctionalTest.java Outdated Show resolved Hide resolved
functional/FunctionalTest.java Outdated Show resolved Hide resolved
api/src/main/java/io/minio/MinioClient.java Outdated Show resolved Hide resolved
api/src/main/java/io/minio/MinioClient.java Outdated Show resolved Hide resolved
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")) {
Copy link
Member

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()

api/src/main/java/io/minio/MinioClient.java Outdated Show resolved Hide resolved
api/src/main/java/io/minio/MinioClient.java Outdated Show resolved Hide resolved
api/src/main/java/io/minio/MinioClient.java Outdated Show resolved Hide resolved
docs/API.md Outdated Show resolved Hide resolved
docs/API.md Outdated Show resolved Hide resolved
docs/API.md Outdated Show resolved Hide resolved
@@ -2647,49 +2715,45 @@ public void composeObject(
}
}

if (partsCount == 1) {
if (args.sources().size() == 1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. You would need to do if (args.sources.size() == 1 && src.offset() == null && src.length() == null) {
  2. No need to use sources.get(0) because src is already pointing to sources.get(0)

"bytes=" + src.offset() + "-" + (src.offset() + src.length() - 1));
Multimap<String, String> headers = HashMultimap.create();
headers.putAll(args.extraHeaders());
headers.putAll(args.headers);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Isn't it headers.putAll(args.headers()) ? Not sure why there is no compiler error to this line.
  2. 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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. use createMultipartUpload() like String uploadId = createMultipartUpload(args.bucket(), args.region(), args.object(), args.genHeaders(), args.extraQueryParams());
  2. move this line at 1242

if (args.sse() != null) {
sseHeaders.putAll(Multimaps.forMap(args.sse().headers()));
headerMap.putAll(args.extraHeaders());
headerMap.putAll(args.headers);
Copy link
Member

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);
Copy link
Member

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);
Copy link
Member

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) {

Copy link
Contributor

@kannappanr kannappanr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@balamurugana balamurugana merged commit 0014bf3 into minio:master Jun 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants