Search in sources :

Example 16 with ComponentProcess

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

the class StormServiceRegistrar method createStormUIServerComponent.

private Pair<Component, List<ComponentProcess>> createStormUIServerComponent(Config config, Map<String, String> flattenConfigMap) {
    if (!config.contains(PARAM_UI_HOST)) {
        throw new IllegalArgumentException("Required parameter " + PARAM_UI_HOST + " not present.");
    }
    if (!config.contains(PARAM_UI_PORT)) {
        throw new IllegalArgumentException("Required parameter " + PARAM_UI_PORT + " not present.");
    }
    String stormUiServerHost;
    try {
        stormUiServerHost = config.getString(PARAM_UI_HOST);
    } catch (ClassCastException e) {
        throw new IllegalArgumentException("Required parameter " + PARAM_UI_HOST + " should be a string.");
    }
    Number stormUiServerPort = readNumberFromConfig(config, PARAM_UI_PORT);
    Component stormUiServer = new Component();
    stormUiServer.setName(COMPONENT_STORM_UI_SERVER);
    ComponentProcess uiProcess = new ComponentProcess();
    uiProcess.setHost(stormUiServerHost);
    uiProcess.setPort(stormUiServerPort.intValue());
    return new Pair<>(stormUiServer, Collections.singletonList(uiProcess));
}
Also used : Component(com.hortonworks.streamline.streams.cluster.catalog.Component) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess) Pair(org.apache.commons.math3.util.Pair)

Example 17 with ComponentProcess

use of com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess 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)

Example 18 with ComponentProcess

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

the class KafkaServiceRegistrarTest method testRegister.

@Test
public void testRegister() 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, "SASL_PLAINTEXT://kafka-1:6668,PLAINTEXT://kafka-2:6669,SSL://kafka-3:6670,SASL_SSL://kafka-4:6671");
    config.put(KafkaServiceRegistrar.PARAM_SECURITY_INTER_BROKER_PROTOCOL, "SSL");
    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());
    // we have 4 component processes according to listener
    assertEquals(4, brokerProcesses.size());
    assertTrue(brokerProcesses.stream().anyMatch(p -> p.getHost().equals("kafka-1") && p.getPort().equals(6668) && p.getProtocol().equals("SASL_PLAINTEXT")));
    assertTrue(brokerProcesses.stream().anyMatch(p -> p.getHost().equals("kafka-2") && p.getPort().equals(6669) && p.getProtocol().equals("PLAINTEXT")));
    assertTrue(brokerProcesses.stream().anyMatch(p -> p.getHost().equals("kafka-3") && p.getPort().equals(6670) && p.getProtocol().equals("SSL")));
    assertTrue(brokerProcesses.stream().anyMatch(p -> p.getHost().equals("kafka-4") && p.getPort().equals(6671) && p.getProtocol().equals("SASL_SSL")));
    ServiceConfiguration serverPropertiesConf = environmentService.getServiceConfigurationByName(kafkaService.getId(), CONFIGURATION_NAME_SERVER_PROPERTIES);
    assertNotNull(serverPropertiesConf);
    Map<String, String> serverPropertiesConfMap = serverPropertiesConf.getConfigurationMap();
    assertEquals(config.get(KafkaServiceRegistrar.PARAM_SECURITY_INTER_BROKER_PROTOCOL), serverPropertiesConfMap.get(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)

Example 19 with ComponentProcess

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

the class ZookeeperMetadataService method getZookeeperServers.

public List<HostPort> getZookeeperServers() throws ServiceNotFoundException, ServiceComponentNotFoundException {
    final Long serviceId = environmentService.getServiceIdByName(clusterId, STREAMS_JSON_SCHEMA_SERVICE_ZOOKEEPER);
    if (serviceId == null) {
        throw new ServiceNotFoundException(clusterId, ServiceConfigurations.ZOOKEEPER.name());
    }
    final Component zookeeperServer = environmentService.getComponentByName(serviceId, STREAMS_JSON_SCHEMA_COMPONENT_ZOOKEEPER_SERVER);
    if (zookeeperServer == null) {
        throw new ServiceComponentNotFoundException(clusterId, ServiceConfigurations.STORM.name(), ComponentPropertyPattern.ZOOKEEPER_SERVER.name());
    }
    final Collection<ComponentProcess> zookeeperServers = environmentService.listComponentProcesses(zookeeperServer.getId());
    return zookeeperServers.stream().map(cp -> new HostPort(cp.getHost(), cp.getPort())).collect(Collectors.toList());
}
Also used : ServiceComponentNotFoundException(com.hortonworks.streamline.streams.cluster.exception.ServiceComponentNotFoundException) EnvironmentService(com.hortonworks.streamline.streams.cluster.service.EnvironmentService) ComponentPropertyPattern(com.hortonworks.streamline.streams.cluster.discovery.ambari.ComponentPropertyPattern) List(java.util.List) ServiceConfigurations(com.hortonworks.streamline.streams.cluster.discovery.ambari.ServiceConfigurations) Collection(java.util.Collection) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) HostPort(com.hortonworks.streamline.streams.cluster.service.metadata.common.HostPort) ServiceNotFoundException(com.hortonworks.streamline.streams.cluster.exception.ServiceNotFoundException) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess) Collectors(java.util.stream.Collectors) ServiceComponentNotFoundException(com.hortonworks.streamline.streams.cluster.exception.ServiceComponentNotFoundException) ServiceNotFoundException(com.hortonworks.streamline.streams.cluster.exception.ServiceNotFoundException) HostPort(com.hortonworks.streamline.streams.cluster.service.metadata.common.HostPort) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess)

Example 20 with ComponentProcess

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

the class StormMetadataServiceTest method buildUiComponentProcesses.

private List<ComponentProcess> buildUiComponentProcesses() {
    ComponentProcess ui = new ComponentProcess();
    ui.setHost("localhost");
    ui.setPort(8080);
    return Collections.singletonList(ui);
}
Also used : ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess)

Aggregations

ComponentProcess (com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess)22 Component (com.hortonworks.streamline.streams.cluster.catalog.Component)15 Service (com.hortonworks.streamline.streams.cluster.catalog.Service)8 ServiceConfiguration (com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration)8 Config (com.hortonworks.streamline.common.Config)7 ComponentPropertyPattern (com.hortonworks.streamline.streams.cluster.discovery.ambari.ComponentPropertyPattern)7 HashMap (java.util.HashMap)6 Map (java.util.Map)6 Constants (com.hortonworks.streamline.streams.cluster.Constants)5 EnvironmentService (com.hortonworks.streamline.streams.cluster.service.EnvironmentService)5 List (java.util.List)5 Cluster (com.hortonworks.streamline.streams.cluster.catalog.Cluster)4 ServiceConfigurations (com.hortonworks.streamline.streams.cluster.discovery.ambari.ServiceConfigurations)4 Collections (java.util.Collections)4 Pair (org.apache.commons.math3.util.Pair)4 Test (org.junit.Test)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Collection (java.util.Collection)3 Collectors.toList (java.util.stream.Collectors.toList)3