Search in sources :

Example 6 with ComponentProcess

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

the class ZookeeperServiceRegistrar method validateComponents.

@Override
protected boolean validateComponents(Map<Component, List<ComponentProcess>> components) {
    // 1. ZOOKEEPER_SERVER should be available, and it should have one or more hosts and one port
    return components.entrySet().stream().anyMatch(componentEntry -> {
        Component component = componentEntry.getKey();
        List<ComponentProcess> componentProcesses = componentEntry.getValue();
        if (component.getName().equals(ZOOKEEPER_SERVER.name())) {
            return isComponentProcessesValid(componentProcesses);
        }
        return false;
    });
}
Also used : Component(com.hortonworks.streamline.streams.cluster.catalog.Component) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess)

Example 7 with ComponentProcess

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

the class ZookeeperServiceRegistrar method createZookeeperServerComponent.

private Pair<Component, List<ComponentProcess>> createZookeeperServerComponent(Config config, Map<String, String> flattenConfigMap) {
    if (!config.contains(PARAM_ZOOKEEPER_SERVER_HOSTNAMES)) {
        throw new IllegalArgumentException("Required parameter " + PARAM_ZOOKEEPER_SERVER_HOSTNAMES + " not present.");
    }
    if (!config.contains(PARAM_ZOOKEEPER_PORT)) {
        throw new IllegalArgumentException("Required parameter " + PARAM_ZOOKEEPER_PORT + " not present.");
    }
    List<String> zookeeperServerHosts;
    try {
        zookeeperServerHosts = config.getAny(PARAM_ZOOKEEPER_SERVER_HOSTNAMES);
    } catch (ClassCastException e) {
        throw new IllegalArgumentException("Required parameter " + PARAM_ZOOKEEPER_SERVER_HOSTNAMES + " should be list of string.");
    }
    Number zookeeperPort;
    try {
        zookeeperPort = config.getAny(PARAM_ZOOKEEPER_PORT);
    } catch (ClassCastException e) {
        throw new IllegalArgumentException("Required parameter " + PARAM_ZOOKEEPER_PORT + " should be number.");
    }
    Component zookeeperServer = new Component();
    zookeeperServer.setName(COMPONENT_ZOOKEEPER_SERVER);
    List<ComponentProcess> componentProcesses = zookeeperServerHosts.stream().map(host -> {
        ComponentProcess cp = new ComponentProcess();
        cp.setHost(host);
        cp.setPort(zookeeperPort.intValue());
        return cp;
    }).collect(toList());
    return new Pair<>(zookeeperServer, 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) ZOOKEEPER_SERVER(com.hortonworks.streamline.streams.cluster.discovery.ambari.ComponentPropertyPattern.ZOOKEEPER_SERVER) 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) 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 8 with ComponentProcess

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

the class StormServiceRegistrarTest method testRegister.

