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  
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.AddColumnAction;
23  import org.apache.hadoop.hbase.chaos.actions.ChangeBloomFilterAction;
24  import org.apache.hadoop.hbase.chaos.actions.ChangeCompressionAction;
25  import org.apache.hadoop.hbase.chaos.actions.ChangeEncodingAction;
26  import org.apache.hadoop.hbase.chaos.actions.ChangeVersionsAction;
27  import org.apache.hadoop.hbase.chaos.actions.CompactRandomRegionOfTableAction;
28  import org.apache.hadoop.hbase.chaos.actions.CompactTableAction;
29  import org.apache.hadoop.hbase.chaos.actions.DumpClusterStatusAction;
30  import org.apache.hadoop.hbase.chaos.actions.FlushRandomRegionOfTableAction;
31  import org.apache.hadoop.hbase.chaos.actions.FlushTableAction;
32  import org.apache.hadoop.hbase.chaos.actions.MergeRandomAdjacentRegionsOfTableAction;
33  import org.apache.hadoop.hbase.chaos.actions.MoveRandomRegionOfTableAction;
34  import org.apache.hadoop.hbase.chaos.actions.MoveRegionsOfTableAction;
35  import org.apache.hadoop.hbase.chaos.actions.RemoveColumnAction;
36  import org.apache.hadoop.hbase.chaos.actions.SnapshotTableAction;
37  import org.apache.hadoop.hbase.chaos.actions.SplitRandomRegionOfTableAction;
38  import org.apache.hadoop.hbase.chaos.monkies.ChaosMonkey;
39  import org.apache.hadoop.hbase.chaos.monkies.PolicyBasedChaosMonkey;
40  import org.apache.hadoop.hbase.chaos.policies.PeriodicRandomActionPolicy;
41  import org.apache.hadoop.hbase.chaos.policies.TwoConcurrentActionPolicy;
42  
43  /**
44   * Monkey factory to create a ChaosMonkey that will not need access to ssh. It will not
45   * kill any services and it will not perform any restarts.
46   */
47  public class NoKillMonkeyFactory extends MonkeyFactory {
48    @Override public ChaosMonkey build() {
49      Action[] actions1 = new Action[] {
50          new CompactTableAction(tableName, MonkeyConstants.DEFAULT_PERIODIC_ACTION1_PERIOD),
51          new CompactRandomRegionOfTableAction(tableName,
52              MonkeyConstants.DEFAULT_COMPACT_RANDOM_REGION_RATIO),
53          new FlushTableAction(tableName),
54          new FlushRandomRegionOfTableAction(tableName),
55          new MoveRandomRegionOfTableAction(tableName)
56      };
57  
58      Action[] actions2 = new Action[] {
59          new SplitRandomRegionOfTableAction(tableName),
60          new MergeRandomAdjacentRegionsOfTableAction(tableName),
61          new SnapshotTableAction(tableName),
62          new AddColumnAction(tableName),
63          new RemoveColumnAction(tableName, columnFamilies),
64          new ChangeEncodingAction(tableName),
65          new ChangeCompressionAction(tableName),
66          new ChangeBloomFilterAction(tableName),
67          new ChangeVersionsAction(tableName)
68      };
69  
70      Action[] actions3 = new Action[] {
71          new MoveRegionsOfTableAction(MonkeyConstants.DEFAULT_MOVE_REGIONS_SLEEP_TIME,
72              MonkeyConstants.DEFAULT_MOVE_REGIONS_MAX_TIME,
73              tableName),
74          new MoveRandomRegionOfTableAction(MonkeyConstants.DEFAULT_RESTART_ACTIVE_MASTER_SLEEP_TIME,
75              tableName),
76      };
77  
78      Action[] actions4 = new Action[] {
79          new DumpClusterStatusAction()
80      };
81  
82      return new PolicyBasedChaosMonkey(util,
83          new TwoConcurrentActionPolicy(MonkeyConstants.DEFAULT_PERIODIC_ACTION1_PERIOD, actions1, actions2),
84          new PeriodicRandomActionPolicy(MonkeyConstants.DEFAULT_PERIODIC_ACTION2_PERIOD,actions3),
85          new PeriodicRandomActionPolicy(MonkeyConstants.DEFAULT_PERIODIC_ACTION4_PERIOD,actions4));
86    }
87  }