Search in sources :

Example 1 with PressureAwareCompactionThroughputController

use of org.apache.hadoop.hbase.regionserver.throttle.PressureAwareCompactionThroughputController in project hbase by apache.

the class TestCompactionWithThroughputController method testThroughputTuning.

/**
   * Test the tuning task of {@link PressureAwareCompactionThroughputController}
   */
@Test
public void testThroughputTuning() throws Exception {
    Configuration conf = TEST_UTIL.getConfiguration();
    conf.set(StoreEngine.STORE_ENGINE_CLASS_KEY, DefaultStoreEngine.class.getName());
    conf.setLong(PressureAwareCompactionThroughputController.HBASE_HSTORE_COMPACTION_MAX_THROUGHPUT_HIGHER_BOUND, 20L * 1024 * 1024);
    conf.setLong(PressureAwareCompactionThroughputController.HBASE_HSTORE_COMPACTION_MAX_THROUGHPUT_LOWER_BOUND, 10L * 1024 * 1024);
    conf.setInt(CompactionConfiguration.HBASE_HSTORE_COMPACTION_MIN_KEY, 4);
    conf.setInt(HStore.BLOCKING_STOREFILES_KEY, 6);
    conf.set(CompactionThroughputControllerFactory.HBASE_THROUGHPUT_CONTROLLER_KEY, PressureAwareCompactionThroughputController.class.getName());
    conf.setInt(PressureAwareCompactionThroughputController.HBASE_HSTORE_COMPACTION_THROUGHPUT_TUNE_PERIOD, 1000);
    TEST_UTIL.startMiniCluster(1);
    Connection conn = ConnectionFactory.createConnection(conf);
    try {
        HTableDescriptor htd = new HTableDescriptor(tableName);
        htd.addFamily(new HColumnDescriptor(family));
        htd.setCompactionEnabled(false);
        TEST_UTIL.getAdmin().createTable(htd);
        TEST_UTIL.waitTableAvailable(tableName);
        HRegionServer regionServer = TEST_UTIL.getRSForFirstRegionInTable(tableName);
        PressureAwareCompactionThroughputController throughputController = (PressureAwareCompactionThroughputController) regionServer.compactSplitThread.getCompactionThroughputController();
        assertEquals(10L * 1024 * 1024, throughputController.getMaxThroughput(), EPSILON);
        Table table = conn.getTable(tableName);
        for (int i = 0; i < 5; i++) {
            byte[] value = new byte[0];
            table.put(new Put(Bytes.toBytes(i)).addColumn(family, qualifier, value));
            TEST_UTIL.flush(tableName);
        }
        Thread.sleep(2000);
        assertEquals(15L * 1024 * 1024, throughputController.getMaxThroughput(), EPSILON);
        byte[] value1 = new byte[0];
        table.put(new Put(Bytes.toBytes(5)).addColumn(family, qualifier, value1));
        TEST_UTIL.flush(tableName);
        Thread.sleep(2000);
        assertEquals(20L * 1024 * 1024, throughputController.getMaxThroughput(), EPSILON);
        byte[] value = new byte[0];
        table.put(new Put(Bytes.toBytes(6)).addColumn(family, qualifier, value));
        TEST_UTIL.flush(tableName);
        Thread.sleep(2000);
        assertEquals(Double.MAX_VALUE, throughputController.getMaxThroughput(), EPSILON);
        conf.set(CompactionThroughputControllerFactory.HBASE_THROUGHPUT_CONTROLLER_KEY, NoLimitThroughputController.class.getName());
        regionServer.compactSplitThread.onConfigurationChange(conf);
        assertTrue(throughputController.isStopped());
        assertTrue(regionServer.compactSplitThread.getCompactionThroughputController() instanceof NoLimitThroughputController);
    } finally {
        conn.close();
        TEST_UTIL.shutdownMiniCluster();
    }
}
Also used : NoLimitThroughputController(org.apache.hadoop.hbase.regionserver.throttle.NoLimitThroughputController) Table(org.apache.hadoop.hbase.client.Table) Configuration(org.apache.hadoop.conf.Configuration) CompactionConfiguration(org.apache.hadoop.hbase.regionserver.compactions.CompactionConfiguration) HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) DefaultStoreEngine(org.apache.hadoop.hbase.regionserver.DefaultStoreEngine) Connection(org.apache.hadoop.hbase.client.Connection) PressureAwareCompactionThroughputController(org.apache.hadoop.hbase.regionserver.throttle.PressureAwareCompactionThroughputController) Put(org.apache.hadoop.hbase.client.Put) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer) Test(org.junit.Test)

Aggregations

Configuration (org.apache.hadoop.conf.Configuration)1 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)1 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)1 Connection (org.apache.hadoop.hbase.client.Connection)1 Put (org.apache.hadoop.hbase.client.Put)1 Table (org.apache.hadoop.hbase.client.Table)1 DefaultStoreEngine (org.apache.hadoop.hbase.regionserver.DefaultStoreEngine)1 HRegionServer (org.apache.hadoop.hbase.regionserver.HRegionServer)1 CompactionConfiguration (org.apache.hadoop.hbase.regionserver.compactions.CompactionConfiguration)1 NoLimitThroughputController (org.apache.hadoop.hbase.regionserver.throttle.NoLimitThroughputController)1 PressureAwareCompactionThroughputController (org.apache.hadoop.hbase.regionserver.throttle.PressureAwareCompactionThroughputController)1 Test (org.junit.Test)1