[
https://issues.apache.org/jira/browse/HDDS-1638?focusedWorklogId=265826&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-265826
]
ASF GitHub Bot logged work on HDDS-1638:
----------------------------------------
Author: ASF GitHub Bot
Created on: 24/Jun/19 17:02
Start Date: 24/Jun/19 17:02
Worklog Time Spent: 10m
Work Description: bharatviswa504 commented on pull request #956:
HDDS-1638. Implement Key Write Requests to use Cache and DoubleBuffer.
URL: https://github.com/apache/hadoop/pull/956#discussion_r296821886
##########
File path:
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyRenameRequest.java
##########
@@ -0,0 +1,203 @@
+/**
+ * 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 com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+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.OMMetrics;
+import org.apache.hadoop.ozone.om.OzoneManager;
+import org.apache.hadoop.ozone.om.exceptions.OMException;
+import org.apache.hadoop.ozone.om.helpers.OmKeyInfo;
+import org.apache.hadoop.ozone.om.request.OMClientRequest;
+import org.apache.hadoop.ozone.om.response.OMClientResponse;
+import org.apache.hadoop.ozone.om.response.key.OMKeyRenameResponse;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
+ .KeyArgs;
+import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
+ .RenameKeyRequest;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos
+ .RenameKeyResponse;
+import org.apache.hadoop.ozone.security.acl.IAccessAuthorizer;
+import org.apache.hadoop.ozone.security.acl.OzoneObj;
+import org.apache.hadoop.util.Time;
+import org.apache.hadoop.utils.db.Table;
+import org.apache.hadoop.utils.db.cache.CacheKey;
+import org.apache.hadoop.utils.db.cache.CacheValue;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.Map;
+
+import static
org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.KEY_NOT_FOUND;
+
+/**
+ * Handles rename key request.
+ */
+public class OMKeyRenameRequest extends OMClientRequest
+ implements OMKeyRequest {
+
+ private static final Logger LOG =
+ LoggerFactory.getLogger(OMKeyRenameRequest.class);
+
+ public OMKeyRenameRequest(OMRequest omRequest) {
+ super(omRequest);
+ }
+
+ @Override
+ public OMRequest preExecute(OzoneManager ozoneManager) throws IOException {
+
+ RenameKeyRequest renameKeyRequest = getOmRequest().getRenameKeyRequest();
+ Preconditions.checkNotNull(renameKeyRequest);
+
+ // Set modification time.
+ KeyArgs.Builder newKeyArgs = renameKeyRequest.getKeyArgs().toBuilder()
+ .setModificationTime(Time.now());
+
+ return getOmRequest().toBuilder()
+ .setRenameKeyRequest(renameKeyRequest.toBuilder()
+ .setKeyArgs(newKeyArgs)).setUserInfo(getUserInfo()).build();
+
+ }
+
+ @Override
+ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager,
+ long transactionLogIndex) {
+
+ RenameKeyRequest renameKeyRequest = getOmRequest().getRenameKeyRequest();
+ Preconditions.checkNotNull(renameKeyRequest);
+
+ OzoneManagerProtocolProtos.KeyArgs renameKeyArgs =
+ renameKeyRequest.getKeyArgs();
+
+ String volumeName = renameKeyArgs.getVolumeName();
+ String bucketName = renameKeyArgs.getBucketName();
+ String fromKeyName = renameKeyArgs.getKeyName();
+ String toKeyName = renameKeyRequest.getToKeyName();
+
+ OMMetrics omMetrics = ozoneManager.getMetrics();
+ omMetrics.incNumKeyRenames();
+
+ AuditLogger auditLogger = ozoneManager.getAuditLogger();
+
+ Map<String, String> auditMap = buildKeyArgsAuditMap(renameKeyArgs);
+
+ OzoneManagerProtocolProtos.OMResponse.Builder omResponse =
+ OzoneManagerProtocolProtos.OMResponse.newBuilder().setCmdType(
+ OzoneManagerProtocolProtos.Type.CommitKey).setStatus(
+ OzoneManagerProtocolProtos.Status.OK).setSuccess(true);
+
+ try {
+ if (toKeyName.length() == 0 || fromKeyName.length() == 0) {
+ throw new OMException("Key name is empty",
+ OMException.ResultCodes.INVALID_KEY_NAME);
+ }
+ // check Acl
+ if (ozoneManager.getAclsEnabled()) {
+ checkAcls(ozoneManager, OzoneObj.ResourceType.KEY,
+ OzoneObj.StoreType.OZONE, IAccessAuthorizer.ACLType.WRITE,
+ volumeName, bucketName, fromKeyName);
Review comment:
Already we have a method checkAcl in OmRequest class. If we want to reduce
the number of lines of code. And remaining lines of code are specific to each
request. And same for auditLogging, in super class we have a method, we call
that. Let me know if I am missing something here.
----------------------------------------------------------------
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:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 265826)
Time Spent: 5h 20m (was: 5h 10m)
> Implement Key Write Requests to use Cache and DoubleBuffer
> ----------------------------------------------------------
>
> Key: HDDS-1638
> URL: https://issues.apache.org/jira/browse/HDDS-1638
> Project: Hadoop Distributed Data Store
> Issue Type: Sub-task
> Components: Ozone Manager
> Reporter: Bharat Viswanadham
> Assignee: Bharat Viswanadham
> Priority: Major
> Labels: pull-request-available
> Time Spent: 5h 20m
> Remaining Estimate: 0h
>
> Implement Key write requests to use OM Cache, double buffer.
> In this Jira will add the changes to implement key operations, and HA/Non-HA
> will have a different code path, but once all requests are implemented will
> have a single code path.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]