ayushtkn commented on code in PR #4720:
URL: https://github.com/apache/ozone/pull/4720#discussion_r1203575864


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeySetTimesRequest.java:
##########
@@ -0,0 +1,246 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.om.request.key;
+
+import java.io.IOException;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.apache.hadoop.hdds.utils.db.cache.CacheKey;
+import org.apache.hadoop.hdds.utils.db.cache.CacheValue;
+import org.apache.hadoop.ozone.OzoneConsts;
+import org.apache.hadoop.ozone.audit.AuditLogger;
+import org.apache.hadoop.ozone.audit.OMAction;
+import org.apache.hadoop.ozone.om.OMMetadataManager;
+import org.apache.hadoop.ozone.om.OzoneManager;
+import org.apache.hadoop.ozone.om.exceptions.OMException;
+import org.apache.hadoop.ozone.om.helpers.BucketLayout;
+import org.apache.hadoop.ozone.om.helpers.OmKeyInfo;
+import org.apache.hadoop.ozone.om.ratis.utils.OzoneManagerDoubleBufferHelper;
+import org.apache.hadoop.ozone.om.request.util.OmResponseUtil;
+import org.apache.hadoop.ozone.om.response.key.OMKeySetTimesResponse;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos;
+import 
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.SetTimesRequest;
+import 
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.SetTimesResponse;
+import org.apache.hadoop.ozone.security.acl.IAccessAuthorizer;
+import org.apache.hadoop.ozone.security.acl.OzoneObj;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.hadoop.ozone.om.response.OMClientResponse;
+import 
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest;
+import 
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse;
+
+import static 
org.apache.hadoop.ozone.om.lock.OzoneManagerLock.Resource.BUCKET_LOCK;
+
+/**
+ * Handle add SetTime request for key.
+ */
+public class OMKeySetTimesRequest extends OMKeyRequest {
+
+  private static final Logger LOG =
+      LoggerFactory.getLogger(OMKeySetTimesRequest.class);
+
+  @Override
+  public OMRequest preExecute(OzoneManager ozoneManager) throws IOException {
+    OMRequest request = super.preExecute(ozoneManager);
+    SetTimesRequest setTimesRequest = request.getSetTimesRequest();
+    String keyPath = setTimesRequest.getKeyArgs().getKeyName();
+    String normalizedKeyPath =
+        validateAndNormalizeKey(ozoneManager.getEnableFileSystemPaths(),
+            keyPath, getBucketLayout());
+
+    OzoneManagerProtocolProtos.KeyArgs keyArgs =
+        OzoneManagerProtocolProtos.KeyArgs.newBuilder()
+            .setVolumeName(getVolumeName())
+            .setBucketName(getBucketName())
+            .setKeyName(normalizedKeyPath)
+            .build();
+
+    return request.toBuilder()
+        .setSetTimesRequest(
+            setTimesRequest.toBuilder()
+                .setKeyArgs(keyArgs)
+                .setMtime(getModificationTime()))
+        .build();
+  }
+
+  private final String volumeName;
+  private final String bucketName;
+  private final String keyName;
+  private final long modificationTime;
+
+  public OMKeySetTimesRequest(OMRequest omRequest, BucketLayout bucketLayout) {
+    super(omRequest, bucketLayout);
+    OzoneManagerProtocolProtos.SetTimesRequest setTimesRequest =
+        getOmRequest().getSetTimesRequest();
+    volumeName = setTimesRequest.getKeyArgs().getVolumeName();
+    bucketName = setTimesRequest.getKeyArgs().getBucketName();
+    keyName = setTimesRequest.getKeyArgs().getKeyName();
+    // ignore accessTime
+    modificationTime = setTimesRequest.getMtime();
+  }
+
+  protected String getVolumeName() {
+    return volumeName;
+  }
+
+  protected String getBucketName() {
+    return bucketName;
+  }
+
+  protected String getKeyName() {
+    return keyName;
+  }
+
+  protected long getModificationTime() {
+    return modificationTime;
+  }
+
+  OMResponse.Builder onInit() {
+    return OmResponseUtil.getOMResponseBuilder(getOmRequest());
+  }
+
+  OMClientResponse onSuccess(OMResponse.Builder omResponse,
+      OmKeyInfo omKeyInfo, boolean operationResult) {
+    omResponse.setSuccess(operationResult);
+    omResponse.setSetTimesResponse(SetTimesResponse.newBuilder());
+    return new OMKeySetTimesResponse(omResponse.build(), omKeyInfo);
+  }
+
+  /**
+   * Get the om client response on failure case with lock.
+   * @param omResponse
+   * @param exception
+   * @return OMClientResponse
+   */
+  OMClientResponse onFailure(OMResponse.Builder omResponse,
+      IOException exception) {
+    return new OMKeySetTimesResponse(createErrorOMResponse(
+        omResponse, exception), getBucketLayout());
+  }
+
+  void onComplete(Result result, boolean operationResult,
+      IOException exception, long trxnLogIndex, AuditLogger auditLogger,

Review Comment:
   ``operationResult`` and ``trxnLogIndex`` are unused?



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to