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
HDDS-6440. Handle custom metadata (x-amz-meta) during put-object through S3 API. #3200
Changes from 3 commits
202fc8f
67a99da
03be08e
87280e6
f63ca57
996afde
44180c1
c1c0454
af9ee6c
1e03a4f
1b12aad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -23,6 +23,8 @@ | |||||||||||||||||||
import org.apache.hadoop.hdds.client.ReplicationType; | ||||||||||||||||||||
|
||||||||||||||||||||
import java.time.Instant; | ||||||||||||||||||||
import java.util.HashMap; | ||||||||||||||||||||
import java.util.Map; | ||||||||||||||||||||
|
||||||||||||||||||||
/** | ||||||||||||||||||||
* A class that encapsulates OzoneKey. | ||||||||||||||||||||
|
@@ -56,6 +58,8 @@ public class OzoneKey { | |||||||||||||||||||
|
||||||||||||||||||||
private ReplicationConfig replicationConfig; | ||||||||||||||||||||
|
||||||||||||||||||||
private Map<String, String> metadata = new HashMap<>(); | ||||||||||||||||||||
|
||||||||||||||||||||
/** | ||||||||||||||||||||
* Constructs OzoneKey from OmKeyInfo. | ||||||||||||||||||||
* | ||||||||||||||||||||
|
@@ -76,6 +80,22 @@ public OzoneKey(String volumeName, String bucketName, | |||||||||||||||||||
ReplicationFactor.valueOf(replicationFactor)); | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
@SuppressWarnings("parameternumber") | ||||||||||||||||||||
public OzoneKey(String volumeName, String bucketName, | ||||||||||||||||||||
String keyName, long size, long creationTime, | ||||||||||||||||||||
long modificationTime, ReplicationType type, | ||||||||||||||||||||
int replicationFactor, Map<String, String> metadata) { | ||||||||||||||||||||
this.volumeName = volumeName; | ||||||||||||||||||||
this.bucketName = bucketName; | ||||||||||||||||||||
this.name = keyName; | ||||||||||||||||||||
this.dataSize = size; | ||||||||||||||||||||
this.creationTime = Instant.ofEpochMilli(creationTime); | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These should be set by OM? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, nesting the constructors would help reduce code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looking into it |
||||||||||||||||||||
this.modificationTime = Instant.ofEpochMilli(modificationTime); | ||||||||||||||||||||
this.replicationConfig = ReplicationConfig.fromTypeAndFactor(type, | ||||||||||||||||||||
ReplicationFactor.valueOf(replicationFactor)); | ||||||||||||||||||||
this.metadata.putAll(metadata); | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
/** | ||||||||||||||||||||
* Constructs OzoneKey from OmKeyInfo. | ||||||||||||||||||||
* | ||||||||||||||||||||
|
@@ -93,6 +113,20 @@ public OzoneKey(String volumeName, String bucketName, | |||||||||||||||||||
this.replicationConfig = replicationConfig; | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
@SuppressWarnings("parameternumber") | ||||||||||||||||||||
public OzoneKey(String volumeName, String bucketName, | ||||||||||||||||||||
String keyName, long size, long creationTime, | ||||||||||||||||||||
long modificationTime, ReplicationConfig replicationConfig, | ||||||||||||||||||||
Map<String, String> metadata) { | ||||||||||||||||||||
this.volumeName = volumeName; | ||||||||||||||||||||
this.bucketName = bucketName; | ||||||||||||||||||||
this.name = keyName; | ||||||||||||||||||||
this.dataSize = size; | ||||||||||||||||||||
this.creationTime = Instant.ofEpochMilli(creationTime); | ||||||||||||||||||||
this.modificationTime = Instant.ofEpochMilli(modificationTime); | ||||||||||||||||||||
this.replicationConfig = replicationConfig; | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
this.metadata.putAll(metadata); | ||||||||||||||||||||
} | ||||||||||||||||||||
/** | ||||||||||||||||||||
* Returns Volume Name associated with the Key. | ||||||||||||||||||||
* | ||||||||||||||||||||
|
@@ -153,6 +187,10 @@ public Instant getModificationTime() { | |||||||||||||||||||
* @return replicationType | ||||||||||||||||||||
*/ | ||||||||||||||||||||
|
||||||||||||||||||||
public Map<String, String> getMetadata() { | ||||||||||||||||||||
return metadata; | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
@Deprecated | ||||||||||||||||||||
public ReplicationType getReplicationType() { | ||||||||||||||||||||
return ReplicationType | ||||||||||||||||||||
|
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.
I think we can omit this constructor (with type and factor), it should be deprecated in favor of
ReplicationConfig
right away.