-
Notifications
You must be signed in to change notification settings - Fork 587
HDDS-10527. Rewrite key atomically #6385
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
Changes from 12 commits
5fe2ff7
aa3bd32
9799ba5
5040d2b
6f45e67
0635134
c151122
908f9cd
3c9c0e2
17b5ff1
0fe12c5
ae4044c
7bb59e9
8890ed8
a360d45
3f3a49d
736740a
525685c
112e2e1
bcd1a28
4e6a97c
247620a
c6bc7e7
b91a051
9dc6d31
80e1802
bb7b74f
a87e092
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -469,6 +469,25 @@ public OzoneOutputStream createKey(String key, long size, | |||||
| .createKey(volumeName, name, key, size, replicationConfig, keyMetadata); | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Overwrite an existing key using optimistic locking. The existingKey must exist in Ozone to allow | ||||||
| * the new key to be created with the same name. Additionally, the existingKey must not have been | ||||||
| * modified since the time its details were read. This is controlled by the objectID and updateID | ||||||
| * fields in the existingKey. If the key is replaced the objectID will change. If it has been updated | ||||||
| * (eg appended) the updateID will change. If either of these have changed since the existingKey | ||||||
| * was read, either the initial key create will fail, or the key will fail to commit after the data | ||||||
| * has been written. | ||||||
| * | ||||||
| * @param existingKey Name of the key to be created. | ||||||
| * @param replicationConfig Replication configuration. | ||||||
| * @return OzoneOutputStream to which the data has to be written. | ||||||
| * @throws IOException | ||||||
| */ | ||||||
| public OzoneOutputStream overwriteKey(OzoneKeyDetails existingKey, ReplicationConfig replicationConfig) | ||||||
|
||||||
| public OzoneOutputStream overwriteKey(OzoneKeyDetails existingKey, ReplicationConfig replicationConfig) | |
| public OzoneOutputStream atomicUpdateKey(OzoneKeyDetails existingKey, ReplicationConfig replicationConfig) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,11 +70,19 @@ public class OzoneKey { | |
| * Constructs OzoneKey from OmKeyInfo. | ||
| * | ||
| */ | ||
adoroszlai marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * The object and update ID of an existing key. These will be null | ||
| * if the key is not yet created on OM and read from OM. | ||
errose28 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| */ | ||
| private final Long objectID; | ||
| private final Long updateID; | ||
|
||
|
|
||
| @SuppressWarnings("parameternumber") | ||
| public OzoneKey(String volumeName, String bucketName, | ||
| String keyName, long size, long creationTime, | ||
| long modificationTime, ReplicationConfig replicationConfig, | ||
| boolean isFile) { | ||
| boolean isFile, Long objectID, Long updateID) { | ||
adoroszlai marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| this.volumeName = volumeName; | ||
| this.bucketName = bucketName; | ||
| this.name = keyName; | ||
|
|
@@ -83,6 +91,17 @@ public OzoneKey(String volumeName, String bucketName, | |
| this.modificationTime = Instant.ofEpochMilli(modificationTime); | ||
| this.replicationConfig = replicationConfig; | ||
| this.isFile = isFile; | ||
| this.objectID = objectID; | ||
| this.updateID = updateID; | ||
| } | ||
|
|
||
| @SuppressWarnings("parameternumber") | ||
| public OzoneKey(String volumeName, String bucketName, | ||
| String keyName, long size, long creationTime, | ||
| long modificationTime, ReplicationConfig replicationConfig, | ||
| boolean isFile) { | ||
| this(volumeName, bucketName, keyName, size, creationTime, modificationTime, replicationConfig, | ||
| isFile, null, null); | ||
| } | ||
|
|
||
| @SuppressWarnings("parameternumber") | ||
|
|
@@ -91,10 +110,19 @@ public OzoneKey(String volumeName, String bucketName, | |
| long modificationTime, ReplicationConfig replicationConfig, | ||
| Map<String, String> metadata, boolean isFile) { | ||
| this(volumeName, bucketName, keyName, size, creationTime, | ||
| modificationTime, replicationConfig, isFile); | ||
| modificationTime, replicationConfig, isFile, null, null); | ||
| this.metadata.putAll(metadata); | ||
| } | ||
|
|
||
| @SuppressWarnings("parameternumber") | ||
| public OzoneKey(String volumeName, String bucketName, | ||
| String keyName, long size, long creationTime, | ||
| long modificationTime, ReplicationConfig replicationConfig, | ||
| Map<String, String> metadata, boolean isFile, Long objectID, Long updateID) { | ||
| this(volumeName, bucketName, keyName, size, creationTime, | ||
| modificationTime, replicationConfig, isFile, objectID, updateID); | ||
| this.metadata.putAll(metadata); | ||
| } | ||
| /** | ||
| * Returns Volume Name associated with the Key. | ||
| * | ||
|
|
@@ -179,6 +207,16 @@ public ReplicationConfig getReplicationConfig() { | |
| return replicationConfig; | ||
| } | ||
|
|
||
| @JsonIgnore | ||
| public Long getObjectID() { | ||
errose28 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return objectID; | ||
| } | ||
|
|
||
| @JsonIgnore | ||
| public Long getUpdateID() { | ||
| return updateID; | ||
| } | ||
|
|
||
| /** | ||
| * Returns indicator if key is a file. | ||
| * @return file | ||
|
|
@@ -191,7 +229,7 @@ public static OzoneKey fromKeyInfo(OmKeyInfo keyInfo) { | |
| return new OzoneKey(keyInfo.getVolumeName(), keyInfo.getBucketName(), | ||
| keyInfo.getKeyName(), keyInfo.getDataSize(), keyInfo.getCreationTime(), | ||
| keyInfo.getModificationTime(), keyInfo.getReplicationConfig(), | ||
| keyInfo.getMetadata(), keyInfo.isFile()); | ||
| keyInfo.getMetadata(), keyInfo.isFile(), keyInfo.getObjectID(), keyInfo.getUpdateID()); | ||
| } | ||
|
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.