HBASE-10175 2-thread ChaosMonkey steps on its own toes

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1553634 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
sershe 2013-12-27 06:53:54 +00:00
parent 9459b605b0
commit 0914704b66
7 changed files with 40 additions and 16 deletions

View File

@ -66,6 +66,7 @@ public class CompactRandomRegionOfTableAction extends Action {
HRegionInfo region = PolicyBasedChaosMonkey.selectRandomItem(
regions.toArray(new HRegionInfo[regions.size()]));
try {
if (major) {
LOG.debug("Major compacting region " + region.getRegionNameAsString());
admin.majorCompact(region.getRegionName());
@ -73,6 +74,9 @@ public class CompactRandomRegionOfTableAction extends Action {
LOG.debug("Compacting region " + region.getRegionNameAsString());
admin.compact(region.getRegionName());
}
} catch (Exception ex) {
LOG.warn("Compaction failed, might be caused by other chaos: " + ex.getMessage());
}
if (sleepTime > 0) {
Thread.sleep(sleepTime);
}

View File

@ -51,11 +51,15 @@ public class CompactTableAction extends Action {
boolean major = RandomUtils.nextInt(100) < majorRatio;
LOG.info("Performing action: Compact table " + tableName + ", major=" + major);
try {
if (major) {
admin.majorCompact(tableNameBytes);
} else {
admin.compact(tableNameBytes);
}
} catch (Exception ex) {
LOG.warn("Compaction failed, might be caused by other chaos: " + ex.getMessage());
}
if (sleepTime > 0) {
Thread.sleep(sleepTime);
}

View File

@ -59,7 +59,11 @@ public class FlushRandomRegionOfTableAction extends Action {
HRegionInfo region = PolicyBasedChaosMonkey.selectRandomItem(
regions.toArray(new HRegionInfo[regions.size()]));
LOG.debug("Flushing region " + region.getRegionNameAsString());
try {
admin.flush(region.getRegionName());
} catch (Exception ex) {
LOG.warn("Flush failed, might be caused by other chaos: " + ex.getMessage());
}
if (sleepTime > 0) {
Thread.sleep(sleepTime);
}

View File

@ -46,7 +46,11 @@ public class FlushTableAction extends Action {
HBaseAdmin admin = util.getHBaseAdmin();
LOG.info("Performing action: Flush table " + tableName);
try {
admin.flush(tableNameBytes);
} catch (Exception ex) {
LOG.warn("Flush failed, might be caused by other chaos: " + ex.getMessage());
}
if (sleepTime > 0) {
Thread.sleep(sleepTime);
}

View File

@ -60,7 +60,11 @@ public class MergeRandomAdjacentRegionsOfTableAction extends Action {
HRegionInfo a = regions.get(i++);
HRegionInfo b = regions.get(i);
LOG.debug("Merging " + a.getRegionNameAsString() + " and " + b.getRegionNameAsString());
try {
admin.mergeRegions(a.getEncodedNameAsBytes(), b.getEncodedNameAsBytes(), false);
} catch (Exception ex) {
LOG.warn("Merge failed, might be caused by other chaos: " + ex.getMessage());
}
if (sleepTime > 0) {
Thread.sleep(sleepTime);
}

View File

@ -74,8 +74,8 @@ public class MoveRegionsOfTableAction extends Action {
servers[RandomUtils.nextInt(servers.length)].getServerName();
LOG.debug("Moving " + regionInfo.getRegionNameAsString() + " to " + destServerName);
admin.move(regionInfo.getEncodedNameAsBytes(), Bytes.toBytes(destServerName));
} catch (Exception e) {
LOG.debug("Error moving region", e);
} catch (Exception ex) {
LOG.warn("Move failed, might be caused by other chaos: " + ex.getMessage());
}
if (sleepTime > 0) {
Thread.sleep(sleepTime);

View File

@ -59,7 +59,11 @@ public class SplitRandomRegionOfTableAction extends Action {
HRegionInfo region = PolicyBasedChaosMonkey.selectRandomItem(
regions.toArray(new HRegionInfo[regions.size()]));
LOG.debug("Splitting region " + region.getRegionNameAsString());
try {
admin.split(region.getRegionName());
} catch (Exception ex) {
LOG.warn("Split failed, might be caused by other chaos: " + ex.getMessage());
}
if (sleepTime > 0) {
Thread.sleep(sleepTime);
}