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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations