1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase.chaos.factories;
20
21 import org.apache.hadoop.hbase.chaos.actions.Action;
22 import org.apache.hadoop.hbase.chaos.actions.DumpClusterStatusAction;
23 import org.apache.hadoop.hbase.chaos.actions.ForceBalancerAction;
24 import org.apache.hadoop.hbase.chaos.actions.RestartActiveMasterAction;
25 import org.apache.hadoop.hbase.chaos.actions.RestartRandomRsExceptMetaAction;
26 import org.apache.hadoop.hbase.chaos.actions.RollingBatchRestartRsExceptMetaAction;
27 import org.apache.hadoop.hbase.chaos.actions.RollingBatchSuspendResumeRsAction;
28 import org.apache.hadoop.hbase.chaos.monkies.ChaosMonkey;
29 import org.apache.hadoop.hbase.chaos.monkies.PolicyBasedChaosMonkey;
30 import org.apache.hadoop.hbase.chaos.policies.CompositeSequentialPolicy;
31 import org.apache.hadoop.hbase.chaos.policies.DoActionsOncePolicy;
32 import org.apache.hadoop.hbase.chaos.policies.PeriodicRandomActionPolicy;
33
34
35
36
37
38 public class ServerKillingMonkeyFactory extends MonkeyFactory {
39
40 private long rollingBatchSuspendRSSleepTime;
41 private float rollingBatchSuspendtRSRatio;
42
43 @Override
44 public ChaosMonkey build() {
45 loadProperties();
46
47
48 Action[] actions1 = new Action[] {
49 new RestartRandomRsExceptMetaAction(60000),
50 new RestartActiveMasterAction(5000),
51 new RollingBatchRestartRsExceptMetaAction(5000, 1.0f, 2),
52 new ForceBalancerAction(),
53 new RollingBatchSuspendResumeRsAction(rollingBatchSuspendRSSleepTime,
54 rollingBatchSuspendtRSRatio)
55 };
56
57
58 Action[] actions2 = new Action[] {
59 new DumpClusterStatusAction()
60 };
61
62 return new PolicyBasedChaosMonkey(util,
63 new CompositeSequentialPolicy(
64 new DoActionsOncePolicy(60 * 1000, actions1),
65 new PeriodicRandomActionPolicy(60 * 1000, actions1)),
66 new PeriodicRandomActionPolicy(60 * 1000, actions2));
67 }
68
69 private void loadProperties() {
70 rollingBatchSuspendRSSleepTime = Long.parseLong(this.properties.getProperty(
71 MonkeyConstants.ROLLING_BATCH_RESTART_RS_SLEEP_TIME,
72 MonkeyConstants.DEFAULT_ROLLING_BATCH_RESTART_RS_SLEEP_TIME + ""));
73 rollingBatchSuspendtRSRatio = Float.parseFloat(this.properties.getProperty(
74 MonkeyConstants.ROLLING_BATCH_RESTART_RS_RATIO,
75 MonkeyConstants.DEFAULT_ROLLING_BATCH_RESTART_RS_RATIO + ""));
76 }
77 }