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.RestartRandomDataNodeAction;
26 import org.apache.hadoop.hbase.chaos.actions.RestartRandomRsExceptMetaAction;
27 import org.apache.hadoop.hbase.chaos.actions.RestartRandomZKNodeAction;
28 import org.apache.hadoop.hbase.chaos.actions.RollingBatchRestartRsExceptMetaAction;
29 import org.apache.hadoop.hbase.chaos.actions.RollingBatchSuspendResumeRsAction;
30 import org.apache.hadoop.hbase.chaos.monkies.ChaosMonkey;
31 import org.apache.hadoop.hbase.chaos.monkies.PolicyBasedChaosMonkey;
32 import org.apache.hadoop.hbase.chaos.policies.CompositeSequentialPolicy;
33 import org.apache.hadoop.hbase.chaos.policies.DoActionsOncePolicy;
34 import org.apache.hadoop.hbase.chaos.policies.PeriodicRandomActionPolicy;
35
36
37
38
39
40 public class ServerAndDependenciesKillingMonkeyFactory extends MonkeyFactory {
41
42 private long rollingBatchSuspendRSSleepTime;
43 private float rollingBatchSuspendtRSRatio;
44
45 @Override
46 public ChaosMonkey build() {
47 loadProperties();
48
49
50 Action[] actions1 = new Action[]{
51 new RestartRandomRsExceptMetaAction(60000),
52 new RestartActiveMasterAction(5000),
53 new RollingBatchRestartRsExceptMetaAction(5000, 1.0f, 2),
54 new ForceBalancerAction(),
55 new RestartRandomDataNodeAction(60000),
56 new RestartRandomZKNodeAction(60000),
57 new RollingBatchSuspendResumeRsAction(rollingBatchSuspendRSSleepTime,
58 rollingBatchSuspendtRSRatio)
59 };
60
61
62 Action[] actions2 = new Action[]{
63 new DumpClusterStatusAction()
64 };
65
66 return new PolicyBasedChaosMonkey(util,
67 new CompositeSequentialPolicy(
68 new DoActionsOncePolicy(60 * 1000, actions1),
69 new PeriodicRandomActionPolicy(60 * 1000, actions1)),
70 new PeriodicRandomActionPolicy(60 * 1000, actions2));
71 }
72
73 private void loadProperties() {
74 rollingBatchSuspendRSSleepTime = Long.parseLong(this.properties.getProperty(
75 MonkeyConstants.ROLLING_BATCH_RESTART_RS_SLEEP_TIME,
76 MonkeyConstants.DEFAULT_ROLLING_BATCH_RESTART_RS_SLEEP_TIME + ""));
77 rollingBatchSuspendtRSRatio = Float.parseFloat(this.properties.getProperty(
78 MonkeyConstants.ROLLING_BATCH_RESTART_RS_RATIO,
79 MonkeyConstants.DEFAULT_ROLLING_BATCH_RESTART_RS_RATIO + ""));
80 }
81 }