busbey commented on a change in pull request #921: HBASE-22749: Distributed MOB 
compactions
URL: https://github.com/apache/hbase/pull/921#discussion_r364963515
 
 

 ##########
 File path: 
hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobCompactionBase.java
 ##########
 @@ -0,0 +1,242 @@
+/**
+ *
+ * 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
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.hbase.mob;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Random;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.HColumnDescriptor;
+import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Admin;
+import org.apache.hadoop.hbase.client.CompactionState;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.ResultScanner;
+import org.apache.hadoop.hbase.client.Table;
+import org.apache.hadoop.hbase.master.MobFileCleanerChore;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.RegionSplitter;
+import org.junit.After;
+import org.junit.Before;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+  * Mob file compaction base test.
+  * 1. Enables batch mode for regular MOB compaction,
+  *    Sets batch size to 7 regions. (Optional)
+  * 2. Disables periodic MOB compactions, sets minimum age to archive to 10 sec
+  * 3. Creates MOB table with 20 regions
+  * 4. Loads MOB data (randomized keys, 1000 rows), flushes data.
+  * 5. Repeats 4. two more times
+  * 6. Verifies that we have 20 *3 = 60 mob files (equals to number of regions 
x 3)
+  * 7. Runs major MOB compaction.
+  * 8. Verifies that number of MOB files in a mob directory is 20 x4 = 80
+  * 9. Waits for a period of time larger than minimum age to archive
+  * 10. Runs Mob cleaner chore
+  * 11 Verifies that number of MOB files in a mob directory is 20.
+  * 12 Runs scanner and checks all 3 * 1000 rows.
+ */
+@SuppressWarnings("deprecation")
+public abstract class TestMobCompactionBase {
+  private static final Logger LOG =
+      LoggerFactory.getLogger(TestMobCompactionBase.class);
+
+  protected HBaseTestingUtility HTU;
+
+  protected final static String famStr = "f1";
+  protected final static byte[] fam = Bytes.toBytes(famStr);
+  protected final static byte[] qualifier = Bytes.toBytes("q1");
+  protected final static long mobLen = 10;
+  protected final static byte[] mobVal = Bytes
+      
.toBytes("01234567890123456789012345678901234567890123456789012345678901234567890123456789");
+
+  protected Configuration conf;
+  protected HTableDescriptor hdt;
+  private HColumnDescriptor hcd;
+  protected Admin admin;
+  protected Table table = null;
+  protected long minAgeToArchive = 10000;
+  protected int numRegions = 20;
+  protected int rows = 1000;
+
+  protected MobFileCleanerChore cleanerChore;
+
+  public TestMobCompactionBase() {
+  }
+
+
+  @Before
+  public void setUp() throws Exception {
+    HTU = new HBaseTestingUtility();
+    hdt = HTU.createTableDescriptor(getClass().getName());
+    conf = HTU.getConfiguration();
+
+    initConf();
+
+    HTU.startMiniCluster();
+    admin = HTU.getAdmin();
+    cleanerChore = new MobFileCleanerChore();
+    hcd = new HColumnDescriptor(fam);
+    hcd.setMobEnabled(true);
+    hcd.setMobThreshold(mobLen);
+    hcd.setMaxVersions(1);
+    hdt.addFamily(hcd);
+    byte[][] splitKeys = generateSplitKeys();
+    table = HTU.createTable(hdt, splitKeys);
+
+  }
+
+  private byte[][] generateSplitKeys() {
 
 Review comment:
   nit: fold this directly into setup 

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


With regards,
Apache Git Services

Reply via email to