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.CompactMobAction;
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 * This is a copy of NoKillMonkeyFactory that also does mob compactions.
045 */
046public class MobNoKillMonkeyFactory extends MonkeyFactory {
047  @Override public ChaosMonkey build() {
048    Action[] actions1 = new Action[] {
049      new CompactMobAction(tableName, MonkeyConstants.DEFAULT_PERIODIC_ACTION1_PERIOD),
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, tableName),
073      new MoveRandomRegionOfTableAction(MonkeyConstants.DEFAULT_RESTART_ACTIVE_MASTER_SLEEP_TIME,
074        tableName), };
075
076    Action[] actions4 = new Action[] { new DumpClusterStatusAction() };
077
078    return new PolicyBasedChaosMonkey(properties, util,
079      new TwoConcurrentActionPolicy(MonkeyConstants.DEFAULT_PERIODIC_ACTION1_PERIOD, actions1,
080        actions2),
081      new PeriodicRandomActionPolicy(MonkeyConstants.DEFAULT_PERIODIC_ACTION2_PERIOD,actions3),
082      new PeriodicRandomActionPolicy(MonkeyConstants.DEFAULT_PERIODIC_ACTION4_PERIOD,actions4));
083  }
084}