[GitHub] [hadoop-ozone] hanishakoneru commented on a change in pull request #510: HDDS-2958. Handle replay of OM Volume ACL requests

2020-01-31 Thread GitBox
hanishakoneru commented on a change in pull request #510: HDDS-2958. Handle 
replay of OM Volume ACL requests
URL: https://github.com/apache/hadoop-ozone/pull/510#discussion_r373608423
 
 

 ##
 File path: 
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/volume/acl/OMVolumeAclRequest.java
 ##
 @@ -73,53 +74,71 @@ public OMClientResponse 
validateAndUpdateCache(OzoneManager ozoneManager,
 
 OMMetadataManager omMetadataManager = ozoneManager.getMetadataManager();
 boolean lockAcquired = false;
+Result result = null;
 try {
   // check Acl
   if (ozoneManager.getAclsEnabled()) {
 checkAcls(ozoneManager, OzoneObj.ResourceType.VOLUME,
 OzoneObj.StoreType.OZONE, IAccessAuthorizer.ACLType.WRITE_ACL,
 volume, null, null);
   }
-  lockAcquired =
-  omMetadataManager.getLock().acquireWriteLock(VOLUME_LOCK, volume);
+  lockAcquired = omMetadataManager.getLock().acquireWriteLock(
+  VOLUME_LOCK, volume);
   String dbVolumeKey = omMetadataManager.getVolumeKey(volume);
   omVolumeArgs = omMetadataManager.getVolumeTable().get(dbVolumeKey);
   if (omVolumeArgs == null) {
 throw new OMException(OMException.ResultCodes.VOLUME_NOT_FOUND);
   }
 
+  // Check if this transaction is a replay of ratis logs.
+  // If this is a replay, then the response has already been returned to
+  // the client. So take no further action and return a dummy
+  // OMClientResponse.
+  if (isReplay(ozoneManager, omVolumeArgs.getUpdateID(),
+  trxnLogIndex)) {
+throw new OMReplayException();
+  }
+
   // result is false upon add existing acl or remove non-existing acl
-  boolean result = true;
+  boolean applyAcl = true;
   try {
 omVolumeAclOp.apply(ozoneAcls, omVolumeArgs);
   } catch (OMException ex) {
-result = false;
+applyAcl = false;
   }
 
-  if (result) {
+  if (applyAcl) {
+omVolumeArgs.setUpdateID(trxnLogIndex);
 
 Review comment:
   We do not update the DB in case applyAcl is false. So this would add an 
unnecessary DB op. Tradeoff is replay transaction would also check and reach 
the same decision - applyAcl false. So I think it should be ok here. Thoughts?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: ozone-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: ozone-issues-h...@hadoop.apache.org



[GitHub] [hadoop-ozone] hanishakoneru commented on a change in pull request #510: HDDS-2958. Handle replay of OM Volume ACL requests

2020-01-31 Thread GitBox
hanishakoneru commented on a change in pull request #510: HDDS-2958. Handle 
replay of OM Volume ACL requests
URL: https://github.com/apache/hadoop-ozone/pull/510#discussion_r373607488
 
 

 ##
 File path: 
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/volume/acl/OMVolumeSetAclRequest.java
 ##
 @@ -80,29 +80,36 @@ public String getVolumeName() {
 
   @Override
   OMClientResponse onSuccess(OMResponse.Builder omResponse,
-  OmVolumeArgs omVolumeArgs, boolean result){
+  OmVolumeArgs omVolumeArgs, boolean aclApplied){
 omResponse.setSetAclResponse(OzoneManagerProtocolProtos.SetAclResponse
-.newBuilder().setResponse(result).build());
-return new OMVolumeAclOpResponse(omVolumeArgs, omResponse.build());
+.newBuilder().setResponse(aclApplied).build());
+return new OMVolumeAclOpResponse(omResponse.build(), omVolumeArgs);
   }
 
   @Override
   OMClientResponse onFailure(OMResponse.Builder omResponse,
   IOException ex) {
-return new OMVolumeAclOpResponse(null,
-createErrorOMResponse(omResponse, ex));
+return new OMVolumeAclOpResponse(createErrorOMResponse(omResponse, ex));
   }
 
   @Override
-  void onComplete(IOException ex) {
-if (ex == null) {
-  if (LOG.isDebugEnabled()) {
-LOG.debug("Set acls: {} to volume: {} success!",
-getAcls(), getVolumeName());
-  }
-} else {
-  LOG.error("Set acls {} to volume {} failed!",
-  getAcls(), getVolumeName(), ex);
+  void onComplete(Result result, IOException ex, long trxnLogIndex) {
 
 Review comment:
   We are using it to log the exception in case of FAILURE.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: ozone-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: ozone-issues-h...@hadoop.apache.org