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    loadProperties();
050    Action[] actions1 = new Action[] { new CompactMobAction(tableName, action1Period),
051      new CompactTableAction(tableName, action1Period),
052      new CompactRandomRegionOfTableAction(tableName, compactRandomRegionRatio),
053      new FlushTableAction(tableName), new FlushRandomRegionOfTableAction(tableName),
054      new MoveRandomRegionOfTableAction(tableName) };
055
056    Action[] actions2 = new Action[] { new SplitRandomRegionOfTableAction(tableName),
057      new MergeRandomAdjacentRegionsOfTableAction(tableName),
058      new SnapshotTableAction(tableName, snapshotTableTtl), new AddColumnAction(tableName),
059      new RemoveColumnAction(tableName, columnFamilies), new ChangeEncodingAction(tableName),
060      new ChangeCompressionAction(tableName), new ChangeBloomFilterAction(tableName),
061      new ChangeVersionsAction(tableName) };
062
063    Action[] actions3 = new Action[] {
064      new MoveRegionsOfTableAction(moveRegionsSleepTime, moveRegionsMaxTime, tableName),
065      new MoveRandomRegionOfTableAction(restartActiveMasterSleepTime, tableName) };
066
067    Action[] actions4 = new Action[] { new DumpClusterStatusAction() };
068
069    return new PolicyBasedChaosMonkey(properties, util,
070      new TwoConcurrentActionPolicy(action1Period, actions1, actions2),
071      new PeriodicRandomActionPolicy(action2Period, actions3),
072      new PeriodicRandomActionPolicy(action4Period, actions4));
073  }
074}