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
048  public ChaosMonkey build() {
049    Action[] actions1 = new Action[] {
050      new CompactMobAction(tableName, MonkeyConstants.DEFAULT_PERIODIC_ACTION1_PERIOD),
051      new CompactTableAction(tableName, MonkeyConstants.DEFAULT_PERIODIC_ACTION1_PERIOD),
052      new CompactRandomRegionOfTableAction(tableName,
053        MonkeyConstants.DEFAULT_COMPACT_RANDOM_REGION_RATIO),
054      new FlushTableAction(tableName), new FlushRandomRegionOfTableAction(tableName),
055      new MoveRandomRegionOfTableAction(tableName) };
056
057    Action[] actions2 = new Action[] { new SplitRandomRegionOfTableAction(tableName),
058      new MergeRandomAdjacentRegionsOfTableAction(tableName), new SnapshotTableAction(tableName),
059      new AddColumnAction(tableName), new RemoveColumnAction(tableName, columnFamilies),
060      new ChangeEncodingAction(tableName), new ChangeCompressionAction(tableName),
061      new ChangeBloomFilterAction(tableName), new ChangeVersionsAction(tableName) };
062
063    Action[] actions3 = new Action[] {
064      new MoveRegionsOfTableAction(MonkeyConstants.DEFAULT_MOVE_REGIONS_SLEEP_TIME,
065        MonkeyConstants.DEFAULT_MOVE_REGIONS_MAX_TIME, tableName),
066      new MoveRandomRegionOfTableAction(MonkeyConstants.DEFAULT_RESTART_ACTIVE_MASTER_SLEEP_TIME,
067        tableName), };
068
069    Action[] actions4 = new Action[] { new DumpClusterStatusAction() };
070
071    return new PolicyBasedChaosMonkey(properties, util,
072      new TwoConcurrentActionPolicy(MonkeyConstants.DEFAULT_PERIODIC_ACTION1_PERIOD, actions1,
073        actions2),
074      new PeriodicRandomActionPolicy(MonkeyConstants.DEFAULT_PERIODIC_ACTION2_PERIOD, actions3),
075      new PeriodicRandomActionPolicy(MonkeyConstants.DEFAULT_PERIODIC_ACTION4_PERIOD, actions4));
076  }
077}