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    * <p>
10   * http://www.apache.org/licenses/LICENSE-2.0
11   * <p>
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.*;
21  import org.apache.hadoop.hbase.chaos.monkies.ChaosMonkey;
22  import org.apache.hadoop.hbase.chaos.monkies.PolicyBasedChaosMonkey;
23  import org.apache.hadoop.hbase.chaos.policies.CompositeSequentialPolicy;
24  import org.apache.hadoop.hbase.chaos.policies.DoActionsOncePolicy;
25  import org.apache.hadoop.hbase.chaos.policies.PeriodicRandomActionPolicy;
26  
27  public class StressAssignmentManagerMonkeyFactory extends MonkeyFactory {
28    @Override
29    public ChaosMonkey build() {
30  
31      // Actions that could slow down region movement.
32      // These could also get regions stuck if there are issues.
33      Action[] actions1 = new Action[]{
34          new CompactTableAction(tableName, 0.5f),
35          new CompactRandomRegionOfTableAction(tableName, 0.6f),
36          new FlushTableAction(tableName),
37          new FlushRandomRegionOfTableAction(tableName)
38      };
39  
40      Action[] actions2 = new Action[]{
41          new SplitRandomRegionOfTableAction(tableName),
42          new MergeRandomAdjacentRegionsOfTableAction(tableName),
43          new AddColumnAction(tableName),
44          new RemoveColumnAction(tableName, columnFamilies),
45          new MoveRegionsOfTableAction(MonkeyConstants.DEFAULT_MOVE_REGIONS_SLEEP_TIME,
46              1600,
47              tableName),
48          new MoveRandomRegionOfTableAction(MonkeyConstants.DEFAULT_MOVE_RANDOM_REGION_SLEEP_TIME,
49              tableName),
50          new RestartRandomRsAction(MonkeyConstants.DEFAULT_RESTART_RANDOM_RS_SLEEP_TIME),
51          new BatchRestartRsAction(MonkeyConstants.DEFAULT_ROLLING_BATCH_RESTART_RS_SLEEP_TIME, 0.5f),
52          new RollingBatchRestartRsAction(MonkeyConstants.DEFAULT_BATCH_RESTART_RS_SLEEP_TIME, 1.0f),
53          new RestartRsHoldingMetaAction(MonkeyConstants.DEFAULT_RESTART_RS_HOLDING_META_SLEEP_TIME),
54          new ChangeSplitPolicyAction(tableName),
55          new SplitAllRegionOfTableAction(tableName),
56          new DecreaseMaxHFileSizeAction(MonkeyConstants.DEFAULT_DECREASE_HFILE_SIZE_SLEEP_TIME,
57              tableName),
58      };
59  
60      // Action to log more info for debugging
61      Action[] actions3 = new Action[]{
62          new DumpClusterStatusAction()
63      };
64  
65      return new PolicyBasedChaosMonkey(util,
66          new PeriodicRandomActionPolicy(90 * 1000, actions1),
67          new CompositeSequentialPolicy(
68              new DoActionsOncePolicy(90 * 1000, actions2),
69              new PeriodicRandomActionPolicy(90 * 1000, actions2)),
70          new PeriodicRandomActionPolicy(90 * 1000, actions3)
71      );
72    }
73  }