@Test
public void testRegister() throws Exception {
    Cluster cluster = getTestCluster(1L);
    StormServiceRegistrar registrar = initializeServiceRegistrar();
    // explicit convert Object
    Config config = new Config();
    config.put(StormServiceRegistrar.PARAM_NIMBUS_SEEDS, "storm-1,storm-2");
    config.put(StormServiceRegistrar.PARAM_NIMBUS_THRIFT_PORT, (Object) 6627);
    config.put(StormServiceRegistrar.PARAM_UI_HOST, "storm-1");
    config.put(StormServiceRegistrar.PARAM_UI_PORT, (Object) 8080);
    config.put(StormServiceRegistrar.PARAM_NIMBUS_THRIFT_MAX_BUFFER_SIZE, (Object) 102476800);
    config.put(StormServiceRegistrar.PARAM_THRIFT_TRANSPORT, "org.apache.storm.security.auth.SimpleTransportPlugin");
    config.put(StormServiceRegistrar.PARAM_PRINCIPAL_TO_LOCAL, "org.apache.storm.security.auth.DefaultPrincipalToLocal");
    config.put(StormServiceRegistrar.PARAM_NIMBUS_PRINCIPAL_NAME, "nimbus/_HOST@EXAMPLE.COM");
    registrar.register(cluster, config, Collections.emptyList());
    Service stormService = environmentService.getServiceByName(cluster.getId(), Constants.Storm.SERVICE_NAME);
    assertNotNull(stormService);
    Component nimbus = environmentService.getComponentByName(stormService.getId(), ComponentPropertyPattern.NIMBUS.name());
    assertNotNull(nimbus);
    Collection<ComponentProcess> nimbusProcesses = environmentService.listComponentProcesses(nimbus.getId());
    List<String> hosts = nimbusProcesses.stream().map(ComponentProcess::getHost).collect(Collectors.toList());
    assertEquals(Sets.newHashSet("storm-1", "storm-2"), new HashSet<>(hosts));
    List<Integer> ports = nimbusProcesses.stream().map(ComponentProcess::getPort).collect(Collectors.toList());
    assertEquals(Sets.newHashSet(6627, 6627), new HashSet<>(ports));
    Component ui = environmentService.getComponentByName(stormService.getId(), ComponentPropertyPattern.STORM_UI_SERVER.name());
    assertNotNull(ui);
    Collection<ComponentProcess> uiProcesses = environmentService.listComponentProcesses(ui.getId());
    assertEquals(Sets.newHashSet("storm-1"), uiProcesses.stream().map(ComponentProcess::getHost).collect(Collectors.toSet()));
    assertEquals(Sets.newHashSet(8080), uiProcesses.stream().map(ComponentProcess::getPort).collect(Collectors.toSet()));
    ServiceConfiguration stormYamlConf = environmentService.getServiceConfigurationByName(stormService.getId(), CONFIGURATION_NAME_STORM_YAML);
    assertNotNull(stormYamlConf);
    Map<String, String> stormYamlConfMap = stormYamlConf.getConfigurationMap();
    assertEquals(config.getAny(StormServiceRegistrar.PARAM_NIMBUS_THRIFT_MAX_BUFFER_SIZE), Integer.valueOf(stormYamlConfMap.get(StormServiceRegistrar.PARAM_NIMBUS_THRIFT_MAX_BUFFER_SIZE)));
    assertEquals(config.get(StormServiceRegistrar.PARAM_THRIFT_TRANSPORT), stormYamlConfMap.get(StormServiceRegistrar.PARAM_THRIFT_TRANSPORT));
    assertEquals(config.get(StormServiceRegistrar.PARAM_PRINCIPAL_TO_LOCAL), stormYamlConfMap.get(StormServiceRegistrar.PARAM_PRINCIPAL_TO_LOCAL));
    ServiceConfiguration stormEnvConf = environmentService.getServiceConfigurationByName(stormService.getId(), CONFIGURATION_NAME_STORM_ENV);
    assertNotNull(stormEnvConf);
    Map<String, String> stormEnvConfMap = stormEnvConf.getConfigurationMap();
    assertEquals(config.get(StormServiceRegistrar.PARAM_NIMBUS_PRINCIPAL_NAME), stormEnvConfMap.get(StormServiceRegistrar.PARAM_NIMBUS_PRINCIPAL_NAME));
}
Also used : Config(com.hortonworks.streamline.common.Config) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) Service(com.hortonworks.streamline.streams.cluster.catalog.Service) ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess) Test(org.junit.Test)

Example 9 with ComponentProcess

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

the class ZookeeperServiceRegistrarTest method testRegister.

@Test
public void testRegister() throws Exception {
    Cluster cluster = getTestCluster(1L);
    ZookeeperServiceRegistrar registrar = initializeServiceRegistrar();
    Config config = new Config();
    config.put(ZookeeperServiceRegistrar.PARAM_ZOOKEEPER_SERVER_HOSTNAMES, Lists.newArrayList("zookeeper-1", "zookeeper-2"));
    config.put(ZookeeperServiceRegistrar.PARAM_ZOOKEEPER_PORT, (Object) 2181);
    registrar.register(cluster, config, Collections.emptyList());
    Service zkService = environmentService.getServiceByName(cluster.getId(), Constants.Zookeeper.SERVICE_NAME);
    assertNotNull(zkService);
    Component zkServer = environmentService.getComponentByName(zkService.getId(), ComponentPropertyPattern.ZOOKEEPER_SERVER.name());
    assertNotNull(zkServer);
    Collection<ComponentProcess> zkServerProcesses = environmentService.listComponentProcesses(zkServer.getId());
    assertEquals(Sets.newHashSet("zookeeper-1", "zookeeper-2"), zkServerProcesses.stream().map(ComponentProcess::getHost).collect(Collectors.toSet()));
    assertEquals(Sets.newHashSet(2181, 2181), zkServerProcesses.stream().map(ComponentProcess::getPort).collect(Collectors.toSet()));
    ServiceConfiguration zooConf = environmentService.getServiceConfigurationByName(zkService.getId(), CONFIGURATION_NAME_ZOO_CFG);
    assertNotNull(zooConf);
}
Also used : 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 10 with ComponentProcess

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

the class KafkaMetadataServiceTest method getBrokerComponentProcesses.

private List<ComponentProcess> getBrokerComponentProcesses() {
    ComponentProcess broker1 = new ComponentProcess();
    broker1.setHost("hostname1");
    broker1.setPort(1234);
    broker1.setProtocol("PLAINTEXT");
    ComponentProcess broker2 = new ComponentProcess();
    broker2.setHost("hostname2");
    broker2.setPort(1234);
    broker2.setProtocol("PLAINTEXT");
    List<ComponentProcess> brokerProcesses = new ArrayList<>();
    brokerProcesses.add(broker1);
    brokerProcesses.add(broker2);
    return brokerProcesses;
}
Also used : ArrayList(java.util.ArrayList) 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