[
https://issues.apache.org/jira/browse/HDDS-1619?focusedWorklogId=286414&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-286414
]
ASF GitHub Bot logged work on HDDS-1619:
----------------------------------------
Author: ASF GitHub Bot
Created on: 01/Aug/19 05:24
Start Date: 01/Aug/19 05:24
Worklog Time Spent: 10m
Work Description: bharatviswa504 commented on pull request #1147:
HDDS-1619. Support volume acl operations for OM HA. Contributed by…
URL: https://github.com/apache/hadoop/pull/1147#discussion_r309526798
##########
File path:
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/volume/acl/OMVolumeAddAclRequest.java
##########
@@ -0,0 +1,103 @@
+/**
+ * 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.volume.acl;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import org.apache.hadoop.hdds.scm.storage.CheckedBiFunction;
+import org.apache.hadoop.ozone.OzoneAcl;
+import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs;
+import org.apache.hadoop.ozone.om.response.OMClientResponse;
+import org.apache.hadoop.ozone.om.response.volume.OMVolumeAclOpResponse;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos;
+import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest;
+import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * Handles volume add acl request.
+ */
+public class OMVolumeAddAclRequest extends OMVolumeAclRequest {
+ private static final Logger LOG =
+ LoggerFactory.getLogger(OMVolumeAddAclRequest.class);
+
+ private static CheckedBiFunction<List<OzoneAcl>,
+ OmVolumeArgs, IOException> volumeAddAclOp;
+
+ static {
+ volumeAddAclOp = (acls, volArgs) -> volArgs.addAcl(acls.get(0));
+ }
+
+ private List<OzoneAcl> ozoneAcls;
+ private String volumeName;
+
+ public OMVolumeAddAclRequest(OMRequest omRequest) {
+ super(omRequest, volumeAddAclOp);
+ OzoneManagerProtocolProtos.AddAclRequest addAclRequest =
+ getOmRequest().getAddAclRequest();
+ Preconditions.checkNotNull(addAclRequest);
+ ozoneAcls = Lists.newArrayList(
+ OzoneAcl.fromProtobuf(addAclRequest.getAcl()));
+ volumeName = addAclRequest.getObj().getPath().substring(1);
+ }
+
+ @Override
+ public List<OzoneAcl> getAcls() {
+ return ozoneAcls;
+ }
+
+ @Override
+ public String getVolumeName() {
+ return volumeName;
+ }
+
+ private OzoneAcl getAcl() {
+ return ozoneAcls.get(0);
+ }
+
+
+ @Override
+ OMResponse.Builder onInit() {
+ return OMResponse.newBuilder().setCmdType(
+ OzoneManagerProtocolProtos.Type.AddAcl)
+ .setStatus(OzoneManagerProtocolProtos.Status.OK).setSuccess(true);
+ }
+
+ @Override
+ OMClientResponse onSuccess(OMResponse.Builder omResponse,
+ OmVolumeArgs omVolumeArgs){
+ LOG.debug("Add acl: {} to volume: {} success!",
+ getAcl(), getVolumeName());
+ omResponse.setAddAclResponse(OzoneManagerProtocolProtos.AddAclResponse
+ .newBuilder().setResponse(true).build());
+ return new OMVolumeAclOpResponse(omVolumeArgs, omResponse.build());
+ }
+
+ @Override
+ OMClientResponse onFailure(OMResponse.Builder omResponse,
+ IOException ex) {
+ LOG.error("Add acl {} to volume {} failed!",
Review comment:
I liked this approach, code looks cleaner.
Can we move logging outside of these onSuccess and OnFailure. As these are
called with lock held.
----------------------------------------------------------------
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: 286414)
Time Spent: 5h 40m (was: 5.5h)
> Support volume acl operations for OM HA.
> ----------------------------------------
>
> Key: HDDS-1619
> URL: https://issues.apache.org/jira/browse/HDDS-1619
> Project: Hadoop Distributed Data Store
> Issue Type: Sub-task
> Reporter: Ajay Kumar
> Assignee: Xiaoyu Yao
> Priority: Major
> Labels: pull-request-available
> Time Spent: 5h 40m
> Remaining Estimate: 0h
>
> [HDDS-1539] adds 4 new api for Ozone rpc client. OM HA implementation needs
> to handle them.
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]