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

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

                Author: ASF GitHub Bot
            Created on: 28/Mar/19 17:48
            Start Date: 28/Mar/19 17:48
    Worklog Time Spent: 10m 
      Work Description: bharatviswa504 commented on pull request #651: 
HDDS-1339. Implement ratis snapshots on OM
URL: https://github.com/apache/hadoop/pull/651#discussion_r270120787
 
 

 ##########
 File path: 
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerStateMachine.java
 ##########
 @@ -115,7 +117,60 @@ public TransactionContext startTransaction(
       return ctxt;
     }
     return handleStartTransactionRequests(raftClientRequest, omRequest);
+  }
+
+  /*
+   * Apply a committed log entry to the state machine.
+   */
+  @Override
+  public CompletableFuture<Message> applyTransaction(TransactionContext trx) {
+    try {
+      OMRequest request = OMRatisHelper.convertByteStringToOMRequest(
+          trx.getStateMachineLogEntry().getLogData());
+      long trxLogIndex = trx.getLogEntry().getIndex();
+      CompletableFuture<Message> future = CompletableFuture
+          .supplyAsync(() -> runCommand(request, trxLogIndex));
+      return future;
+    } catch (IOException e) {
+      return completeExceptionally(e);
+    }
+  }
+
+  /**
+   * Query the state machine. The request must be read-only.
+   */
+  @Override
+  public CompletableFuture<Message> query(Message request) {
+    try {
+      OMRequest omRequest = OMRatisHelper.convertByteStringToOMRequest(
+          request.getContent());
+      return CompletableFuture.completedFuture(queryCommand(omRequest));
+    } catch (IOException e) {
+      return completeExceptionally(e);
+    }
+  }
+
+  /**
+   * Take OM Ratis snapshot. Write the snapshot index to file. Snapshot index
+   * is the log index corresponding to the last applied transaction on the OM
+   * State Machine.
+   *
+   * @return the last applied index on the state machine which has been
+   * stored in the snapshot file.
+   */
+  @Override
+  public long takeSnapshot() throws IOException {
+    LOG.info("Saving Ratis snapshot on the OM.");
+    return ozoneManager.saveRatisSnapshot();
 
 Review comment:
   Question: Can we consider this applied and when the snapshot is taken can we 
consider that it is completed?
   
   As writing to rocksdb means is it is not written to disk(As we are writing 
with sync false), so when we take a snapshot, we should also flush the DB to 
make sure the applied index transaction is applied to OM DB.
 
----------------------------------------------------------------
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: 220180)
    Time Spent: 1h  (was: 50m)

> Implement Ratis Snapshots on OM
> -------------------------------
>
>                 Key: HDDS-1339
>                 URL: https://issues.apache.org/jira/browse/HDDS-1339
>             Project: Hadoop Distributed Data Store
>          Issue Type: Sub-task
>            Reporter: Hanisha Koneru
>            Assignee: Hanisha Koneru
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> For bootstrapping and restarting OMs, we need to implement snapshots in OM. 
> The OM state maintained by RocksDB will be checkpoint-ed on demand. Ratis 
> snapshots will only preserve the last applied log index by the State Machine 
> on disk. This index will be stored in file in the OM metadata dir.



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

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

Reply via email to