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.*;
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.PeriodicRandomActionPolicy;
24  import org.apache.hadoop.hbase.chaos.policies.TwoConcurrentActionPolicy;
25  
26  /**
27   * This is a copy of NoKillMonkeyFactory that also does mob compactions.
28   */
29  public class MobNoKillMonkeyFactory extends MonkeyFactory {
30    @Override public ChaosMonkey build() {
31      Action[] actions1 = new Action[] {
32              new CompactMobAction(tableName, MonkeyConstants.DEFAULT_PERIODIC_ACTION1_PERIOD),
33              new CompactTableAction(tableName, MonkeyConstants.DEFAULT_PERIODIC_ACTION1_PERIOD),
34              new CompactRandomRegionOfTableAction(tableName,
35                      MonkeyConstants.DEFAULT_COMPACT_RANDOM_REGION_RATIO),
36              new FlushTableAction(tableName),
37              new FlushRandomRegionOfTableAction(tableName),
38              new MoveRandomRegionOfTableAction(tableName)
39      };
40  
41      Action[] actions2 = new Action[] {
42              new SplitRandomRegionOfTableAction(tableName),
43              new MergeRandomAdjacentRegionsOfTableAction(tableName),
44              new SnapshotTableAction(tableName),
45              new AddColumnAction(tableName),
46              new RemoveColumnAction(tableName, columnFamilies),
47              new ChangeEncodingAction(tableName),
48              new ChangeCompressionAction(tableName),
49              new ChangeBloomFilterAction(tableName),
50              new ChangeVersionsAction(tableName)
51      };
52  
53      Action[] actions3 = new Action[] {
54              new MoveRegionsOfTableAction(MonkeyConstants.DEFAULT_MOVE_REGIONS_SLEEP_TIME,
55                      MonkeyConstants.DEFAULT_MOVE_REGIONS_MAX_TIME,
56                      tableName),
57              new MoveRandomRegionOfTableAction(MonkeyConstants.DEFAULT_RESTART_ACTIVE_MASTER_SLEEP_TIME,
58                      tableName),
59      };
60  
61      Action[] actions4 = new Action[] {
62              new DumpClusterStatusAction()
63      };
64  
65      return new PolicyBasedChaosMonkey(util,
66              new TwoConcurrentActionPolicy(MonkeyConstants.DEFAULT_PERIODIC_ACTION1_PERIOD, actions1, actions2),
67              new PeriodicRandomActionPolicy(MonkeyConstants.DEFAULT_PERIODIC_ACTION2_PERIOD,actions3),
68              new PeriodicRandomActionPolicy(MonkeyConstants.DEFAULT_PERIODIC_ACTION4_PERIOD,actions4));
69    }
70  }