Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,20 @@
import org.slf4j.LoggerFactory;

public class DecreaseMaxHFileSizeAction extends Action {
private static final Logger LOG = LoggerFactory.getLogger(DecreaseMaxHFileSizeAction.class);

private static final long minFileSize = 1024 * 1024 * 1024L;
private static final Logger LOG = LoggerFactory.getLogger(DecreaseMaxHFileSizeAction.class);

private final long sleepTime;
private final long minHFileSize;
private final float hfileSizeJitter;
private final TableName tableName;
private Admin admin;

public DecreaseMaxHFileSizeAction(long sleepTime, TableName tableName) {
public DecreaseMaxHFileSizeAction(long sleepTime, long minHFileSize, float hfileSizeJitter,
TableName tableName) {
this.sleepTime = sleepTime;
this.minHFileSize = minHFileSize;
this.hfileSizeJitter = hfileSizeJitter;
this.tableName = tableName;
}

Expand Down Expand Up @@ -72,7 +76,9 @@ public void perform() throws Exception {

// 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 - ThreadLocalRandom.current().nextInt(1024));
newValue = Math.max(minHFileSize, newValue);
newValue +=
newValue * ThreadLocalRandom.current().nextDouble(-hfileSizeJitter, hfileSizeJitter);

// Change the table descriptor.
TableDescriptor modifiedTable =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private Action instantiateAction(String actionString) throws Exception {
.toArray(String[]::new);
LOG.info("About to instantiate action class: {}; With constructor params: {}", className,
params);
Class<? extends Action> actionClass = (Class<? extends Action>) Class.forName(className);
Class<? extends Action> actionClass = Class.forName(className).asSubclass(Action.class);
Constructor<? extends Action>[] constructors =
(Constructor<? extends Action>[]) actionClass.getDeclaredConstructors();
for (Constructor<? extends Action> c : constructors) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,4 @@ public ChaosMonkey build() {
new PeriodicRandomActionPolicy(action1Period, actions1),
new PeriodicRandomActionPolicy(action2Period, actions2));
}

private void loadProperties() {
action1Period =
Long.parseLong(this.properties.getProperty(MonkeyConstants.PERIODIC_ACTION1_PERIOD,
MonkeyConstants.DEFAULT_PERIODIC_ACTION1_PERIOD + ""));
action2Period =
Long.parseLong(this.properties.getProperty(MonkeyConstants.PERIODIC_ACTION2_PERIOD,
MonkeyConstants.DEFAULT_PERIODIC_ACTION2_PERIOD + ""));
chanceToAct = Float.parseFloat(this.properties.getProperty(MonkeyConstants.DATA_ISSUE_CHANCE,
MonkeyConstants.DEFAULT_DATA_ISSUE_CHANCE + ""));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,6 @@
*/
public class DistributedIssuesMonkeyFactory extends MonkeyFactory {

private long action1Period;
private long action2Period;

private long cpuLoadDuration;
private long cpuLoadProcesses;
private long networkIssueTimeout;
private long networkIssueDuration;
private float networkIssueRation;
private long networkIssueDelay;
private String networkIssueInterface;
private long fillDiskTimeout;
private String fillDiskPath;
private long fillDiskFileSize;
private long fillDiskIssueduration;

@Override
public ChaosMonkey build() {
loadProperties();
Expand All @@ -77,43 +62,4 @@ public ChaosMonkey build() {
new PeriodicRandomActionPolicy(action1Period, actions1),
new PeriodicRandomActionPolicy(action2Period, actions2));
}

private void loadProperties() {
action1Period =
Long.parseLong(this.properties.getProperty(MonkeyConstants.PERIODIC_ACTION1_PERIOD,
MonkeyConstants.DEFAULT_PERIODIC_ACTION1_PERIOD + ""));
action2Period =
Long.parseLong(this.properties.getProperty(MonkeyConstants.PERIODIC_ACTION2_PERIOD,
MonkeyConstants.DEFAULT_PERIODIC_ACTION2_PERIOD + ""));
cpuLoadDuration = Long.parseLong(this.properties.getProperty(MonkeyConstants.CPU_LOAD_DURATION,
MonkeyConstants.DEFAULT_CPU_LOAD_DURATION + ""));
cpuLoadProcesses =
Long.parseLong(this.properties.getProperty(MonkeyConstants.CPU_LOAD_PROCESSES,
MonkeyConstants.DEFAULT_CPU_LOAD_PROCESSES + ""));
networkIssueTimeout =
Long.parseLong(this.properties.getProperty(MonkeyConstants.NETWORK_ISSUE_COMMAND_TIMEOUT,
MonkeyConstants.DEFAULT_NETWORK_ISSUE_COMMAND_TIMEOUT + ""));
networkIssueDuration =
Long.parseLong(this.properties.getProperty(MonkeyConstants.NETWORK_ISSUE_DURATION,
MonkeyConstants.DEFAULT_NETWORK_ISSUE_DURATION + ""));
networkIssueRation =
Float.parseFloat(this.properties.getProperty(MonkeyConstants.NETWORK_ISSUE_RATIO,
MonkeyConstants.DEFAULT_NETWORK_ISSUE_RATIO + ""));
networkIssueDelay =
Long.parseLong(this.properties.getProperty(MonkeyConstants.NETWORK_ISSUE_DELAY,
MonkeyConstants.DEFAULT_NETWORK_ISSUE_DELAY + ""));
networkIssueInterface = this.properties.getProperty(MonkeyConstants.NETWORK_ISSUE_INTERFACE,
MonkeyConstants.DEFAULT_NETWORK_ISSUE_INTERFACE + "");
fillDiskTimeout =
Long.parseLong(this.properties.getProperty(MonkeyConstants.FILL_DISK_COMMAND_TIMEOUT,
MonkeyConstants.DEFAULT_FILL_DISK_COMMAND_TIMEOUT + ""));
fillDiskPath = this.properties.getProperty(MonkeyConstants.FILL_DISK_PATH,
MonkeyConstants.DEFAULT_FILL_DISK_PATH + "");
fillDiskFileSize =
Long.parseLong(this.properties.getProperty(MonkeyConstants.FILL_DISK_FILE_SIZE,
MonkeyConstants.DEFAULT_FILL_DISK_FILE_SIZE + ""));
fillDiskIssueduration =
Long.parseLong(this.properties.getProperty(MonkeyConstants.FILL_DISK_ISSUE_DURATION,
MonkeyConstants.DEFAULT_FILL_DISK_ISSUE_DURATION + ""));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@
*/
public class MasterKillingMonkeyFactory extends MonkeyFactory {

private long action1Period;
private long action2Period;

private long restartActiveMasterSleepTime;

@Override
public ChaosMonkey build() {
loadProperties();
Expand All @@ -50,18 +45,4 @@ public ChaosMonkey build() {
new PeriodicRandomActionPolicy(action1Period, actions1),
new PeriodicRandomActionPolicy(action2Period, actions2));
}

private void loadProperties() {

action1Period =
Long.parseLong(this.properties.getProperty(MonkeyConstants.PERIODIC_ACTION1_PERIOD,
MonkeyConstants.DEFAULT_PERIODIC_ACTION1_PERIOD + ""));
action2Period =
Long.parseLong(this.properties.getProperty(MonkeyConstants.PERIODIC_ACTION2_PERIOD,
MonkeyConstants.DEFAULT_PERIODIC_ACTION2_PERIOD + ""));
restartActiveMasterSleepTime =
Long.parseLong(this.properties.getProperty(MonkeyConstants.RESTART_ACTIVE_MASTER_SLEEP_TIME,
MonkeyConstants.DEFAULT_RESTART_ACTIVE_MASTER_SLEEP_TIME + ""));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,33 +46,29 @@
public class MobNoKillMonkeyFactory extends MonkeyFactory {
@Override
public ChaosMonkey build() {
Action[] actions1 = new Action[] {
new CompactMobAction(tableName, MonkeyConstants.DEFAULT_PERIODIC_ACTION1_PERIOD),
new CompactTableAction(tableName, MonkeyConstants.DEFAULT_PERIODIC_ACTION1_PERIOD),
new CompactRandomRegionOfTableAction(tableName,
MonkeyConstants.DEFAULT_COMPACT_RANDOM_REGION_RATIO),
loadProperties();
Action[] actions1 = new Action[] { new CompactMobAction(tableName, action1Period),
new CompactTableAction(tableName, action1Period),
new CompactRandomRegionOfTableAction(tableName, compactRandomRegionRatio),
new FlushTableAction(tableName), new FlushRandomRegionOfTableAction(tableName),
new MoveRandomRegionOfTableAction(tableName) };

Action[] actions2 = new Action[] { new SplitRandomRegionOfTableAction(tableName),
new MergeRandomAdjacentRegionsOfTableAction(tableName),
new SnapshotTableAction(tableName, MonkeyConstants.DEFAULT_SNAPSHOT_TABLE_TTL),
new AddColumnAction(tableName), new RemoveColumnAction(tableName, columnFamilies),
new ChangeEncodingAction(tableName), new ChangeCompressionAction(tableName),
new ChangeBloomFilterAction(tableName), new ChangeVersionsAction(tableName) };
new SnapshotTableAction(tableName, snapshotTableTtl), new AddColumnAction(tableName),
new RemoveColumnAction(tableName, columnFamilies), new ChangeEncodingAction(tableName),
new ChangeCompressionAction(tableName), new ChangeBloomFilterAction(tableName),
new ChangeVersionsAction(tableName) };

Action[] actions3 = new Action[] {
new MoveRegionsOfTableAction(MonkeyConstants.DEFAULT_MOVE_REGIONS_SLEEP_TIME,
MonkeyConstants.DEFAULT_MOVE_REGIONS_MAX_TIME, tableName),
new MoveRandomRegionOfTableAction(MonkeyConstants.DEFAULT_RESTART_ACTIVE_MASTER_SLEEP_TIME,
tableName), };
new MoveRegionsOfTableAction(moveRegionsSleepTime, moveRegionsMaxTime, tableName),
new MoveRandomRegionOfTableAction(restartActiveMasterSleepTime, tableName) };

Action[] actions4 = new Action[] { new DumpClusterStatusAction() };

return new PolicyBasedChaosMonkey(properties, util,
new TwoConcurrentActionPolicy(MonkeyConstants.DEFAULT_PERIODIC_ACTION1_PERIOD, actions1,
actions2),
new PeriodicRandomActionPolicy(MonkeyConstants.DEFAULT_PERIODIC_ACTION2_PERIOD, actions3),
new PeriodicRandomActionPolicy(MonkeyConstants.DEFAULT_PERIODIC_ACTION4_PERIOD, actions4));
new TwoConcurrentActionPolicy(action1Period, actions1, actions2),
new PeriodicRandomActionPolicy(action2Period, actions3),
new PeriodicRandomActionPolicy(action4Period, actions4));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,8 @@
*/
public class MobSlowDeterministicMonkeyFactory extends MonkeyFactory {

private long action1Period;
private long action2Period;
private long action3Period;
private long action4Period;
private long moveRegionsMaxTime;
private long moveRegionsSleepTime;
private long moveRandomRegionSleepTime;
private long restartRandomRSSleepTime;
private long batchRestartRSSleepTime;
private float batchRestartRSRatio;
private long restartActiveMasterSleepTime;
private long rollingBatchRestartRSSleepTime;
private float rollingBatchRestartRSRatio;
private long restartRsHoldingMetaSleepTime;
private float compactTableRatio;
private float compactRandomRegionRatio;
private long snapshotTableTtl;

@Override
public ChaosMonkey build() {

loadProperties();
// Actions such as compact/flush a table/region,
// move one region around. They are not so destructive,
Expand Down Expand Up @@ -112,56 +93,4 @@ public ChaosMonkey build() {
new PeriodicRandomActionPolicy(action3Period, actions3)),
new PeriodicRandomActionPolicy(action4Period, actions4));
}

private void loadProperties() {

action1Period =
Long.parseLong(this.properties.getProperty(MonkeyConstants.PERIODIC_ACTION1_PERIOD,
MonkeyConstants.DEFAULT_PERIODIC_ACTION1_PERIOD + ""));
action2Period =
Long.parseLong(this.properties.getProperty(MonkeyConstants.PERIODIC_ACTION2_PERIOD,
MonkeyConstants.DEFAULT_PERIODIC_ACTION2_PERIOD + ""));
action3Period =
Long.parseLong(this.properties.getProperty(MonkeyConstants.COMPOSITE_ACTION3_PERIOD,
MonkeyConstants.DEFAULT_COMPOSITE_ACTION3_PERIOD + ""));
action4Period =
Long.parseLong(this.properties.getProperty(MonkeyConstants.PERIODIC_ACTION4_PERIOD,
MonkeyConstants.DEFAULT_PERIODIC_ACTION4_PERIOD + ""));
moveRegionsMaxTime =
Long.parseLong(this.properties.getProperty(MonkeyConstants.MOVE_REGIONS_MAX_TIME,
MonkeyConstants.DEFAULT_MOVE_REGIONS_MAX_TIME + ""));
moveRegionsSleepTime =
Long.parseLong(this.properties.getProperty(MonkeyConstants.MOVE_REGIONS_SLEEP_TIME,
MonkeyConstants.DEFAULT_MOVE_REGIONS_SLEEP_TIME + ""));
moveRandomRegionSleepTime =
Long.parseLong(this.properties.getProperty(MonkeyConstants.MOVE_RANDOM_REGION_SLEEP_TIME,
MonkeyConstants.DEFAULT_MOVE_RANDOM_REGION_SLEEP_TIME + ""));
restartRandomRSSleepTime =
Long.parseLong(this.properties.getProperty(MonkeyConstants.RESTART_RANDOM_RS_SLEEP_TIME,
MonkeyConstants.DEFAULT_RESTART_RANDOM_RS_SLEEP_TIME + ""));
batchRestartRSSleepTime =
Long.parseLong(this.properties.getProperty(MonkeyConstants.BATCH_RESTART_RS_SLEEP_TIME,
MonkeyConstants.DEFAULT_BATCH_RESTART_RS_SLEEP_TIME + ""));
restartActiveMasterSleepTime =
Long.parseLong(this.properties.getProperty(MonkeyConstants.RESTART_ACTIVE_MASTER_SLEEP_TIME,
MonkeyConstants.DEFAULT_RESTART_ACTIVE_MASTER_SLEEP_TIME + ""));
rollingBatchRestartRSSleepTime = Long
.parseLong(this.properties.getProperty(MonkeyConstants.ROLLING_BATCH_RESTART_RS_SLEEP_TIME,
MonkeyConstants.DEFAULT_ROLLING_BATCH_RESTART_RS_SLEEP_TIME + ""));
rollingBatchRestartRSRatio =
Float.parseFloat(this.properties.getProperty(MonkeyConstants.ROLLING_BATCH_RESTART_RS_RATIO,
MonkeyConstants.DEFAULT_ROLLING_BATCH_RESTART_RS_RATIO + ""));
restartRsHoldingMetaSleepTime =
Long.parseLong(this.properties.getProperty(MonkeyConstants.RESTART_RS_HOLDING_META_SLEEP_TIME,
MonkeyConstants.DEFAULT_RESTART_RS_HOLDING_META_SLEEP_TIME + ""));
compactTableRatio =
Float.parseFloat(this.properties.getProperty(MonkeyConstants.COMPACT_TABLE_ACTION_RATIO,
MonkeyConstants.DEFAULT_COMPACT_TABLE_ACTION_RATIO + ""));
compactRandomRegionRatio =
Float.parseFloat(this.properties.getProperty(MonkeyConstants.COMPACT_RANDOM_REGION_RATIO,
MonkeyConstants.DEFAULT_COMPACT_RANDOM_REGION_RATIO + ""));
snapshotTableTtl =
Long.parseLong(this.properties.getProperty(MonkeyConstants.SNAPSHOT_TABLE_TTL,
MonkeyConstants.DEFAULT_SNAPSHOT_TABLE_TTL + ""));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public interface MonkeyConstants {
String UNBALANCE_WAIT_AFTER_BALANCE_MS = "unbalance.action.wait.after.period";
String UNBALANCE_KILL_META_RS = "unbalance.action.kill.meta.rs";
String DECREASE_HFILE_SIZE_SLEEP_TIME = "decrease.hfile.size.sleep.time";
String DECREASE_HFILE_SIZE_MIN_HFILE_SIZE = "decrease.hfile.size.min.hfile.size";
String DECREASE_HFILE_SIZE_HFILE_SIZE_JITTER = "decrease.hfile.size.hfile.size.jitter";
String RESTART_RANDOM_RS_EXCEPTION_SLEEP_TIME = "restart.random.rs.exception.sleep.time";
String RESTART_ACTIVE_NAMENODE_SLEEP_TIME = "restart.active.namenode.sleep.time";
String RESTART_RANDOM_DATANODE_SLEEP_TIME = "restart.random.datanode.sleep.time";
Expand Down Expand Up @@ -99,6 +101,8 @@ public interface MonkeyConstants {
long DEFAULT_UNBALANCE_WAIT_AFTER_BALANCE_MS = 5 * 1000;
boolean DEFAULT_UNBALANCE_KILL_META_RS = true;
long DEFAULT_DECREASE_HFILE_SIZE_SLEEP_TIME = 30 * 1000;
long DEFAULT_DECREASE_HFILE_SIZE_MIN_HFILE_SIZE = 1024L * 1024 * 1024;
float DEFAULT_DECREASE_HFILE_SIZE_HFILE_SIZE_JITTER = 0.001f;

long DEFAULT_RESTART_RANDOM_RS_EXCEPTION_SLEEP_TIME = TimeUnit.MILLISECONDS.toMillis(60000);
long DEFAULT_RESTART_ACTIVE_NAMENODE_SLEEP_TIME = TimeUnit.MILLISECONDS.toMillis(60000);
Expand Down
Loading