001/**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.regionserver;
019
020import java.io.IOException;
021import org.apache.hadoop.hbase.HBaseClassTestRule;
022import org.apache.hadoop.hbase.HBaseTestingUtility;
023import org.apache.hadoop.hbase.TableName;
024import org.apache.hadoop.hbase.client.Durability;
025import org.apache.hadoop.hbase.testclassification.LargeTests;
026import org.apache.hadoop.hbase.testclassification.VerySlowRegionServerTests;
027import org.apache.hadoop.hbase.wal.WAL;
028import org.junit.ClassRule;
029import org.junit.experimental.categories.Category;
030import org.slf4j.Logger;
031import org.slf4j.LoggerFactory;
032
033/**
034 * A test similar to TestHRegion, but with in-memory flush families.
035 * Also checks wal truncation after in-memory compaction.
036 */
037@Category({VerySlowRegionServerTests.class, LargeTests.class})
038@SuppressWarnings("deprecation")
039public class TestHRegionWithInMemoryFlush extends TestHRegion {
040
041  @ClassRule
042  public static final HBaseClassTestRule CLASS_RULE =
043      HBaseClassTestRule.forClass(TestHRegionWithInMemoryFlush.class);
044
045  // Do not spin up clusters in here. If you need to spin up a cluster, do it
046  // over in TestHRegionOnCluster.
047  private static final Logger LOG = LoggerFactory.getLogger(TestHRegionWithInMemoryFlush.class);
048
049  /**
050   * @return A region on which you must call
051   *         {@link HBaseTestingUtility#closeRegionAndWAL(HRegion)} when done.
052   */
053  @Override
054  public HRegion initHRegion(TableName tableName, byte[] startKey, byte[] stopKey,
055      boolean isReadOnly, Durability durability, WAL wal, byte[]... families) throws IOException {
056    boolean[] inMemory = new boolean[families.length];
057    for(int i = 0; i < inMemory.length; i++) {
058      inMemory[i] = true;
059    }
060    return TEST_UTIL.createLocalHRegionWithInMemoryFlags(tableName, startKey, stopKey,
061        isReadOnly, durability, wal, inMemory, families);
062  }
063}
064