Search in sources :

Example 31 with Cluster

use of com.hortonworks.streamline.streams.cluster.catalog.Cluster in project streamline by hortonworks.

the class HBaseServiceRegistrarTest method testRegister.

@Test
public void testRegister() throws Exception {
    Cluster cluster = getTestCluster(1L);
    HBaseServiceRegistrar registrar = initializeServiceRegistrar();
    try (InputStream is = getClass().getClassLoader().getResourceAsStream(HBASE_SITE_XML_FILE_PATH)) {
        ManualServiceRegistrar.ConfigFileInfo hiveSiteXml = new ManualServiceRegistrar.ConfigFileInfo(HBASE_SITE_XML, is);
        registrar.register(cluster, new Config(), Lists.newArrayList(hiveSiteXml));
    }
    Service hbaseService = environmentService.getServiceByName(cluster.getId(), Constants.HBase.SERVICE_NAME);
    assertNotNull(hbaseService);
    ServiceConfiguration hbaseSiteConf = environmentService.getServiceConfigurationByName(hbaseService.getId(), CONFIGURATION_NAME_HBASE_SITE);
    assertNotNull(hbaseSiteConf);
}
Also used : ManualServiceRegistrar(com.hortonworks.streamline.streams.cluster.register.ManualServiceRegistrar) ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) InputStream(java.io.InputStream) Config(com.hortonworks.streamline.common.Config) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) Service(com.hortonworks.streamline.streams.cluster.catalog.Service) Test(org.junit.Test)

Example 32 with Cluster

use of com.hortonworks.streamline.streams.cluster.catalog.Cluster in project streamline by hortonworks.

the class HBaseServiceRegistrarTest method testRegister_requiredPropertyNotPresent.

@Test
public void testRegister_requiredPropertyNotPresent() throws Exception {
    Cluster cluster = getTestCluster(1L);
    HBaseServiceRegistrar registrar = initializeServiceRegistrar();
    try (InputStream is = getClass().getClassLoader().getResourceAsStream(HBASE_SITE_XML_BADCASE_FILE_PATH)) {
        ManualServiceRegistrar.ConfigFileInfo hbaseSiteXml = new ManualServiceRegistrar.ConfigFileInfo(HBASE_SITE_XML, is);
        registrar.register(cluster, new Config(), Lists.newArrayList(hbaseSiteXml));
        fail("Should throw IllegalArgumentException");
    } catch (IllegalArgumentException e) {
        // OK
        Service hbaseService = environmentService.getServiceByName(cluster.getId(), Constants.HBase.SERVICE_NAME);
        assertNull(hbaseService);
    }
}
Also used : ManualServiceRegistrar(com.hortonworks.streamline.streams.cluster.register.ManualServiceRegistrar) InputStream(java.io.InputStream) Config(com.hortonworks.streamline.common.Config) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) Service(com.hortonworks.streamline.streams.cluster.catalog.Service) Test(org.junit.Test)

Example 33 with Cluster

use of com.hortonworks.streamline.streams.cluster.catalog.Cluster in project streamline by hortonworks.

the class HDFSServiceRegistrarTest method testRegister_hdfs_site_xml_notPresent.

@Test
public void testRegister_hdfs_site_xml_notPresent() throws Exception {
    Cluster cluster = getTestCluster(1L);
    HDFSServiceRegistrar registrar = initializeServiceRegistrar();
    try (InputStream is = getClass().getClassLoader().getResourceAsStream(CORE_SITE_XML_FILE_PATH)) {
        ManualServiceRegistrar.ConfigFileInfo coreSiteXml = new ManualServiceRegistrar.ConfigFileInfo(CORE_SITE_XML, is);
        registrar.register(cluster, new Config(), Lists.newArrayList(coreSiteXml));
        fail("Should throw IllegalArgumentException");
    } catch (IllegalArgumentException e) {
        // OK
        Service hdfsService = environmentService.getServiceByName(cluster.getId(), Constants.HDFS.SERVICE_NAME);
        assertNull(hdfsService);
    }
}
Also used : ManualServiceRegistrar(com.hortonworks.streamline.streams.cluster.register.ManualServiceRegistrar) InputStream(java.io.InputStream) Config(com.hortonworks.streamline.common.Config) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) Service(com.hortonworks.streamline.streams.cluster.catalog.Service) Test(org.junit.Test)

Example 34 with Cluster

use of com.hortonworks.streamline.streams.cluster.catalog.Cluster in project streamline by hortonworks.

the class HDFSServiceRegistrarTest method testRegister.

