HBASE-18631 Allow ChaosMonkey properties to be specified in hbase-site
This commit is contained in:
parent
b932d38b2a
commit
13028d7157
|
@ -19,6 +19,7 @@
|
||||||
package org.apache.hadoop.hbase;
|
package org.apache.hadoop.hbase;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -27,6 +28,7 @@ import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
|
import org.apache.hadoop.hbase.chaos.factories.MonkeyConstants;
|
||||||
import org.apache.hadoop.hbase.chaos.factories.MonkeyFactory;
|
import org.apache.hadoop.hbase.chaos.factories.MonkeyFactory;
|
||||||
import org.apache.hadoop.hbase.chaos.monkies.ChaosMonkey;
|
import org.apache.hadoop.hbase.chaos.monkies.ChaosMonkey;
|
||||||
import org.apache.hadoop.hbase.util.AbstractHBaseTool;
|
import org.apache.hadoop.hbase.util.AbstractHBaseTool;
|
||||||
|
@ -86,6 +88,10 @@ public abstract class IntegrationTestBase extends AbstractHBaseTool {
|
||||||
noClusterCleanUp = true;
|
noClusterCleanUp = true;
|
||||||
}
|
}
|
||||||
monkeyProps = new Properties();
|
monkeyProps = new Properties();
|
||||||
|
// Add entries for the CM from hbase-site.xml as a convenience.
|
||||||
|
// Do this prior to loading from the properties file to make sure those in the properties
|
||||||
|
// file are given precedence to those in hbase-site.xml (backwards compatibility).
|
||||||
|
loadMonkeyProperties(monkeyProps, HBaseConfiguration.create());
|
||||||
if (cmd.hasOption(CHAOS_MONKEY_PROPS)) {
|
if (cmd.hasOption(CHAOS_MONKEY_PROPS)) {
|
||||||
String chaosMonkeyPropsFile = cmd.getOptionValue(CHAOS_MONKEY_PROPS);
|
String chaosMonkeyPropsFile = cmd.getOptionValue(CHAOS_MONKEY_PROPS);
|
||||||
if (StringUtils.isNotEmpty(chaosMonkeyPropsFile)) {
|
if (StringUtils.isNotEmpty(chaosMonkeyPropsFile)) {
|
||||||
|
@ -100,6 +106,21 @@ public abstract class IntegrationTestBase extends AbstractHBaseTool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads entries from the provided {@code conf} into {@code props} when the configuration key
|
||||||
|
* is one that may be configuring ChaosMonkey actions.
|
||||||
|
*/
|
||||||
|
void loadMonkeyProperties(Properties props, Configuration conf) {
|
||||||
|
for (Entry<String,String> entry : conf) {
|
||||||
|
for (String prefix : MonkeyConstants.MONKEY_CONFIGURATION_KEY_PREFIXES) {
|
||||||
|
if (entry.getKey().startsWith(prefix)) {
|
||||||
|
props.put(entry.getKey(), entry.getValue());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void processOptions(CommandLine cmd) {
|
protected void processOptions(CommandLine cmd) {
|
||||||
processBaseOptions(cmd);
|
processBaseOptions(cmd);
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
/**
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.apache.hadoop.hbase;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.apache.hadoop.conf.Configuration;
|
||||||
|
import org.apache.hadoop.hbase.chaos.factories.MonkeyConstants;
|
||||||
|
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.experimental.categories.Category;
|
||||||
|
|
||||||
|
@Category(SmallTests.class)
|
||||||
|
public class TestIntegrationTestBase {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMonkeyPropertiesParsing() {
|
||||||
|
final Configuration conf = new Configuration(false);
|
||||||
|
conf.set(MonkeyConstants.BATCH_RESTART_RS_RATIO, "0.85");
|
||||||
|
conf.set(MonkeyConstants.MOVE_REGIONS_MAX_TIME, "60000");
|
||||||
|
conf.set("hbase.rootdir", "/foo/bar/baz");
|
||||||
|
|
||||||
|
final Properties props = new Properties();
|
||||||
|
IntegrationTestBase testBase = new IntegrationTestDDLMasterFailover();
|
||||||
|
assertEquals(0, props.size());
|
||||||
|
testBase.loadMonkeyProperties(props, conf);
|
||||||
|
assertEquals(2, props.size());
|
||||||
|
assertEquals("0.85", props.getProperty(MonkeyConstants.BATCH_RESTART_RS_RATIO));
|
||||||
|
assertEquals("60000", props.getProperty(MonkeyConstants.MOVE_REGIONS_MAX_TIME));
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,6 +17,10 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.hbase.chaos.factories;
|
package org.apache.hadoop.hbase.chaos.factories;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public interface MonkeyConstants {
|
public interface MonkeyConstants {
|
||||||
|
|
||||||
String PERIODIC_ACTION1_PERIOD = "sdm.action1.period";
|
String PERIODIC_ACTION1_PERIOD = "sdm.action1.period";
|
||||||
|
@ -42,6 +46,13 @@ public interface MonkeyConstants {
|
||||||
String UNBALANCE_KILL_META_RS = "unbalance.action.kill.meta.rs";
|
String UNBALANCE_KILL_META_RS = "unbalance.action.kill.meta.rs";
|
||||||
String DECREASE_HFILE_SIZE_SLEEP_TIME = "decrease.hfile.size.sleep.time";
|
String DECREASE_HFILE_SIZE_SLEEP_TIME = "decrease.hfile.size.sleep.time";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Set of prefixes which encompasses all of the configuration properties for the ChaosMonky.
|
||||||
|
*/
|
||||||
|
Set<String> MONKEY_CONFIGURATION_KEY_PREFIXES = new HashSet<>(
|
||||||
|
Arrays.asList("sdm.", "move.", "restart.", "batch.", "rolling.", "compact.",
|
||||||
|
"unbalance.", "decrease."));
|
||||||
|
|
||||||
long DEFAULT_PERIODIC_ACTION1_PERIOD = 60 * 1000;
|
long DEFAULT_PERIODIC_ACTION1_PERIOD = 60 * 1000;
|
||||||
long DEFAULT_PERIODIC_ACTION2_PERIOD = 90 * 1000;
|
long DEFAULT_PERIODIC_ACTION2_PERIOD = 90 * 1000;
|
||||||
long DEFAULT_PERIODIC_ACTION4_PERIOD = 90 * 1000;
|
long DEFAULT_PERIODIC_ACTION4_PERIOD = 90 * 1000;
|
||||||
|
|
Loading…
Reference in New Issue