[ 
https://issues.apache.org/jira/browse/HDDS-1379?focusedWorklogId=222692&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-222692
 ]

ASF GitHub Bot logged work on HDDS-1379:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 03/Apr/19 23:32
            Start Date: 03/Apr/19 23:32
    Worklog Time Spent: 10m 
      Work Description: arp7 commented on pull request #689: HDDS-1379. Convert 
all OM Volume related operations to HA model.
URL: https://github.com/apache/hadoop/pull/689#discussion_r271971359
 
 

 ##########
 File path: 
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/protocolPB/OzoneManagerRequestHandler.java
 ##########
 @@ -363,6 +365,199 @@ public OMResponse handle(OMRequest request) {
     return responseBuilder.build();
   }
 
+  @Override
+  public OMRequest handleStartTransaction(OMRequest omRequest)
+      throws IOException {
+    LOG.debug("Received OMRequest: {}, ", omRequest);
+    Type cmdType = omRequest.getCmdType();
+    OMRequest newOmRequest = null;
+    try {
+      switch (cmdType) {
+      case CreateVolume:
+        newOmRequest = handleCreateVolumeStart(omRequest);
+        break;
+      case SetVolumeProperty:
+        newOmRequest = handleSetVolumePropertyStart(omRequest);
+        break;
+      case DeleteVolume:
+        newOmRequest = handleDeleteVolumeStart(omRequest);
+        break;
+      default:
+        new OMException("Unrecognized Command Type:" + cmdType,
+            OMException.ResultCodes.INVALID_REQUEST);
+      }
+    } catch (IOException ex) {
+      throw ex;
+    }
+    return newOmRequest;
+  }
+
+
+  @Override
+  public OMResponse handleApplyTransaction(OMRequest omRequest) {
+    LOG.debug("Received OMRequest: {}, ", omRequest);
+    Type cmdType = omRequest.getCmdType();
+    OMResponse.Builder responseBuilder = OMResponse.newBuilder()
+        .setCmdType(cmdType)
+        .setStatus(Status.OK);
+    try {
+      switch (cmdType) {
+      case CreateVolume:
+        responseBuilder.setCreateVolumeResponse(
+            handleCreateVolumeApply(omRequest));
+        break;
+      case SetVolumeProperty:
+        responseBuilder.setSetVolumePropertyResponse(
+            handleSetVolumePropertyApply(omRequest));
+        break;
+      case DeleteVolume:
+        responseBuilder.setDeleteVolumeResponse(
+            handleDeleteVolumeApply(omRequest));
+        break;
+      default:
+        // As all request types are not changed so we need to call handle
+        // here.
+        return handle(omRequest);
+      }
+      responseBuilder.setSuccess(true);
+    } catch (IOException ex) {
+      responseBuilder.setSuccess(false);
+      responseBuilder.setStatus(exceptionToResponseStatus(ex));
+      if (ex.getMessage() != null) {
+        responseBuilder.setMessage(ex.getMessage());
+      }
+    }
+    return responseBuilder.build();
+  }
+
+
+  private OMRequest handleCreateVolumeStart(OMRequest omRequest)
+      throws IOException {
+    try {
+      OzoneManagerProtocolProtos.VolumeInfo volumeInfo =
+          omRequest.getCreateVolumeRequest().getVolumeInfo();
+      OzoneManagerProtocolProtos.VolumeList volumeList =
+          impl.startCreateVolume(OmVolumeArgs.getFromProtobuf(volumeInfo));
+
+      CreateVolumeRequest createVolumeRequest =
+          CreateVolumeRequest.newBuilder().setVolumeInfo(volumeInfo)
+              .setVolumeList(volumeList).build();
+      return omRequest.toBuilder().setCreateVolumeRequest(createVolumeRequest)
+          .build();
+    } catch (IOException ex) {
+      throw ex;
+    }
+  }
+
+  private CreateVolumeResponse handleCreateVolumeApply(OMRequest omRequest)
+      throws IOException {
+    try {
+      OzoneManagerProtocolProtos.VolumeInfo volumeInfo =
+          omRequest.getCreateVolumeRequest().getVolumeInfo();
+      OzoneManagerProtocolProtos.VolumeList volumeList =
+          omRequest.getCreateVolumeRequest().getVolumeList();
+      impl.applyCreateVolume(OmVolumeArgs.getFromProtobuf(volumeInfo),
+          volumeList);
+    } catch (IOException ex) {
+      throw ex;
+    }
+    return CreateVolumeResponse.newBuilder().build();
+  }
+
+  private OMRequest handleSetVolumePropertyStart(OMRequest omRequest)
+      throws IOException {
+    SetVolumePropertyRequest setVolumePropertyRequest =
+        omRequest.getSetVolumePropertyRequest();
+    String volume = setVolumePropertyRequest.getVolumeName();
+    OMRequest newOmRequest = null;
+    if (setVolumePropertyRequest.hasQuotaInBytes()) {
+      long quota = setVolumePropertyRequest.getQuotaInBytes();
+      OmVolumeArgs omVolumeArgs = impl.startSetQuota(volume, quota);
+      SetVolumePropertyRequest newSetVolumePropertyRequest =
+          SetVolumePropertyRequest.newBuilder().setVolumeName(volume)
+              .setVolumeInfo(omVolumeArgs.getProtobuf()).build();
+      newOmRequest =
+          omRequest.toBuilder().setSetVolumePropertyRequest(
+              newSetVolumePropertyRequest).build();
+    } else {
+      String owner = setVolumePropertyRequest.getOwnerName();
+      OmVolumeOwnerChangeResponse omVolumeOwnerChangeResponse =
+          impl.startSetOwner(volume, owner);
+      // If volumeLists become large and when writing to disk we might take
+      // more space if the lists become very big in size. We might need to
+      // revisit this if it becomes problem
 
 Review comment:
   Is this list stored in a separate table? I think comment text needs fixing, 
looks off.
 
----------------------------------------------------------------
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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 222692)
    Time Spent: 1h 10m  (was: 1h)

> Convert all OM Volume related operations to HA model
> ----------------------------------------------------
>
>                 Key: HDDS-1379
>                 URL: https://issues.apache.org/jira/browse/HDDS-1379
>             Project: Hadoop Distributed Data Store
>          Issue Type: Sub-task
>            Reporter: Bharat Viswanadham
>            Assignee: Bharat Viswanadham
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> In this jira, we shall convert all OM related operations to OM HA model, 
> which is a 2 step.
>  # StartTransaction, where we validate request and check for any errors and 
> return the response.
>  # ApplyTransaction, where original OM request will have a response which 
> needs to be applied to OM DB. This step is just to apply response to Om DB.
> In this way, all requests which are failed with like volume not found or some 
> conditions which i have not satisfied like when deleting volume should be 
> empty, these all will be executed during startTransaction, and if it fails 
> these requests will not be written to raft log also.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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

Reply via email to