Search in sources :

Example 6 with HBaseTestingUtility

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

the class FlushTableAction method perform.

@Override
public void perform() throws Exception {
    HBaseTestingUtility util = context.getHBaseIntegrationTestingUtility();
    Admin admin = util.getAdmin();
    // Don't try the flush if we're stopping
    if (context.isStopping()) {
        return;
    }
    LOG.info("Performing action: Flush table " + tableName);
    try {
        admin.flush(tableName);
    } catch (Exception ex) {
        LOG.warn("Flush 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 7 with HBaseTestingUtility

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

the class MoveRandomRegionOfTableAction method perform.

@Override
public void perform() throws Exception {
    if (sleepTime > 0) {
        Thread.sleep(sleepTime);
    }
    HBaseTestingUtility util = context.getHBaseIntegrationTestingUtility();
    Admin admin = util.getAdmin();
    LOG.info("Performing action: Move 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 move");
        return;
    }
    HRegionInfo region = PolicyBasedChaosMonkey.selectRandomItem(regions.toArray(new HRegionInfo[regions.size()]));
    LOG.debug("Unassigning region " + region.getRegionNameAsString());
    admin.unassign(region.getRegionName(), false);
    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)

Example 8 with HBaseTestingUtility

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

the class SnapshotTableAction method perform.

@Override
public void perform() throws Exception {
    HBaseTestingUtility util = context.getHBaseIntegrationTestingUtility();
    String snapshotName = tableName + "-it-" + System.currentTimeMillis();
    Admin admin = util.getAdmin();
    // Don't try the snapshot if we're stopping
    if (context.isStopping()) {
        return;
    }
    LOG.info("Performing action: Snapshot table " + tableName);
    admin.snapshot(snapshotName, tableName);
    if (sleepTime > 0) {
        Thread.sleep(sleepTime);
    }
}
Also used : HBaseTestingUtility(org.apache.hadoop.hbase.HBaseTestingUtility) Admin(org.apache.hadoop.hbase.client.Admin)

Example 9 with HBaseTestingUtility

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

the class CompactMobAction method perform.

@Override
public void perform() throws Exception {
    HBaseTestingUtility util = context.getHBaseIntegrationTestingUtility();
    Admin admin = util.getAdmin();
    boolean major = RandomUtils.nextInt(100) < majorRatio;
    // Don't try the modify if we're stopping
    if (context.isStopping()) {
        return;
    }
    LOG.info("Performing action: Compact mob of table " + tableName + ", major=" + major);
    try {
        if (major) {
            admin.majorCompact(tableName, CompactType.MOB);
        } else {
            admin.compact(tableName, CompactType.MOB);
        }
    } catch (Exception ex) {
        LOG.warn("Mob 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 10 with HBaseTestingUtility

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

the class CompactRandomRegionOfTableAction 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 random region of table " + tableName + ", major=" + major);
    List<HRegionInfo> regions = admin.getTableRegions(tableName);
    if (regions == null || regions.isEmpty()) {
        LOG.info("Table " + tableName + " doesn't have regions to compact");
        return;
    }
    HRegionInfo region = PolicyBasedChaosMonkey.selectRandomItem(regions.toArray(new HRegionInfo[regions.size()]));
    try {
        if (major) {
            LOG.debug("Major compacting region " + region.getRegionNameAsString());
            admin.majorCompactRegion(region.getRegionName());
        } else {
            LOG.debug("Compacting region " + region.getRegionNameAsString());
            admin.compactRegion(region.getRegionName());
        }
    } catch (Exception ex) {
        LOG.warn("Compaction 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