Search in sources :

Example 1 with ServiceFactory

use of org.apache.whirr.service.ServiceFactory in project whirr by apache.

the class ClusterSpecCommandTest method testOverrides.

@Test
public void testOverrides() throws Exception {
    ClusterSpecCommand clusterSpecCommand = new ClusterSpecCommand("name", "description", new ServiceFactory()) {

        @Override
        public int run(InputStream in, PrintStream out, PrintStream err, List<String> args) throws Exception {
            return 0;
        }
    };
    OptionSet optionSet = clusterSpecCommand.parser.parse("--service-name", "overridden-test-service", "--config", "whirr-override-test.properties");
    ClusterSpec clusterSpec = clusterSpecCommand.getClusterSpec(optionSet);
    assertThat(clusterSpec.getServiceName(), is("overridden-test-service"));
    assertThat(clusterSpec.getClusterName(), is("test-cluster"));
}
Also used : PrintStream(java.io.PrintStream) ServiceFactory(org.apache.whirr.service.ServiceFactory) InputStream(java.io.InputStream) List(java.util.List) ClusterSpec(org.apache.whirr.service.ClusterSpec) OptionSet(joptsimple.OptionSet) Test(org.junit.Test)

Example 2 with ServiceFactory

use of org.apache.whirr.service.ServiceFactory in project whirr by apache.

the class HadoopServiceTest method setUp.

@Before
public void setUp() throws ConfigurationException, IOException {
    CompositeConfiguration config = new CompositeConfiguration();
    if (System.getProperty("config") != null) {
        config.addConfiguration(new PropertiesConfiguration(System.getProperty("config")));
    }
    config.addConfiguration(new PropertiesConfiguration("whirr-hadoop-test.properties"));
    clusterSpec = ClusterSpec.fromConfiguration(config);
    Service s = new ServiceFactory().create(clusterSpec.getServiceName());
    assertThat(s, instanceOf(HadoopService.class));
    service = (HadoopService) s;
    cluster = service.launchCluster(clusterSpec);
    proxy = new HadoopProxy(clusterSpec, cluster);
    proxy.start();
}
Also used : HadoopService(org.apache.whirr.service.hadoop.HadoopService) ServiceFactory(org.apache.whirr.service.ServiceFactory) CompositeConfiguration(org.apache.commons.configuration.CompositeConfiguration) HadoopService(org.apache.whirr.service.hadoop.HadoopService) Service(org.apache.whirr.service.Service) HadoopProxy(org.apache.whirr.service.hadoop.HadoopProxy) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) Before(org.junit.Before)

Aggregations

ServiceFactory (org.apache.whirr.service.ServiceFactory)2 InputStream (java.io.InputStream)1 PrintStream (java.io.PrintStream)1 List (java.util.List)1 OptionSet (joptsimple.OptionSet)1 CompositeConfiguration (org.apache.commons.configuration.CompositeConfiguration)1 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)1 ClusterSpec (org.apache.whirr.service.ClusterSpec)1 Service (org.apache.whirr.service.Service)1 HadoopProxy (org.apache.whirr.service.hadoop.HadoopProxy)1 HadoopService (org.apache.whirr.service.hadoop.HadoopService)1 Before (org.junit.Before)1 Test (org.junit.Test)1