Search in sources :

Example 1 with HBaseTestingUtility

use of org.apache.hadoop.hbase.HBaseTestingUtility in project hadoop by apache.

the class TestHBaseStorageFlowActivity method setupBeforeClass.

@BeforeClass
public static void setupBeforeClass() throws Exception {
    util = new HBaseTestingUtility();
    Configuration conf = util.getConfiguration();
    conf.setInt("hfile.format.version", 3);
    util.startMiniCluster();
    createSchema();
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) HBaseTestingUtility(org.apache.hadoop.hbase.HBaseTestingUtility) BeforeClass(org.junit.BeforeClass)

Example 2 with HBaseTestingUtility

use of org.apache.hadoop.hbase.HBaseTestingUtility in project hadoop by apache.

the class TestHBaseTimelineStorageApps method setupBeforeClass.

@BeforeClass
public static void setupBeforeClass() throws Exception {
    util = new HBaseTestingUtility();
    util.startMiniCluster();
    createSchema();
    DataGeneratorForTest.loadApps(util);
}
Also used : HBaseTestingUtility(org.apache.hadoop.hbase.HBaseTestingUtility) BeforeClass(org.junit.BeforeClass)

Example 3 with HBaseTestingUtility

use of org.apache.hadoop.hbase.HBaseTestingUtility in project hbase by apache.

the class CompactTableAction method perform.

@Override
public void perform() throws Exception {
    HBaseTestingUtility util = context.getHBaseIntegrationTestingUtility();
    Admin admin = util.getAdmin();
    boolean major = RandomUtils.nextInt(100) < majorRatio;
    LOG.info("Performing action: Compact table " + tableName + ", major=" + major);
    try {
        if (major) {
            admin.majorCompact(tableName);
        } else {
            admin.compact(tableName);
        }
    } catch (Exception ex) {
        LOG.warn("Compaction failed, might be caused by other chaos: " + ex.getMessage());
    }
    if (sleepTime > 0) {
        Thread.sleep(sleepTime);
    }
}
Also used : HBaseTestingUtility(org.apache.hadoop.hbase.HBaseTestingUtility) Admin(org.apache.hadoop.hbase.client.Admin)

Example 4 with HBaseTestingUtility

use of org.apache.hadoop.hbase.HBaseTestingUtility in project hbase by apache.

the class DecreaseMaxHFileSizeAction method perform.

@Override
public void perform() throws Exception {
    HBaseTestingUtility util = context.getHBaseIntegrationTestingUtility();
    Admin admin = util.getAdmin();
    HTableDescriptor htd = admin.getTableDescriptor(tableName);
    // Try and get the current value.
    long currentValue = htd.getMaxFileSize();
    // That's ok. We're trying to cause chaos.
    if (currentValue <= 0) {
        currentValue = context.getHBaseCluster().getConf().getLong(HConstants.HREGION_MAX_FILESIZE, HConstants.DEFAULT_MAX_FILE_SIZE);
    }
    // Decrease by 10% at a time.
    long newValue = (long) (currentValue * 0.9);
    // We don't want to go too far below 1gb.
    // So go to about 1gb +/- 512 on each side.
    newValue = Math.max(minFileSize, newValue) - (512 - random.nextInt(1024));
    // Change the table descriptor.
    htd.setMaxFileSize(newValue);
    // Don't try the modify if we're stopping
    if (context.isStopping()) {
        return;
    }
    // modify the table.
    admin.modifyTable(tableName, htd);
    // Sleep some time.
    if (sleepTime > 0) {
        Thread.sleep(sleepTime);
    }
}
Also used : HBaseTestingUtility(org.apache.hadoop.hbase.HBaseTestingUtility) Admin(org.apache.hadoop.hbase.client.Admin) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor)

Example 5 with HBaseTestingUtility

use of org.apache.hadoop.hbase.HBaseTestingUtility in project hbase by apache.

the class FlushRandomRegionOfTableAction method perform.

@Override
public void perform() throws Exception {
    HBaseTestingUtility util = context.getHBaseIntegrationTestingUtility();
    Admin admin = util.getAdmin();
    LOG.info("Performing action: Flush random region of table " + tableName);
    List<HRegionInfo> regions = admin.getTableRegions(tableName);
    if (regions == null || regions.isEmpty()) {
        LOG.info("Table " + tableName + " doesn't have regions to flush");
        return;
    }
    HRegionInfo region = PolicyBasedChaosMonkey.selectRandomItem(regions.toArray(new HRegionInfo[regions.size()]));
    LOG.debug("Flushing region " + region.getRegionNameAsString());
    try {
        admin.flushRegion(region.getRegionName());
    } catch (Exception ex) {
        LOG.warn("Flush failed, might be caused by other chaos: " + ex.getMessage());
    }
    if (sleepTime > 0) {
        Thread.sleep(sleepTime);
    }
}
Also used : HRegionInfo(org.apache.hadoop.hbase.HRegionInfo) HBaseTestingUtility(org.apache.hadoop.hbase.HBaseTestingUtility) Admin(org.apache.hadoop.hbase.client.Admin)

Aggregations

HBaseTestingUtility (org.apache.hadoop.hbase.HBaseTestingUtility)136 Configuration (org.apache.hadoop.conf.Configuration)50 BeforeClass (org.junit.BeforeClass)49 Test (org.junit.Test)42 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)35 Path (org.apache.hadoop.fs.Path)29 Admin (org.apache.hadoop.hbase.client.Admin)24 FileSystem (org.apache.hadoop.fs.FileSystem)22 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)20 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)18 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)16 Before (org.junit.Before)14 MiniHBaseCluster (org.apache.hadoop.hbase.MiniHBaseCluster)11 ZooKeeperWatcher (org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher)11 MiniZooKeeperCluster (org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster)10 Table (org.apache.hadoop.hbase.client.Table)8 HFileSystem (org.apache.hadoop.hbase.fs.HFileSystem)8 MiniDFSCluster (org.apache.hadoop.hdfs.MiniDFSCluster)8 FileStatus (org.apache.hadoop.fs.FileStatus)7 Result (org.apache.hadoop.hbase.client.Result)7