001/**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018
019package org.apache.hadoop.hbase.chaos.factories;
020
021import org.apache.hadoop.hbase.chaos.actions.Action;
022import org.apache.hadoop.hbase.chaos.actions.AddColumnAction;
023import org.apache.hadoop.hbase.chaos.actions.ChangeBloomFilterAction;
024import org.apache.hadoop.hbase.chaos.actions.ChangeCompressionAction;
025import org.apache.hadoop.hbase.chaos.actions.ChangeEncodingAction;
026import org.apache.hadoop.hbase.chaos.actions.ChangeVersionsAction;
027import org.apache.hadoop.hbase.chaos.actions.CompactRandomRegionOfTableAction;
028import org.apache.hadoop.hbase.chaos.actions.CompactTableAction;
029import org.apache.hadoop.hbase.chaos.actions.DumpClusterStatusAction;
030import org.apache.hadoop.hbase.chaos.actions.FlushRandomRegionOfTableAction;
031import org.apache.hadoop.hbase.chaos.actions.FlushTableAction;
032import org.apache.hadoop.hbase.chaos.actions.MergeRandomAdjacentRegionsOfTableAction;
033import org.apache.hadoop.hbase.chaos.actions.MoveRandomRegionOfTableAction;
034import org.apache.hadoop.hbase.chaos.actions.MoveRegionsOfTableAction;
035import org.apache.hadoop.hbase.chaos.actions.RemoveColumnAction;
036import org.apache.hadoop.hbase.chaos.actions.SnapshotTableAction;
037import org.apache.hadoop.hbase.chaos.actions.SplitRandomRegionOfTableAction;
038import org.apache.hadoop.hbase.chaos.monkies.ChaosMonkey;
039import org.apache.hadoop.hbase.chaos.monkies.PolicyBasedChaosMonkey;
040import org.apache.hadoop.hbase.chaos.policies.PeriodicRandomActionPolicy;
041import org.apache.hadoop.hbase.chaos.policies.TwoConcurrentActionPolicy;
042
043/**
044 * Monkey factory to create a ChaosMonkey that will not need access to ssh. It will not
045 * kill any services and it will not perform any restarts.
046 */
047public class NoKillMonkeyFactory extends MonkeyFactory {
048  @Override public ChaosMonkey build() {
049    Action[] actions1 = new Action[] {
050        new CompactTableAction(tableName, MonkeyConstants.DEFAULT_PERIODIC_ACTION1_PERIOD),
051        new CompactRandomRegionOfTableAction(tableName,
052            MonkeyConstants.DEFAULT_COMPACT_RANDOM_REGION_RATIO),
053        new FlushTableAction(tableName),
054        new FlushRandomRegionOfTableAction(tableName),
055        new MoveRandomRegionOfTableAction(tableName)
056    };
057
058    Action[] actions2 = new Action[] {
059        new SplitRandomRegionOfTableAction(tableName),
060        new MergeRandomAdjacentRegionsOfTableAction(tableName),
061        new SnapshotTableAction(tableName),
062        new AddColumnAction(tableName),
063        new RemoveColumnAction(tableName, columnFamilies),
064        new ChangeEncodingAction(tableName),
065        new ChangeCompressionAction(tableName),
066        new ChangeBloomFilterAction(tableName),
067        new ChangeVersionsAction(tableName)
068    };
069
070    Action[] actions3 = new Action[] {
071        new MoveRegionsOfTableAction(MonkeyConstants.DEFAULT_MOVE_REGIONS_SLEEP_TIME,
072            MonkeyConstants.DEFAULT_MOVE_REGIONS_MAX_TIME,
073            tableName),
074        new MoveRandomRegionOfTableAction(MonkeyConstants.DEFAULT_RESTART_ACTIVE_MASTER_SLEEP_TIME,
075            tableName),
076    };
077
078    Action[] actions4 = new Action[] {
079        new DumpClusterStatusAction()
080    };
081
082    return new PolicyBasedChaosMonkey(properties, util,
083        new TwoConcurrentActionPolicy(MonkeyConstants.DEFAULT_PERIODIC_ACTION1_PERIOD, actions1, actions2),
084        new PeriodicRandomActionPolicy(MonkeyConstants.DEFAULT_PERIODIC_ACTION2_PERIOD,actions3),
085        new PeriodicRandomActionPolicy(MonkeyConstants.DEFAULT_PERIODIC_ACTION4_PERIOD,actions4));
086  }
087}