-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-10077. Add hsync metadata to hsync'ed keys in OpenKeyTable as well #6046
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 all commits
665dc84
a933b83
9ac270e
7bdb083
a15c9ae
e4d8d3e
2274739
de7ec3f
80cc7b2
74f98ec
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 |
|---|---|---|
|
|
@@ -42,6 +42,7 @@ | |
| import org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo; | ||
| import org.apache.hadoop.ozone.om.helpers.WithMetadata; | ||
| import org.apache.hadoop.ozone.om.request.util.OmResponseUtil; | ||
| import org.apache.hadoop.ozone.om.request.util.OmKeyHSyncUtil; | ||
| import org.apache.hadoop.ozone.om.request.validation.RequestFeatureValidator; | ||
| import org.apache.hadoop.ozone.om.request.validation.RequestProcessingPhase; | ||
| import org.apache.hadoop.ozone.om.request.validation.ValidationCondition; | ||
|
|
@@ -81,8 +82,7 @@ | |
| public class OMKeyCommitRequest extends OMKeyRequest { | ||
|
|
||
| @VisibleForTesting | ||
| public static final Logger LOG = | ||
| LoggerFactory.getLogger(OMKeyCommitRequest.class); | ||
| public static final Logger LOG = LoggerFactory.getLogger(OMKeyCommitRequest.class); | ||
|
|
||
| public OMKeyCommitRequest(OMRequest omRequest, BucketLayout bucketLayout) { | ||
| super(omRequest, bucketLayout); | ||
|
|
@@ -237,7 +237,7 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, TermIn | |
|
|
||
| final String clientIdString = String.valueOf(writerClientId); | ||
| if (null != keyToDelete) { | ||
| isPreviousCommitHsync = java.util.Optional.ofNullable(keyToDelete) | ||
| isPreviousCommitHsync = java.util.Optional.of(keyToDelete) | ||
| .map(WithMetadata::getMetadata) | ||
| .map(meta -> meta.get(OzoneConsts.HSYNC_CLIENT_ID)) | ||
| .filter(id -> id.equals(clientIdString)) | ||
|
|
@@ -260,17 +260,24 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, TermIn | |
| " metadata while recovery flag is not set in request", KEY_UNDER_LEASE_RECOVERY); | ||
| } | ||
| } | ||
| omKeyInfo.getMetadata().putAll(KeyValueUtil.getFromProtobuf( | ||
| commitKeyArgs.getMetadataList())); | ||
|
|
||
| omKeyInfo.setModificationTime(commitKeyArgs.getModificationTime()); | ||
|
|
||
| // non-null indicates it is necessary to update the open key | ||
| OmKeyInfo newOpenKeyInfo = null; | ||
|
|
||
| if (isHSync) { | ||
| omKeyInfo.getMetadata().put(OzoneConsts.HSYNC_CLIENT_ID, clientIdString); | ||
| } else if (isRecovery) { | ||
| omKeyInfo.getMetadata().remove(OzoneConsts.HSYNC_CLIENT_ID); | ||
| omKeyInfo.getMetadata().remove(OzoneConsts.LEASE_RECOVERY); | ||
| if (!OmKeyHSyncUtil.isHSyncedPreviously(omKeyInfo, clientIdString, dbOpenKey)) { | ||
smengcl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // Update open key as well if it is the first hsync of this key | ||
| omKeyInfo.getMetadata().put(OzoneConsts.HSYNC_CLIENT_ID, clientIdString); | ||
| newOpenKeyInfo = omKeyInfo.copyObject(); | ||
|
Contributor
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. The modification time should be updated for newOpenKeyInfo.
Contributor
Author
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. Good idea. Then the mod time in open key would indicate the first time the key is hsync'ed (since open key will only be updated on the first hsync). Done. |
||
| } | ||
| } | ||
|
|
||
| omKeyInfo.getMetadata().putAll(KeyValueUtil.getFromProtobuf( | ||
| commitKeyArgs.getMetadataList())); | ||
smengcl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| omKeyInfo.setDataSize(commitKeyArgs.getDataSize()); | ||
| omKeyInfo.setModificationTime(commitKeyArgs.getModificationTime()); | ||
|
|
||
| // Update the block length for each block, return the allocated but | ||
| // uncommitted blocks | ||
| List<OmKeyLocationInfo> uncommitted = | ||
|
|
@@ -337,6 +344,16 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, TermIn | |
| // So that this key can't be committed again. | ||
| omMetadataManager.getOpenKeyTable(getBucketLayout()).addCacheEntry( | ||
| dbOpenKey, trxnLogIndex); | ||
|
|
||
| // Prevent hsync metadata from getting committed to the final key | ||
| omKeyInfo.getMetadata().remove(OzoneConsts.HSYNC_CLIENT_ID); | ||
| if (isRecovery) { | ||
| omKeyInfo.getMetadata().remove(OzoneConsts.LEASE_RECOVERY); | ||
| } | ||
| } else if (newOpenKeyInfo != null) { | ||
| // isHSync is true and newOpenKeyInfo is set, update OpenKeyTable | ||
| omMetadataManager.getOpenKeyTable(getBucketLayout()).addCacheEntry( | ||
| dbOpenKey, newOpenKeyInfo, trxnLogIndex); | ||
| } | ||
|
|
||
| omMetadataManager.getKeyTable(getBucketLayout()).addCacheEntry( | ||
|
|
@@ -346,7 +363,7 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, TermIn | |
|
|
||
| omClientResponse = new OMKeyCommitResponse(omResponse.build(), | ||
| omKeyInfo, dbOzoneKey, dbOpenKey, omBucketInfo.copyObject(), | ||
| oldKeyVersionsToDeleteMap, isHSync); | ||
| oldKeyVersionsToDeleteMap, isHSync, newOpenKeyInfo); | ||
|
|
||
| result = Result.SUCCESS; | ||
| } catch (IOException | InvalidPathException ex) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.