Search in sources :

Example 1 with ComponentProcess

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

the class ClusterImporter method newComponentProcess.

private ComponentProcess newComponentProcess(ComponentProcess componentProcess, KafkaBrokerListeners.ListenersPropEntry listenersPropEntry) {
    ComponentProcess newComponentProcess = new ComponentProcess();
    newComponentProcess.setComponentId(componentProcess.getComponentId());
    newComponentProcess.setHost(componentProcess.getHost());
    newComponentProcess.setTimestamp(componentProcess.getTimestamp());
    newComponentProcess.setProtocol(listenersPropEntry.getProtocol().name());
    newComponentProcess.setPort(listenersPropEntry.getPort());
    return newComponentProcess;
}
Also used : ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess)

Example 2 with ComponentProcess

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

the class NamespaceAwareContainer method buildStormRestApiRootUrl.

protected String buildStormRestApiRootUrl(Namespace namespace, String streamingEngine) {
    // Assuming that a namespace has one mapping of streaming engine
    Service streamingEngineService = getFirstOccurenceServiceForNamespace(namespace, streamingEngine);
    if (streamingEngineService == null) {
        throw new RuntimeException("Streaming Engine " + streamingEngine + " is not associated to the namespace " + namespace.getName() + "(" + namespace.getId() + ")");
    }
    Component uiServer = getComponent(streamingEngineService, COMPONENT_NAME_STORM_UI_SERVER).orElseThrow(() -> new RuntimeException(streamingEngine + " doesn't have " + COMPONENT_NAME_STORM_UI_SERVER + " as component"));
    Collection<ComponentProcess> uiServerProcesses = environmentService.listComponentProcesses(uiServer.getId());
    if (uiServerProcesses.isEmpty()) {
        throw new RuntimeException(streamingEngine + " doesn't have any process for " + COMPONENT_NAME_STORM_UI_SERVER + " as component");
    }
    ComponentProcess uiServerProcess = uiServerProcesses.iterator().next();
    String uiHost = uiServerProcess.getHost();
    Integer uiPort = uiServerProcess.getPort();
    assertHostAndPort(uiServer.getName(), uiHost, uiPort);
    return "http://" + uiHost + ":" + uiPort + "/api/v1";
}
Also used : EnvironmentService(com.hortonworks.streamline.streams.cluster.service.EnvironmentService) Service(com.hortonworks.streamline.streams.cluster.catalog.Service) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess)

Example 3 with ComponentProcess

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

the class AbstractServiceRegistrar method register.

@Override
public Service register(Cluster cluster, Config config, List<ConfigFileInfo> configFileInfos) throws IOException {
    Service service = environmentService.createService(cluster, getServiceName());
    List<ServiceConfiguration> configurations = new ArrayList<>();
    Map<String, String> flattenConfigMap = new HashMap<>();
    List<ServiceConfiguration> serviceConfigurations = createServiceConfigurations(config);
    if (serviceConfigurations != null && !serviceConfigurations.isEmpty()) {
        serviceConfigurations.forEach(sc -> {
            configurations.add(sc);
            try {
                flattenConfigMap.putAll(sc.getConfigurationMap());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        });
    }
    for (ConfigFileInfo configFileInfo : configFileInfos) {
        Map<String, String> configMap = readConfigFile(configFileInfo);
        String fileName = FilenameUtils.getName(configFileInfo.getName());
        String confType = getConfType(fileName);
        String actualFileName = ConfigFilePattern.getOriginFileName(confType);
        ServiceConfiguration configuration = environmentService.createServiceConfiguration(service.getId(), confType, actualFileName, new HashMap<>(configMap));
        configurations.add(configuration);
        flattenConfigMap.putAll(configMap);
    }
    Map<Component, List<ComponentProcess>> components = createComponents(config, flattenConfigMap);
    if (!validateComponents(components)) {
        throw new IllegalArgumentException("Validation failed for components.");
    }
    if (!validateServiceConfigurations(configurations)) {
        throw new IllegalArgumentException("Validation failed for service configurations.");
    }
    if (!validateServiceConfiguationsAsFlattenedMap(flattenConfigMap)) {
        throw new IllegalArgumentException("Validation failed for service configurations.");
    }
    // here we are storing actual catalogs
    // before that we need to replace dummy service id to the actual one
    service = environmentService.addService(service);
    for (Map.Entry<Component, List<ComponentProcess>> entry : components.entrySet()) {
        Component component = entry.getKey();
        List<ComponentProcess> componentProcesses = entry.getValue();
        component.setServiceId(service.getId());
        component = environmentService.addComponent(component);
        for (ComponentProcess componentProcess : componentProcesses) {
            componentProcess.setComponentId(component.getId());
            environmentService.addComponentProcess(componentProcess);
        }
    }
    for (ServiceConfiguration configuration : configurations) {
        configuration.setServiceId(service.getId());
        environmentService.addServiceConfiguration(configuration);
    }
    return service;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) EnvironmentService(com.hortonworks.streamline.streams.cluster.service.EnvironmentService) Service(com.hortonworks.streamline.streams.cluster.catalog.Service) IOException(java.io.IOException) ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) ArrayList(java.util.ArrayList) List(java.util.List) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) HashMap(java.util.HashMap) Map(java.util.Map) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess)

Example 4 with ComponentProcess

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

the class EnvironmentService method removeComponentProcess.

public void removeComponentProcess(Long componentProcessId) {
    ComponentProcess componentProcess = new ComponentProcess();
    componentProcess.setId(componentProcessId);
    this.dao.remove(new StorableKey(NAMESPACE_COMPONENT_PROCESS, componentProcess.getPrimaryKey()));
}
Also used : StorableKey(com.hortonworks.registries.storage.StorableKey) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess)

Example 5 with ComponentProcess

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

the class KafkaServiceRegistrar method validateComponents.

@Override
protected boolean validateComponents(Map<Component, List<ComponentProcess>> components) {
    return components.entrySet().stream().anyMatch(componentEntry -> {
        Component component = componentEntry.getKey();
        List<ComponentProcess> componentProcesses = componentEntry.getValue();
        if (component.getName().equals(COMPONENT_KAFKA_BROKER)) {
            return isComponentProcessesWithProtocolRequiredValid(componentProcesses);
        }
        return false;
    });
}
Also used : Component(com.hortonworks.streamline.streams.cluster.catalog.Component) 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