use of org.apache.commons.configuration.CompositeConfiguration in project whirr by apache.
the class ChefServiceTest method setUp.
// private static Cluster cluster;
@BeforeClass
public static void setUp() throws Exception {
CompositeConfiguration config = new CompositeConfiguration();
if (System.getProperty("config") != null) {
config.addConfiguration(new PropertiesConfiguration(System.getProperty("config")));
}
config.addConfiguration(new PropertiesConfiguration("whirr-chef-test.properties"));
clusterSpec = ClusterSpec.withTemporaryKeys(config);
controller = new ClusterController();
controller.launchCluster(clusterSpec);
}
use of org.apache.commons.configuration.CompositeConfiguration in project whirr by apache.
the class BootstrapClusterActionTest method testDoActionRetriesSucceed.
@SuppressWarnings("unchecked")
@Test
public void testDoActionRetriesSucceed() throws Exception {
CompositeConfiguration config = new CompositeConfiguration();
if (System.getProperty("config") != null) {
config.addConfiguration(new PropertiesConfiguration(System.getProperty("config")));
}
Configuration conf = new PropertiesConfiguration();
conf.addProperty("whirr.service-name", "test-service");
conf.addProperty("whirr.cluster-name", "test-cluster");
conf.addProperty("whirr.instance-templates", "1 hadoop-namenode+hadoop-jobtracker,4 hadoop-datanode+hadoop-tasktracker");
conf.addProperty("whirr.instance-templates-max-percent-failures", "60 hadoop-datanode+hadoop-tasktracker");
conf.addProperty("whirr.provider", "ec2");
config.addConfiguration(conf);
ClusterSpec clusterSpec = ClusterSpec.withTemporaryKeys(conf);
Set<String> jtnn = new HashSet<String>();
jtnn.add("hadoop-jobtracker");
jtnn.add("hadoop-namenode");
Set<String> dntt = new HashSet<String>();
dntt.add("hadoop-datanode");
dntt.add("hadoop-tasktracker");
TestNodeStarterFactory nodeStarterFactory = null;
ClusterActionHandler handler = mock(ClusterActionHandler.class);
LoadingCache<String, ClusterActionHandler> handlerMap = convertMapToLoadingCache(ImmutableMap.<String, ClusterActionHandler>builder().put("hadoop-jobtracker", handler).put("hadoop-namenode", handler).put("hadoop-datanode", handler).put("hadoop-tasktracker", handler).build());
Function<ClusterSpec, ComputeServiceContext> getCompute = mock(Function.class);
ComputeServiceContext serviceContext = mock(ComputeServiceContext.class);
ComputeService computeService = mock(ComputeService.class);
TemplateBuilder templateBuilder = mock(TemplateBuilder.class);
Template template = mock(Template.class);
TemplateOptions templateOptions = mock(TemplateOptions.class);
when(getCompute.apply(clusterSpec)).thenReturn(serviceContext);
when(serviceContext.getComputeService()).thenReturn(computeService);
when(computeService.getContext()).thenReturn(serviceContext);
when(serviceContext.getBackendType()).thenReturn(TypeToken.class.cast(TypeToken.of(Context.class)));
when(computeService.templateBuilder()).thenReturn(templateBuilder);
when(templateBuilder.from((TemplateBuilderSpec) any())).thenReturn(templateBuilder);
when(templateBuilder.options((TemplateOptions) any())).thenReturn(templateBuilder);
when(templateBuilder.build()).thenReturn(template);
when(template.getOptions()).thenReturn(templateOptions);
// here is a scenario when jt+nn fails once, then the retry is successful
// and from the dn+tt one node fails, then the retry is successful
Map<Set<String>, Stack<Integer>> reaction = Maps.newHashMap();
Stack<Integer> jtnnStack = new Stack<Integer>();
// then ok
jtnnStack.push(1);
// initially fail
jtnnStack.push(0);
reaction.put(jtnn, jtnnStack);
Stack<Integer> ddttStack = new Stack<Integer>();
// 3 from 4, just enough
ddttStack.push(3);
reaction.put(dntt, ddttStack);
nodeStarterFactory = new TestNodeStarterFactory(reaction);
BootstrapClusterAction bootstrapper = new BootstrapClusterAction(getCompute, handlerMap, nodeStarterFactory);
bootstrapper.execute(clusterSpec, null);
if (nodeStarterFactory != null) {
nodeStarterFactory.validateCompletion();
}
}
use of org.apache.commons.configuration.CompositeConfiguration in project whirr by apache.
the class BootstrapClusterActionTest method testDoActionRetriesExceeds.
@SuppressWarnings("unchecked")
@Test(expected = IOException.class)
public void testDoActionRetriesExceeds() throws Exception {
CompositeConfiguration config = new CompositeConfiguration();
if (System.getProperty("config") != null) {
config.addConfiguration(new PropertiesConfiguration(System.getProperty("config")));
}
Configuration conf = new PropertiesConfiguration();
conf.addProperty("whirr.service-name", "test-service");
conf.addProperty("whirr.cluster-name", "test-cluster");
conf.addProperty("whirr.instance-templates", "1 hadoop-namenode+hadoop-jobtracker,4 hadoop-datanode+hadoop-tasktracker");
conf.addProperty("whirr.instance-templates-max-percent-failures", "60 hadoop-datanode+hadoop-tasktracker");
conf.addProperty("whirr.provider", "ec2");
config.addConfiguration(conf);
ClusterSpec clusterSpec = ClusterSpec.withTemporaryKeys(conf);
Set<String> jtnn = new HashSet<String>();
jtnn.add("hadoop-jobtracker");
jtnn.add("hadoop-namenode");
Set<String> dntt = new HashSet<String>();
dntt.add("hadoop-datanode");
dntt.add("hadoop-tasktracker");
TestNodeStarterFactory nodeStarterFactory = null;
ClusterActionHandler handler = mock(ClusterActionHandler.class);
LoadingCache<String, ClusterActionHandler> handlerMap = convertMapToLoadingCache(ImmutableMap.<String, ClusterActionHandler>builder().put("hadoop-jobtracker", handler).put("hadoop-namenode", handler).put("hadoop-datanode", handler).put("hadoop-tasktracker", handler).build());
Function<ClusterSpec, ComputeServiceContext> getCompute = mock(Function.class);
ComputeServiceContext serviceContext = mock(ComputeServiceContext.class);
ComputeService computeService = mock(ComputeService.class);
TemplateBuilder templateBuilder = mock(TemplateBuilder.class);
Template template = mock(Template.class);
TemplateOptions templateOptions = mock(TemplateOptions.class);
when(getCompute.apply(clusterSpec)).thenReturn(serviceContext);
when(serviceContext.getComputeService()).thenReturn(computeService);
when(computeService.getContext()).thenReturn(serviceContext);
when(serviceContext.getBackendType()).thenReturn(TypeToken.class.cast(TypeToken.of(Context.class)));
when(computeService.templateBuilder()).thenReturn(templateBuilder);
when(templateBuilder.from((TemplateBuilderSpec) any())).thenReturn(templateBuilder);
when(templateBuilder.options((TemplateOptions) any())).thenReturn(templateBuilder);
when(templateBuilder.build()).thenReturn(template);
when(template.getOptions()).thenReturn(templateOptions);
// here is a scenario when jt+nn does not fail
// but the dn+tt one node fails 3, then in the retry fails 2
// at the end result, the cluster will fail, throwing IOException
Map<Set<String>, Stack<Integer>> reaction = Maps.newHashMap();
Stack<Integer> jtnnStack = new Stack<Integer>();
jtnnStack.push(new Integer(1));
reaction.put(jtnn, jtnnStack);
Stack<Integer> ddttStack = new Stack<Integer>();
// 1 from 4, retryRequired
ddttStack.push(new Integer(1));
// 1 from 4, still retryRequired
ddttStack.push(new Integer(1));
reaction.put(dntt, ddttStack);
nodeStarterFactory = new TestNodeStarterFactory(reaction);
BootstrapClusterAction bootstrapper = new BootstrapClusterAction(getCompute, handlerMap, nodeStarterFactory);
// this should file with too many retries
bootstrapper.execute(clusterSpec, null);
if (nodeStarterFactory != null) {
nodeStarterFactory.validateCompletion();
}
}
use of org.apache.commons.configuration.CompositeConfiguration in project wcomponents by BorderTech.
the class StandaloneLauncher method main.
/**
* The entry point when the launcher is run as a java application.
*
* @param args command-line arguments, ignored.
* @throws Exception on error
*/
public static void main(final String[] args) throws Exception {
// Set the logger to use the text area logger
System.setProperty("org.apache.commons.logging.Log", "com.github.bordertech.wcomponents.lde.StandaloneLauncher$TextAreaLogger");
// Set the port number to a random port
Configuration internalWComponentConfig = Config.getInstance();
CompositeConfiguration config = new CompositeConfiguration(new MapConfiguration(new HashMap<String, Object>()));
// Internal WComponent config next
config.addConfiguration(internalWComponentConfig);
config.setProperty(ConfigurationProperties.LDE_SERVER_PORT, 0);
Config.setConfiguration(config);
getInstance().launcher.run();
getInstance().log("LDE now running on " + getInstance().launcher.getUrl() + '\n');
}
use of org.apache.commons.configuration.CompositeConfiguration in project wcomponents by BorderTech.
the class ValidateXMLInterceptor_Test method setUp.
@BeforeClass
public static void setUp() {
originalConfig = Config.getInstance();
CompositeConfiguration config = new CompositeConfiguration(originalConfig);
MapConfiguration overrides = new MapConfiguration(new HashMap<String, Object>());
overrides.setProperty(ConfigurationProperties.DEVELOPER_DEBUG_ENABLED, "true");
overrides.setProperty(ConfigurationProperties.DEVELOPER_VALIDATE_XML, "true");
config.addConfiguration(overrides);
Config.setConfiguration(config);
}
Aggregations