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 * <p> 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * <p> 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.*; 021import org.apache.hadoop.hbase.chaos.monkies.ChaosMonkey; 022import org.apache.hadoop.hbase.chaos.monkies.PolicyBasedChaosMonkey; 023import org.apache.hadoop.hbase.chaos.policies.CompositeSequentialPolicy; 024import org.apache.hadoop.hbase.chaos.policies.DoActionsOncePolicy; 025import org.apache.hadoop.hbase.chaos.policies.PeriodicRandomActionPolicy; 026 027public class StressAssignmentManagerMonkeyFactory extends MonkeyFactory { 028 @Override 029 public ChaosMonkey build() { 030 031 // Actions that could slow down region movement. 032 // These could also get regions stuck if there are issues. 033 Action[] actions1 = new Action[]{ 034 new CompactTableAction(tableName, 0.5f), 035 new CompactRandomRegionOfTableAction(tableName, 0.6f), 036 new FlushTableAction(tableName), 037 new FlushRandomRegionOfTableAction(tableName) 038 }; 039 040 Action[] actions2 = new Action[]{ 041 new SplitRandomRegionOfTableAction(tableName), 042 new MergeRandomAdjacentRegionsOfTableAction(tableName), 043 new AddColumnAction(tableName), 044 new RemoveColumnAction(tableName, columnFamilies), 045 new MoveRegionsOfTableAction(MonkeyConstants.DEFAULT_MOVE_REGIONS_SLEEP_TIME, 046 1600, 047 tableName), 048 new MoveRandomRegionOfTableAction(MonkeyConstants.DEFAULT_MOVE_RANDOM_REGION_SLEEP_TIME, 049 tableName), 050 new RestartRandomRsAction(MonkeyConstants.DEFAULT_RESTART_RANDOM_RS_SLEEP_TIME), 051 new BatchRestartRsAction(MonkeyConstants.DEFAULT_ROLLING_BATCH_RESTART_RS_SLEEP_TIME, 0.5f), 052 new RollingBatchRestartRsAction(MonkeyConstants.DEFAULT_BATCH_RESTART_RS_SLEEP_TIME, 1.0f), 053 new RestartRsHoldingMetaAction(MonkeyConstants.DEFAULT_RESTART_RS_HOLDING_META_SLEEP_TIME), 054 new ChangeSplitPolicyAction(tableName), 055 new SplitAllRegionOfTableAction(tableName), 056 new DecreaseMaxHFileSizeAction(MonkeyConstants.DEFAULT_DECREASE_HFILE_SIZE_SLEEP_TIME, 057 tableName), 058 }; 059 060 // Action to log more info for debugging 061 Action[] actions3 = new Action[]{ 062 new DumpClusterStatusAction() 063 }; 064 065 return new PolicyBasedChaosMonkey(util, 066 new PeriodicRandomActionPolicy(90 * 1000, actions1), 067 new CompositeSequentialPolicy( 068 new DoActionsOncePolicy(90 * 1000, actions2), 069 new PeriodicRandomActionPolicy(90 * 1000, actions2)), 070 new PeriodicRandomActionPolicy(90 * 1000, actions3) 071 ); 072 } 073}