Skip to content

Commit

Permalink
HBASE-18439 Subclasses of o.a.h.h.chaos.actions.Action all use the sa…
Browse files Browse the repository at this point in the history
…me logger

Signed-off-by: Jan Hentschel <jan.hentschel@ultratendency.com>
Signed-off-by: Guangxu Cheng <gxcheng@apache.org>
  • Loading branch information
rabi-kumar authored and HorizonNet committed Nov 8, 2019
1 parent 82037ee commit 5dfa58b
Show file tree
Hide file tree
Showing 34 changed files with 178 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class Action {
public static final String START_NAMENODE_TIMEOUT_KEY =
"hbase.chaosmonkey.action.startnamenodetimeout";

protected static final Logger LOG = LoggerFactory.getLogger(Action.class);
private static final Logger LOG = LoggerFactory.getLogger(Action.class);

protected static final long KILL_MASTER_TIMEOUT_DEFAULT = PolicyBasedChaosMonkey.TIMEOUT;
protected static final long START_MASTER_TIMEOUT_DEFAULT = PolicyBasedChaosMonkey.TIMEOUT;
Expand Down Expand Up @@ -312,9 +312,11 @@ public Configuration getConf() {
}

/**
* Apply a transform to all columns in a given table. If there are no columns in a table or if the context is stopping does nothing.
* Apply a transform to all columns in a given table. If there are no columns in a table
* or if the context is stopping does nothing.
* @param tableName the table to modify
* @param transform the modification to perform. Callers will have the column name as a string and a column family builder available to them
* @param transform the modification to perform. Callers will have the
* column name as a string and a column family builder available to them
*/
protected void modifyAllTableColumns(TableName tableName, BiConsumer<String, ColumnFamilyDescriptorBuilder> transform) throws IOException {
HBaseTestingUtility util = this.context.getHBaseIntegrationTestingUtility();
Expand Down Expand Up @@ -342,7 +344,8 @@ protected void modifyAllTableColumns(TableName tableName, BiConsumer<String, Col
}

/**
* Apply a transform to all columns in a given table. If there are no columns in a table or if the context is stopping does nothing.
* Apply a transform to all columns in a given table.
* If there are no columns in a table or if the context is stopping does nothing.
* @param tableName the table to modify
* @param transform the modification to perform on each column family descriptor builder
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
import org.apache.hadoop.hbase.client.TableDescriptor;
import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Action the adds a column family to a table.
*/
public class AddColumnAction extends Action {
private final TableName tableName;
private Admin admin;
private static final Logger LOG = LoggerFactory.getLogger(AddColumnAction.class);

public AddColumnAction(TableName tableName) {
this.tableName = tableName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.chaos.monkies.PolicyBasedChaosMonkey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Restarts a ratio of the running regionservers at the same time
*/
public class BatchRestartRsAction extends RestartActionBaseAction {
float ratio; //ratio of regionservers to restart
private static final Logger LOG =
LoggerFactory.getLogger(BatchRestartRsAction.class);

public BatchRestartRsAction(long sleepTime, float ratio) {
super(sleepTime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.regionserver.BloomType;
import org.apache.hadoop.hbase.util.BloomFilterUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Action that tries to adjust the bloom filter setting on all the columns of a
Expand All @@ -31,6 +33,7 @@
public class ChangeBloomFilterAction extends Action {
private final long sleepTime;
private final TableName tableName;
private static final Logger LOG = LoggerFactory.getLogger(ChangeBloomFilterAction.class);

public ChangeBloomFilterAction(TableName tableName) {
this(-1, tableName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,22 @@

package org.apache.hadoop.hbase.chaos.actions;

import java.io.IOException;
import java.util.Random;

import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.io.compress.Compression.Algorithm;
import org.apache.hadoop.io.compress.Compressor;

import java.io.IOException;
import java.util.Random;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Action that changes the compression algorithm on a column family from a list of tables.
*/
public class ChangeCompressionAction extends Action {
private final TableName tableName;
private final Random random;
private static final Logger LOG = LoggerFactory.getLogger(ChangeCompressionAction.class);

public ChangeCompressionAction(TableName tableName) {
this.tableName = tableName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,21 @@

package org.apache.hadoop.hbase.chaos.actions;

import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.io.encoding.DataBlockEncoding;

import java.io.IOException;
import java.util.Random;

import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.io.encoding.DataBlockEncoding;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Action that changes the encoding on a column family from a list of tables.
*/
public class ChangeEncodingAction extends Action {
private final TableName tableName;
private final Random random;
private static final Logger LOG = LoggerFactory.getLogger(ChangeEncodingAction.class);

public ChangeEncodingAction(TableName tableName) {
this.tableName = tableName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package org.apache.hadoop.hbase.chaos.actions;

import java.util.Random;

import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
Expand All @@ -25,10 +27,11 @@
import org.apache.hadoop.hbase.regionserver.ConstantSizeRegionSplitPolicy;
import org.apache.hadoop.hbase.regionserver.DisabledRegionSplitPolicy;
import org.apache.hadoop.hbase.regionserver.IncreasingToUpperBoundRegionSplitPolicy;

import java.util.Random;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ChangeSplitPolicyAction extends Action {
private static final Logger LOG = LoggerFactory.getLogger(ChangeSplitPolicyAction.class);
private final TableName tableName;
private final String[] possiblePolicies;
private final Random random;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.util.Random;

import org.apache.hadoop.hbase.TableName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Action that changes the number of versions on a column family from a list of tables.
Expand All @@ -30,6 +32,7 @@
*/
public class ChangeVersionsAction extends Action {
private final TableName tableName;
private static final Logger LOG = LoggerFactory.getLogger(ChangeVersionsAction.class);

private Random random;

Expand All @@ -44,7 +47,7 @@ public void perform() throws IOException {

LOG.debug("Performing action: Changing versions on " + tableName + " to " + versions);
modifyAllTableColumns(tableName, columnBuilder -> {
columnBuilder.setMinVersions(versions).setMaxVersions(versions);
columnBuilder.setMinVersions(versions).setMaxVersions(versions);
});
LOG.debug("Performing action: Just changed versions on " + tableName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.CompactType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Action that queues a table compaction.
Expand All @@ -31,6 +33,7 @@ public class CompactMobAction extends Action {
private final TableName tableName;
private final int majorRatio;
private final long sleepTime;
private static final Logger LOG = LoggerFactory.getLogger(CompactMobAction.class);

public CompactMobAction(TableName tableName, float majorRatio) {
this(-1, tableName, majorRatio);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.chaos.monkies.PolicyBasedChaosMonkey;
import org.apache.hadoop.hbase.client.Admin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Region that queues a compaction of a random region from the table.
Expand All @@ -34,6 +36,8 @@ public class CompactRandomRegionOfTableAction extends Action {
private final int majorRatio;
private final long sleepTime;
private final TableName tableName;
private static final Logger LOG =
LoggerFactory.getLogger(CompactRandomRegionOfTableAction.class);

public CompactRandomRegionOfTableAction(
TableName tableName, float majorRatio) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Action that queues a table compaction.
Expand All @@ -30,6 +32,7 @@ public class CompactTableAction extends Action {
private final TableName tableName;
private final int majorRatio;
private final long sleepTime;
private static final Logger LOG = LoggerFactory.getLogger(CompactTableAction.class);

public CompactTableAction(TableName tableName, float majorRatio) {
this(-1, tableName, majorRatio);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@

import java.io.IOException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Action to dump the cluster status.
*/
public class DumpClusterStatusAction extends Action {
private static final Logger LOG =
LoggerFactory.getLogger(DumpClusterStatusAction.class);

@Override
public void init(ActionContext context) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,20 @@
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.chaos.monkies.PolicyBasedChaosMonkey;
import org.apache.hadoop.hbase.client.Admin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Action that tries to flush a random region of a table.
*/
public class FlushRandomRegionOfTableAction extends Action {
private static final Logger LOG =
LoggerFactory.getLogger(FlushRandomRegionOfTableAction.class);
private final long sleepTime;
private final TableName tableName;

public FlushRandomRegionOfTableAction(TableName tableName) {
this (-1, tableName);
this (-1, tableName);
}

public FlushRandomRegionOfTableAction(int sleepTime, TableName tableName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Action that tries to flush a table.
*/
public class FlushTableAction extends Action {
private static final Logger LOG =
LoggerFactory.getLogger(FlushTableAction.class);
private final long sleepTime;
private final TableName tableName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@

package org.apache.hadoop.hbase.chaos.actions;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Action that tries to force a balancer run.
*/
public class ForceBalancerAction extends Action {
private static final Logger LOG =
LoggerFactory.getLogger(ForceBalancerAction.class);

@Override
public void perform() throws Exception {
// Don't try the flush if we're stopping
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Action to merge regions of a table.
*/
public class MergeRandomAdjacentRegionsOfTableAction extends Action {
private static final Logger LOG =
LoggerFactory.getLogger(MergeRandomAdjacentRegionsOfTableAction.class);
private final TableName tableName;
private final long sleepTime;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@
import org.apache.hadoop.hbase.chaos.monkies.PolicyBasedChaosMonkey;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Action that tries to move a random region of a table.
*/
public class MoveRandomRegionOfTableAction extends Action {
private static final Logger LOG =
LoggerFactory.getLogger(MoveRandomRegionOfTableAction.class);
private final long sleepTime;
private final TableName tableName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,23 @@
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import org.apache.commons.lang3.RandomUtils;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.chaos.factories.MonkeyConstants;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Action that tries to move every region of a table.
*/
public class MoveRegionsOfTableAction extends Action {
private static final Logger LOG =
LoggerFactory.getLogger(MoveRegionsOfTableAction.class);
private final long sleepTime;
private final TableName tableName;
private final long maxTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@
import org.apache.hadoop.hbase.client.TableDescriptor;
import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
import org.apache.hadoop.hbase.util.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Action that removes a column family.
*/
public class RemoveColumnAction extends Action {
private static final Logger LOG =
LoggerFactory.getLogger(RemoveColumnAction.class);
private final TableName tableName;
private final Set<String> protectedColumns;
private Admin admin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@

import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.util.Threads;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Base class for restarting HBaseServer's
*/
public class RestartActionBaseAction extends Action {
private static final Logger LOG =
LoggerFactory.getLogger(RestartActionBaseAction.class);
long sleepTime; // how long should we sleep

public RestartActionBaseAction(long sleepTime) {
Expand Down

0 comments on commit 5dfa58b

Please sign in to comment.