View Javadoc

1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.hadoop.hbase.chaos.factories;
19  
20  import org.apache.hadoop.hbase.chaos.actions.Action;
21  import org.apache.hadoop.hbase.chaos.actions.AddColumnAction;
22  import org.apache.hadoop.hbase.chaos.actions.BatchRestartRsAction;
23  import org.apache.hadoop.hbase.chaos.actions.CompactRandomRegionOfTableAction;
24  import org.apache.hadoop.hbase.chaos.actions.CompactTableAction;
25  import org.apache.hadoop.hbase.chaos.actions.DumpClusterStatusAction;
26  import org.apache.hadoop.hbase.chaos.actions.FlushRandomRegionOfTableAction;
27  import org.apache.hadoop.hbase.chaos.actions.FlushTableAction;
28  import org.apache.hadoop.hbase.chaos.actions.MergeRandomAdjacentRegionsOfTableAction;
29  import org.apache.hadoop.hbase.chaos.actions.MoveRandomRegionOfTableAction;
30  import org.apache.hadoop.hbase.chaos.actions.MoveRegionsOfTableAction;
31  import org.apache.hadoop.hbase.chaos.actions.RemoveColumnAction;
32  import org.apache.hadoop.hbase.chaos.actions.RestartRandomRsAction;
33  import org.apache.hadoop.hbase.chaos.actions.RestartRsHoldingMetaAction;
34  import org.apache.hadoop.hbase.chaos.actions.RollingBatchRestartRsAction;
35  import org.apache.hadoop.hbase.chaos.actions.SplitRandomRegionOfTableAction;
36  import org.apache.hadoop.hbase.chaos.monkies.ChaosMonkey;
37  import org.apache.hadoop.hbase.chaos.monkies.PolicyBasedChaosMonkey;
38  import org.apache.hadoop.hbase.chaos.policies.CompositeSequentialPolicy;
39  import org.apache.hadoop.hbase.chaos.policies.DoActionsOncePolicy;
40  import org.apache.hadoop.hbase.chaos.policies.PeriodicRandomActionPolicy;
41  
42  public class StressAssignmentManagerMonkeyFactory extends MonkeyFactory {
43    @Override
44    public ChaosMonkey build() {
45  
46      // Actions that could slow down region movement.
47      // These could also get regions stuck if there are issues.
48      Action[] actions1 = new Action[] {
49          new CompactTableAction(tableName, 0.5f),
50          new CompactRandomRegionOfTableAction(tableName, 0.6f),
51          new FlushTableAction(tableName),
52          new FlushRandomRegionOfTableAction(tableName)
53      };
54  
55      Action[] actions2 = new Action[] {
56          new SplitRandomRegionOfTableAction(tableName),
57          new MergeRandomAdjacentRegionsOfTableAction(tableName),
58          new AddColumnAction(tableName),
59          new RemoveColumnAction(tableName, columnFamilies),
60          new MoveRegionsOfTableAction(800, 1600, tableName),
61          new MoveRandomRegionOfTableAction(800, tableName),
62          new RestartRandomRsAction(60000),
63          new BatchRestartRsAction(5000, 0.5f),
64          new RollingBatchRestartRsAction(5000, 1.0f),
65          new RestartRsHoldingMetaAction(35000)
66      };
67  
68      // Action to log more info for debugging
69      Action[] actions3 = new Action[] {
70          new DumpClusterStatusAction()
71      };
72  
73      return new PolicyBasedChaosMonkey(util,
74          new PeriodicRandomActionPolicy(90 * 1000, actions1),
75          new CompositeSequentialPolicy(
76              new DoActionsOncePolicy(90 * 1000, actions2),
77              new PeriodicRandomActionPolicy(90 * 1000, actions2)),
78          new PeriodicRandomActionPolicy(90 * 1000, actions3)
79      );
80    }
81  }