@Test
public void testRegister() throws Exception {
    Cluster cluster = getTestCluster(1L);
    HDFSServiceRegistrar registrar = initializeServiceRegistrar();
    try (InputStream coreSiteIs = getClass().getClassLoader().getResourceAsStream(CORE_SITE_XML_FILE_PATH);
        InputStream hdfsSiteIs = getClass().getClassLoader().getResourceAsStream(HDFS_SITE_XML_FILE_PATH)) {
        ManualServiceRegistrar.ConfigFileInfo coreSiteXml = new ManualServiceRegistrar.ConfigFileInfo(CORE_SITE_XML, coreSiteIs);
        ManualServiceRegistrar.ConfigFileInfo hdfsSiteXml = new ManualServiceRegistrar.ConfigFileInfo(HDFS_SITE_XML, hdfsSiteIs);
        registrar.register(cluster, new Config(), Lists.newArrayList(coreSiteXml, hdfsSiteXml));
    }
    Service hdfsService = environmentService.getServiceByName(cluster.getId(), Constants.HDFS.SERVICE_NAME);
    assertNotNull(hdfsService);
    ServiceConfiguration coreSiteConf = environmentService.getServiceConfigurationByName(hdfsService.getId(), CONFIGURATION_NAME_CORE_SITE);
    assertNotNull(coreSiteConf);
    ServiceConfiguration hdfsSiteConf = environmentService.getServiceConfigurationByName(hdfsService.getId(), CONFIGURATION_NAME_HDFS_SITE);
    assertNotNull(hdfsSiteConf);
}
Also used : ManualServiceRegistrar(com.hortonworks.streamline.streams.cluster.register.ManualServiceRegistrar) ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) InputStream(java.io.InputStream) Config(com.hortonworks.streamline.common.Config) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) Service(com.hortonworks.streamline.streams.cluster.catalog.Service) Test(org.junit.Test)

Example 35 with Cluster

use of com.hortonworks.streamline.streams.cluster.catalog.Cluster in project streamline by hortonworks.

the class KafkaServiceRegistrarTest method testRegisterWithoutOptionalParams.

@Test
public void testRegisterWithoutOptionalParams() throws Exception {
    Cluster cluster = getTestCluster(1L);
    KafkaServiceRegistrar registrar = initializeServiceRegistrar();
    Config config = new Config();
    config.put(KafkaServiceRegistrar.PARAM_ZOOKEEPER_CONNECT, "zookeeper-1:2181,zookeeper-2:2181,zookeeper-3:2181");
    config.put(KafkaServiceRegistrar.PARAM_LISTENERS, "PLAINTEXT://kafka-1:9092");
    registrar.register(cluster, config, Collections.emptyList());
    Service kafkaService = environmentService.getServiceByName(cluster.getId(), Constants.Kafka.SERVICE_NAME);
    assertNotNull(kafkaService);
    Component broker = environmentService.getComponentByName(kafkaService.getId(), ComponentPropertyPattern.KAFKA_BROKER.name());
    assertNotNull(broker);
    Collection<ComponentProcess> brokerProcesses = environmentService.listComponentProcesses(broker.getId());
    assertEquals(1, brokerProcesses.size());
    assertTrue(brokerProcesses.stream().anyMatch(p -> p.getHost().equals("kafka-1") && p.getPort().equals(9092) && p.getProtocol().equals("PLAINTEXT")));
    ServiceConfiguration serverPropertiesConf = environmentService.getServiceConfigurationByName(kafkaService.getId(), CONFIGURATION_NAME_SERVER_PROPERTIES);
    assertNotNull(serverPropertiesConf);
    Map<String, String> serverPropertiesConfMap = serverPropertiesConf.getConfigurationMap();
    assertFalse(serverPropertiesConfMap.containsKey(KafkaServiceRegistrar.PARAM_SECURITY_INTER_BROKER_PROTOCOL));
}
Also used : Config(com.hortonworks.streamline.common.Config) ComponentPropertyPattern(com.hortonworks.streamline.streams.cluster.discovery.ambari.ComponentPropertyPattern) Collection(java.util.Collection) Test(org.junit.Test) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess) Constants(com.hortonworks.streamline.streams.cluster.Constants) Service(com.hortonworks.streamline.streams.cluster.catalog.Service) ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) Map(java.util.Map) Assert(org.junit.Assert) Collections(java.util.Collections) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) Before(org.junit.Before) ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) Config(com.hortonworks.streamline.common.Config) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) Service(com.hortonworks.streamline.streams.cluster.catalog.Service) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess) Test(org.junit.Test)

Aggregations

Cluster (com.hortonworks.streamline.streams.cluster.catalog.Cluster)49 Service (com.hortonworks.streamline.streams.cluster.catalog.Service)31 Test (org.junit.Test)30 Config (com.hortonworks.streamline.common.Config)25 ServiceConfiguration (com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration)15 ManualServiceRegistrar (com.hortonworks.streamline.streams.cluster.register.ManualServiceRegistrar)9 InputStream (java.io.InputStream)9 Timed (com.codahale.metrics.annotation.Timed)8 EnvironmentService (com.hortonworks.streamline.streams.cluster.service.EnvironmentService)8 Path (javax.ws.rs.Path)8 Expectations (mockit.Expectations)8 NamespaceServiceClusterMap (com.hortonworks.streamline.streams.cluster.catalog.NamespaceServiceClusterMap)7 Component (com.hortonworks.streamline.streams.cluster.catalog.Component)6 HashMap (java.util.HashMap)5 ComponentProcess (com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess)4 Collection (java.util.Collection)4 Collections (java.util.Collections)4 Map (java.util.Map)4 POST (javax.ws.rs.POST)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3