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 */
018package org.apache.hadoop.hbase.chaos.factories;
019
020import org.apache.hadoop.hbase.chaos.actions.Action;
021import org.apache.hadoop.hbase.chaos.actions.AddColumnAction;
022import org.apache.hadoop.hbase.chaos.actions.ChangeBloomFilterAction;
023import org.apache.hadoop.hbase.chaos.actions.ChangeCompressionAction;
024import org.apache.hadoop.hbase.chaos.actions.ChangeEncodingAction;
025import org.apache.hadoop.hbase.chaos.actions.ChangeVersionsAction;
026import org.apache.hadoop.hbase.chaos.actions.CompactRandomRegionOfTableAction;
027import org.apache.hadoop.hbase.chaos.actions.CompactTableAction;
028import org.apache.hadoop.hbase.chaos.actions.DumpClusterStatusAction;
029import org.apache.hadoop.hbase.chaos.actions.FlushRandomRegionOfTableAction;
030import org.apache.hadoop.hbase.chaos.actions.FlushTableAction;
031import org.apache.hadoop.hbase.chaos.actions.MergeRandomAdjacentRegionsOfTableAction;
032import org.apache.hadoop.hbase.chaos.actions.MoveRandomRegionOfTableAction;
033import org.apache.hadoop.hbase.chaos.actions.MoveRegionsOfTableAction;
034import org.apache.hadoop.hbase.chaos.actions.RemoveColumnAction;
035import org.apache.hadoop.hbase.chaos.actions.SnapshotTableAction;
036import org.apache.hadoop.hbase.chaos.actions.SplitRandomRegionOfTableAction;
037import org.apache.hadoop.hbase.chaos.monkies.ChaosMonkey;
038import org.apache.hadoop.hbase.chaos.monkies.PolicyBasedChaosMonkey;
039import org.apache.hadoop.hbase.chaos.policies.PeriodicRandomActionPolicy;
040import org.apache.hadoop.hbase.chaos.policies.TwoConcurrentActionPolicy;
041
042/**
043 * Monkey factory to create a ChaosMonkey that will not need access to ssh. It will not kill any
044 * services and it will not perform any restarts.
045 */
046public class NoKillMonkeyFactory extends MonkeyFactory {
047  @Override
048  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), new FlushRandomRegionOfTableAction(tableName),
054      new MoveRandomRegionOfTableAction(tableName) };
055
056    Action[] actions2 = new Action[] { new SplitRandomRegionOfTableAction(tableName),
057      new MergeRandomAdjacentRegionsOfTableAction(tableName), new SnapshotTableAction(tableName),
058      new AddColumnAction(tableName), new RemoveColumnAction(tableName, columnFamilies),
059      new ChangeEncodingAction(tableName), new ChangeCompressionAction(tableName),
060      new ChangeBloomFilterAction(tableName), new ChangeVersionsAction(tableName) };
061
062    Action[] actions3 = new Action[] {
063      new MoveRegionsOfTableAction(MonkeyConstants.DEFAULT_MOVE_REGIONS_SLEEP_TIME,
064        MonkeyConstants.DEFAULT_MOVE_REGIONS_MAX_TIME, tableName),
065      new MoveRandomRegionOfTableAction(MonkeyConstants.DEFAULT_RESTART_ACTIVE_MASTER_SLEEP_TIME,
066        tableName), };
067
068    Action[] actions4 = new Action[] { new DumpClusterStatusAction() };
069
070    return new PolicyBasedChaosMonkey(properties, util,
071      new TwoConcurrentActionPolicy(MonkeyConstants.DEFAULT_PERIODIC_ACTION1_PERIOD, actions1,
072        actions2),
073      new PeriodicRandomActionPolicy(MonkeyConstants.DEFAULT_PERIODIC_ACTION2_PERIOD, actions3),
074      new PeriodicRandomActionPolicy(MonkeyConstants.DEFAULT_PERIODIC_ACTION4_PERIOD, actions4));
075  }
076}