Search in sources :

Example 21 with Config

use of com.hortonworks.streamline.common.Config in project streamline by hortonworks.

the class KafkaServiceRegistrar method createKafkaBrokerComponent.

private Pair<Component, List<ComponentProcess>> createKafkaBrokerComponent(Config config, Map<String, String> flattenConfigMap) {
    if (!config.contains(PARAM_LISTENERS)) {
        throw new IllegalArgumentException("Required parameter " + PARAM_LISTENERS + " not present.");
    }
    Map<String, String> confMap = new HashMap<>();
    confMap.put(PARAM_LISTENERS, config.getString(PARAM_LISTENERS));
    Component kafkaBroker = new Component();
    kafkaBroker.setName(COMPONENT_KAFKA_BROKER);
    List<KafkaBrokerListeners.ListenersPropEntry> parsedProps = new KafkaBrokerListeners.ListenersPropParsed(confMap).getParsedProps();
    List<ComponentProcess> componentProcesses = parsedProps.stream().map(propEntry -> {
        ComponentProcess cp = new ComponentProcess();
        cp.setHost(propEntry.getHost());
        cp.setPort(propEntry.getPort());
        cp.setProtocol(propEntry.getProtocol().name());
        return cp;
    }).collect(toList());
    return new Pair<>(kafkaBroker, componentProcesses);
}
Also used : Config(com.hortonworks.streamline.common.Config) ComponentPropertyPattern(com.hortonworks.streamline.streams.cluster.discovery.ambari.ComponentPropertyPattern) Pair(org.apache.commons.math3.util.Pair) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) HashMap(java.util.HashMap) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess) Constants(com.hortonworks.streamline.streams.cluster.Constants) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Lists(com.google.common.collect.Lists) ServiceConfigurations(com.hortonworks.streamline.streams.cluster.discovery.ambari.ServiceConfigurations) KafkaBrokerListeners(com.hortonworks.streamline.streams.cluster.service.metadata.json.KafkaBrokerListeners) ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) Map(java.util.Map) HashMap(java.util.HashMap) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess) KafkaBrokerListeners(com.hortonworks.streamline.streams.cluster.service.metadata.json.KafkaBrokerListeners) Pair(org.apache.commons.math3.util.Pair)

Example 22 with Config

use of com.hortonworks.streamline.common.Config in project streamline by hortonworks.

the class StormServiceRegistrar method createNimbusComponent.

private Pair<Component, List<ComponentProcess>> createNimbusComponent(Config config, Map<String, String> flatConfigMap) {
    if (!config.contains(PARAM_NIMBUS_SEEDS)) {
        throw new IllegalArgumentException("Required parameter " + PARAM_NIMBUS_SEEDS + " not present.");
    }
    if (!config.contains(PARAM_NIMBUS_THRIFT_PORT)) {
        throw new IllegalArgumentException("Required parameter " + PARAM_NIMBUS_THRIFT_PORT + " not present.");
    }
    String nimbusSeeds;
    try {
        nimbusSeeds = config.getString(PARAM_NIMBUS_SEEDS);
    } catch (ClassCastException e) {
        throw new IllegalArgumentException("Required parameter " + PARAM_NIMBUS_SEEDS + " should be a string.");
    }
    Number nimbusThriftPort = readNumberFromConfig(config, PARAM_NIMBUS_THRIFT_PORT);
    Component nimbus = new Component();
    nimbus.setName(COMPONENT_NIMBUS);
    List<ComponentProcess> componentProcesses = Arrays.stream(nimbusSeeds.split(",")).map(nimbusHost -> {
        ComponentProcess cp = new ComponentProcess();
        cp.setHost(nimbusHost);
        cp.setPort(nimbusThriftPort.intValue());
        return cp;
    }).collect(toList());
    return new Pair<>(nimbus, componentProcesses);
}
Also used : Config(com.hortonworks.streamline.common.Config) ComponentPropertyPattern(com.hortonworks.streamline.streams.cluster.discovery.ambari.ComponentPropertyPattern) Arrays(java.util.Arrays) Pair(org.apache.commons.math3.util.Pair) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) HashMap(java.util.HashMap) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess) Constants(com.hortonworks.streamline.streams.cluster.Constants) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Lists(com.google.common.collect.Lists) ServiceConfigurations(com.hortonworks.streamline.streams.cluster.discovery.ambari.ServiceConfigurations) ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) Map(java.util.Map) Collections(java.util.Collections) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess) Pair(org.apache.commons.math3.util.Pair)

Example 23 with Config

use of com.hortonworks.streamline.common.Config 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 24 with Config

use of com.hortonworks.streamline.common.Config 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 25 with Config

use of com.hortonworks.streamline.common.Config 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)

Aggregations

Config (com.hortonworks.streamline.common.Config)41 Cluster (com.hortonworks.streamline.streams.cluster.catalog.Cluster)25 Service (com.hortonworks.streamline.streams.cluster.catalog.Service)25 Test (org.junit.Test)24 ServiceConfiguration (com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration)15 ManualServiceRegistrar (com.hortonworks.streamline.streams.cluster.register.ManualServiceRegistrar)9 InputStream (java.io.InputStream)9 Component (com.hortonworks.streamline.streams.cluster.catalog.Component)8 Map (java.util.Map)8 ComponentProcess (com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 Constants (com.hortonworks.streamline.streams.cluster.Constants)5 ComponentPropertyPattern (com.hortonworks.streamline.streams.cluster.discovery.ambari.ComponentPropertyPattern)5 Collections (java.util.Collections)5 List (java.util.List)4 Collectors.toList (java.util.stream.Collectors.toList)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 ServiceConfigurations (com.hortonworks.streamline.streams.cluster.discovery.ambari.ServiceConfigurations)3 Stream (com.hortonworks.streamline.streams.layout.component.Stream)3 HashMap (java.util.HashMap)3