Search in sources :

Example 1 with ServiceConfiguration

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

the class TopologyActionsContainer method putStormConfigurations.

private void putStormConfigurations(Service streamingEngineService, Map<String, Object> conf) {
    ServiceConfiguration storm = getServiceConfiguration(streamingEngineService, SERVICE_CONFIGURATION_STORM).orElse(new ServiceConfiguration());
    ServiceConfiguration stormEnv = getServiceConfiguration(streamingEngineService, SERVICE_CONFIGURATION_STORM_ENV).orElse(new ServiceConfiguration());
    try {
        Map<String, String> stormConfMap = storm.getConfigurationMap();
        if (stormConfMap != null) {
            if (stormConfMap.containsKey(TopologyLayoutConstants.NIMBUS_THRIFT_MAX_BUFFER_SIZE)) {
                conf.put(TopologyLayoutConstants.NIMBUS_THRIFT_MAX_BUFFER_SIZE, Long.parseLong(stormConfMap.get(TopologyLayoutConstants.NIMBUS_THRIFT_MAX_BUFFER_SIZE)));
            }
            if (stormConfMap.containsKey(TopologyLayoutConstants.STORM_THRIFT_TRANSPORT)) {
                String thriftTransport = stormConfMap.get(TopologyLayoutConstants.STORM_THRIFT_TRANSPORT);
                if (!thriftTransport.startsWith("{{") && !thriftTransport.endsWith("}}")) {
                    conf.put(TopologyLayoutConstants.STORM_THRIFT_TRANSPORT, stormConfMap.get(TopologyLayoutConstants.STORM_THRIFT_TRANSPORT));
                }
            }
            if (stormConfMap.containsKey(TopologyLayoutConstants.STORM_NONSECURED_THRIFT_TRANSPORT)) {
                conf.put(TopologyLayoutConstants.STORM_NONSECURED_THRIFT_TRANSPORT, stormConfMap.get(TopologyLayoutConstants.STORM_NONSECURED_THRIFT_TRANSPORT));
            }
            if (stormConfMap.containsKey(TopologyLayoutConstants.STORM_SECURED_THRIFT_TRANSPORT)) {
                conf.put(TopologyLayoutConstants.STORM_SECURED_THRIFT_TRANSPORT, stormConfMap.get(TopologyLayoutConstants.STORM_SECURED_THRIFT_TRANSPORT));
            }
            if (stormConfMap.containsKey(TopologyLayoutConstants.STORM_PRINCIPAL_TO_LOCAL)) {
                conf.put(TopologyLayoutConstants.STORM_PRINCIPAL_TO_LOCAL, stormConfMap.get(TopologyLayoutConstants.STORM_PRINCIPAL_TO_LOCAL));
            }
        }
        Map<String, String> stormEnvConfMap = stormEnv.getConfigurationMap();
        if (stormEnvConfMap != null) {
            if (stormEnvConfMap.containsKey(TopologyLayoutConstants.STORM_NIMBUS_PRINCIPAL_NAME)) {
                conf.put(TopologyLayoutConstants.STORM_NIMBUS_PRINCIPAL_NAME, stormEnvConfMap.get(TopologyLayoutConstants.STORM_NIMBUS_PRINCIPAL_NAME));
            }
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) IOException(java.io.IOException)

Example 2 with ServiceConfiguration

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

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

the class NotificationSinkBundleHintProvider method getHintsOnCluster.

@Override
public Map<String, Object> getHintsOnCluster(Cluster cluster, SecurityContext securityContext, Subject subject) {
    Map<String, Object> hintMap = new HashMap<>();
    try {
        Service email = environmentService.getServiceByName(cluster.getId(), Constants.Email.SERVICE_NAME);
        if (email == null) {
            throw new ServiceNotFoundException(Constants.Email.SERVICE_NAME);
        }
        ServiceConfiguration properties = environmentService.getServiceConfigurationByName(email.getId(), Constants.Email.CONF_TYPE_PROPERTIES);
        if (properties == null) {
            throw new ServiceConfigurationNotFoundException(Constants.Email.CONF_TYPE_PROPERTIES);
        }
        Map<String, String> configurationMap = properties.getConfigurationMap();
        putToHintMapIfAvailable(configurationMap, hintMap, Constants.Email.PROPERTY_KEY_HOST, FIELD_NAME_HOST);
        putToHintMapIfAvailable(configurationMap, hintMap, Constants.Email.PROPERTY_KEY_PORT, FIELD_NAME_PORT);
        putToHintMapIfAvailable(configurationMap, hintMap, Constants.Email.PROPERTY_KEY_SSL, FIELD_NAME_SSL);
        putToHintMapIfAvailable(configurationMap, hintMap, Constants.Email.PROPERTY_KEY_STARTTLS, FIELD_NAME_STARTTLS);
        putToHintMapIfAvailable(configurationMap, hintMap, Constants.Email.PROPERTY_KEY_PROTOCOL, FIELD_NAME_PROTOCOL);
        putToHintMapIfAvailable(configurationMap, hintMap, Constants.Email.PROPERTY_KEY_AUTH, FIELD_NAME_AUTH);
    } catch (ServiceNotFoundException e) {
        // we access it from mapping information so shouldn't be here
        throw new IllegalStateException("Service " + Constants.Email.SERVICE_NAME + " in cluster " + cluster.getName() + " not found but mapping information exists.");
    } catch (ServiceConfigurationNotFoundException e) {
    // there's Email service configuration but not having enough information
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return hintMap;
}
Also used : ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) HashMap(java.util.HashMap) ServiceNotFoundException(com.hortonworks.streamline.streams.cluster.exception.ServiceNotFoundException) Service(com.hortonworks.streamline.streams.cluster.catalog.Service) ServiceConfigurationNotFoundException(com.hortonworks.streamline.streams.cluster.exception.ServiceConfigurationNotFoundException) ServiceConfigurationNotFoundException(com.hortonworks.streamline.streams.cluster.exception.ServiceConfigurationNotFoundException) ServiceNotFoundException(com.hortonworks.streamline.streams.cluster.exception.ServiceNotFoundException)

Example 4 with ServiceConfiguration

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

the class ServiceCatalogResource method buildManualServiceRegisterResult.

private ServiceWithComponents buildManualServiceRegisterResult(Service service) {
    Collection<ServiceConfiguration> configurations = environmentService.listServiceConfigurations(service.getId());
    Collection<Component> components = environmentService.listComponents(service.getId());
    ServiceWithComponents s = new ServiceWithComponents(service);
    s.setComponents(components);
    s.setConfigurations(configurations);
    return s;
}
Also used : ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) ServiceWithComponents(com.hortonworks.streamline.streams.cluster.model.ServiceWithComponents)

Example 5 with ServiceConfiguration

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

the class EnvironmentService method getServiceConfiguration.

public ServiceConfiguration getServiceConfiguration(Long configurationId) {
    ServiceConfiguration serviceConfiguration = new ServiceConfiguration();
    serviceConfiguration.setId(configurationId);
    return this.dao.get(new StorableKey(SERVICE_CONFIGURATION_NAMESPACE, serviceConfiguration.getPrimaryKey()));
}
Also used : ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) StorableKey(com.hortonworks.registries.storage.StorableKey)

Aggregations

ServiceConfiguration (com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration)40 Service (com.hortonworks.streamline.streams.cluster.catalog.Service)21 Cluster (com.hortonworks.streamline.streams.cluster.catalog.Cluster)14 Test (org.junit.Test)13 HashMap (java.util.HashMap)12 Config (com.hortonworks.streamline.common.Config)11 EnvironmentService (com.hortonworks.streamline.streams.cluster.service.EnvironmentService)9 Component (com.hortonworks.streamline.streams.cluster.catalog.Component)8 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)7 ComponentProcess (com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess)5 Map (java.util.Map)5 Timed (com.codahale.metrics.annotation.Timed)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 Path (javax.ws.rs.Path)4 ServiceConfigurationNotFoundException (com.hortonworks.streamline.streams.cluster.exception.ServiceConfigurationNotFoundException)3 ManualServiceRegistrar (com.hortonworks.streamline.streams.cluster.register.ManualServiceRegistrar)3 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 Collection (java.util.Collection)3 Collections (java.util.Collections)3