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

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

                Author: ASF GitHub Bot
            Created on: 23/May/19 21:13
            Start Date: 23/May/19 21:13
    Worklog Time Spent: 10m 
      Work Description: bharatviswa504 commented on pull request #810: 
HDDS-1512. Implement DoubleBuffer in OzoneManager.
URL: https://github.com/apache/hadoop/pull/810#discussion_r287136965
 
 

 ##########
 File path: 
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/ratis/TestOzoneManagerDoubleBuffer.java
 ##########
 @@ -0,0 +1,397 @@
+/**
+ * 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.ratis;
+
+import java.io.IOException;
+import java.util.Queue;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.hadoop.ozone.om.response.OMBucketCreateResponse;
+import org.apache.hadoop.ozone.om.response.OMBucketDeleteResponse;
+import org.apache.hadoop.ozone.om.response.OMClientResponse;
+import org.apache.hadoop.utils.db.BatchOperation;
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.ozone.om.OMMetadataManager;
+import org.apache.hadoop.ozone.om.OmMetadataManagerImpl;
+import org.apache.hadoop.ozone.om.helpers.OmBucketInfo;
+import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs;
+import org.apache.hadoop.ozone.om.response.OMVolumeCreateResponse;
+import 
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.VolumeList;
+import org.apache.hadoop.test.GenericTestUtils;
+import org.apache.hadoop.util.Daemon;
+import org.apache.hadoop.util.Time;
+
+
+
+import static org.apache.hadoop.hdds.HddsConfigKeys.OZONE_METADATA_DIRS;
+import static org.junit.Assert.fail;
+
+/**
+ * This class tests OzoneManagerDouble Buffer.
+ */
+public class TestOzoneManagerDoubleBuffer {
+
+  private OMMetadataManager omMetadataManager;
+  private OzoneManagerDoubleBuffer doubleBuffer;
+  private AtomicLong trxId = new AtomicLong(0);
+
+  @Rule
+  public TemporaryFolder folder = new TemporaryFolder();
+
+  private void setup() throws IOException  {
+    OzoneConfiguration configuration = new OzoneConfiguration();
+    configuration.set(OZONE_METADATA_DIRS,
+        folder.newFolder().getAbsolutePath());
+    omMetadataManager =
+        new OmMetadataManagerImpl(configuration);
+    doubleBuffer = new OzoneManagerDoubleBuffer(omMetadataManager);
+  }
+
+  private void stop() {
+    doubleBuffer.stop();
+  }
+
+  @Test(timeout = 300_000)
+  public void testDoubleBufferWithDummyResponse() throws Exception {
+    try {
+      setup();
+      String volumeName = UUID.randomUUID().toString();
+      int bucketCount = 100;
+      for (int i=0; i < bucketCount; i++) {
+        doubleBuffer.add(createDummyBucketResponse(volumeName,
+            UUID.randomUUID().toString()), trxId.incrementAndGet());
+      }
+      GenericTestUtils.waitFor(() ->
+              doubleBuffer.getFlushedTransactionCount() == bucketCount, 100,
+          120000);
+      Assert.assertTrue(omMetadataManager.countRowsInTable(
+          omMetadataManager.getBucketTable()) == (bucketCount));
+      Assert.assertTrue(doubleBuffer.getFlushIterations() > 0);
+    } finally {
+      stop();
+    }
+  }
+
+
+  @Test(timeout = 300_000)
+  public void testDoubleBuffer() throws Exception {
+    // This test checks whether count in tables are correct or not.
+    testDoubleBuffer(1, 10);
+    testDoubleBuffer(10, 100);
+    testDoubleBuffer(100, 100);
+    testDoubleBuffer(1000, 1000);
+  }
+
+
+
+  @Test
+  public void testDoubleBufferWithMixOfTransactions() throws Exception {
+    // This test checks count, data in table is correct or not.
+    try {
+      setup();
+
+      Queue< OMBucketCreateResponse > bucketQueue =
+          new ConcurrentLinkedQueue<>();
+      Queue< OMBucketDeleteResponse > deleteBucketQueue =
+          new ConcurrentLinkedQueue<>();
+
+      String volumeName = UUID.randomUUID().toString();
+      OMVolumeCreateResponse omVolumeCreateResponse = createVolume(volumeName);
+      doubleBuffer.add(omVolumeCreateResponse, trxId.incrementAndGet());
+
+
+      int bucketCount = 10;
+
+      doMixTransactions(volumeName, 10, deleteBucketQueue, bucketQueue);
+
+      // As for every 2 transactions of create bucket we add deleted bucket.
+      final int deleteCount = 5;
+
+      // We are doing +1 for volume transaction.
+      GenericTestUtils.waitFor(() ->
+          doubleBuffer.getFlushedTransactionCount() ==
+              (bucketCount + deleteCount + 1), 100, 120000);
+
+      Assert.assertTrue(omMetadataManager.countRowsInTable(
+          omMetadataManager.getVolumeTable()) == 1);
+
+      Assert.assertTrue(omMetadataManager.countRowsInTable(
+          omMetadataManager.getBucketTable()) == 5);
+
+      // Now after this in our DB we should have 5 buckets and one volume
+
+
+      checkVolume(volumeName, omVolumeCreateResponse);
+
+      checkCreateBuckets(bucketQueue);
+
+      checkDeletedBuckets(deleteBucketQueue);
+    } finally {
+      stop();
+    }
+  }
+
+  @Test
 
 Review comment:
   Done
 
----------------------------------------------------------------
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: 247694)
    Time Spent: 8.5h  (was: 8h 20m)

> Implement DoubleBuffer in OzoneManager
> --------------------------------------
>
>                 Key: HDDS-1512
>                 URL: https://issues.apache.org/jira/browse/HDDS-1512
>             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: 8.5h
>  Remaining Estimate: 0h
>
> This Jira is created to implement DoubleBuffer in OzoneManager to flush 
> transactions to OM DB.
>  
> h2. Flushing Transactions to RocksDB:
> We propose using an implementation similar to the HDFS EditsDoubleBuffer.  We 
> shall flush RocksDB transactions in batches, instead of current way of using 
> rocksdb.put() after every operation. At a given time only one batch will be 
> outstanding for flush while newer transactions are accumulated in memory to 
> be flushed later.
>  
> In DoubleBuffer it will have 2 buffers one is currentBuffer, and the other is 
> readyBuffer. We add entry to current buffer, and we check if another flush 
> call is outstanding. If not, we flush to disk Otherwise we add entries to 
> otherBuffer while sync is happening.
>  
> In this if sync is happening, we shall add new requests to other buffer and 
> when we can sync we use *RocksDB batch commit to sync to disk, instead of 
> rocksdb put.*
>  
> Note: If flush to disk is failed on any OM, we shall terminate the 
> OzoneManager, so that OM DB’s will not diverge. Flush failure should be 
> considered as catastrophic failure.
>  
> Scope of this Jira is to add DoubleBuffer implementation, integrating to 
> current OM will be done in further jira's.
>  



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