amaliujia commented on a change in pull request #1725:
URL: https://github.com/apache/ozone/pull/1725#discussion_r553743247



##########
File path: 
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMDBTransactionBuffer.java
##########
@@ -0,0 +1,75 @@
+/*
+ * 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.hdds.scm.ha;
+
+import org.apache.hadoop.hdds.scm.metadata.SCMMetadataStore;
+import org.apache.hadoop.hdds.utils.db.BatchOperation;
+import org.apache.hadoop.hdds.utils.db.Table;
+
+import java.io.IOException;
+
+import static org.apache.hadoop.ozone.OzoneConsts.TRANSACTION_INFO_KEY;
+
+public class SCMDBTransactionBuffer {
+  private final SCMMetadataStore metadataStore;
+  private BatchOperation currentBatchOperation;
+  private SCMTransactionInfo latestTrxInfo;
+
+  public SCMDBTransactionBuffer(SCMMetadataStore store) {
+    this.metadataStore = store;
+
+    // initialize a batch operation during construction time
+    currentBatchOperation = this.metadataStore.getStore().initBatchOperation();
+    latestTrxInfo =
+        SCMTransactionInfo
+            .builder()
+            .setTransactionIndex(-1)
+            .setCurrentTerm(0)
+            .build();
+  }
+
+  public BatchOperation getCurrentBatchOperation() {

Review comment:
       Do you know is there a better mechanism to achieve the buffering? 
   
   I studied what OM does and that is different from SCM. OM just buffer entry 
and then apply entries in a batch, but SCM need to router such entry to 
handlers and then different handler will apply the entry.
   
   So if we change to the way that OM is doing, there will be a good amount of 
refactoring needs happen, which might be not appropriate in this PR. E.g. We 
will need to move handlers to the buffer class and insert entries into buffer. 
Buffer will be the place to trouter entries to right state managers.
   
   What do you think? I can create a PR to track such refactoring thus we won't 
need to expose  `currentBatchOperation`




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



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

Reply via email to