Search in sources :

Example 11 with ComponentProcess

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

the class StormMetadataServiceTest method buildNimbusComponentProcesses.

private List<ComponentProcess> buildNimbusComponentProcesses() {
    ComponentProcess nimbus1 = new ComponentProcess();
    nimbus1.setHost("localhost");
    nimbus1.setPort(8080);
    ComponentProcess nimbus2 = new ComponentProcess();
    nimbus2.setHost("localhost");
    nimbus2.setPort(8080);
    return Lists.newArrayList(nimbus1, nimbus2);
}
Also used : ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess)

Example 12 with ComponentProcess

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

the class EnvironmentService method createComponentProcess.

public ComponentProcess createComponentProcess(Component component, String host) {
    ComponentProcess componentProcess = new ComponentProcess();
    componentProcess.setId(this.dao.nextId(NAMESPACE_COMPONENT_PROCESS));
    componentProcess.setComponentId(component.getId());
    componentProcess.setHost(host);
    componentProcess.setTimestamp(System.currentTimeMillis());
    return componentProcess;
}
Also used : ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess)

Example 13 with ComponentProcess

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

the class EnvironmentService method injectProtocolAndPortToComponent.

public void injectProtocolAndPortToComponent(Map<String, String> configurations, Component component, List<ComponentProcess> componentProcesses) {
    try {
        ComponentPropertyPattern componentPropertyPattern = ComponentPropertyPattern.valueOf(component.getName());
        String value = configurations.get(componentPropertyPattern.getConnectionConfName());
        if (value != null) {
            Pattern parsePattern = componentPropertyPattern.getParsePattern();
            LOG.debug("Connection configuration name: [{}], parse pattern: [{}]", value, parsePattern);
            if (parsePattern != null) {
                Matcher matcher = parsePattern.matcher(value);
                if (matcher.matches()) {
                    String protocol = matcher.group(1);
                    String portStr = matcher.group(2);
                    if (!protocol.isEmpty()) {
                        for (ComponentProcess componentProcess : componentProcesses) {
                            componentProcess.setProtocol(protocol);
                        }
                    }
                    if (!portStr.isEmpty()) {
                        try {
                            int port = Integer.parseInt(portStr);
                            for (ComponentProcess componentProcess : componentProcesses) {
                                componentProcess.setPort(port);
                            }
                        } catch (NumberFormatException e) {
                            LOG.warn("Protocol/Port information [{}] for component {} has illegal format [{}]." + "skip assigning...", value, component.getName(), parsePattern);
                            // reset protocol information
                            for (ComponentProcess componentProcess : componentProcesses) {
                                componentProcess.setPort(null);
                            }
                        }
                    }
                } else {
                    LOG.warn("Protocol/Port information [{}] for component {} doesn't seem to known format [{}]. " + "skipping assignment...", value, component.getName(), parsePattern);
                }
            }
        } else {
            LOG.warn("Protocol/Port related configuration ({}) is not set", componentPropertyPattern.getConnectionConfName());
        }
    } catch (IllegalArgumentException e) {
    // don't know port related configuration
    }
}
Also used : ComponentPropertyPattern(com.hortonworks.streamline.streams.cluster.discovery.ambari.ComponentPropertyPattern) Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) ComponentPropertyPattern(com.hortonworks.streamline.streams.cluster.discovery.ambari.ComponentPropertyPattern) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess)

Example 14 with ComponentProcess

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

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

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