Search in sources :

Example 36 with ServiceConfiguration

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

the class ServiceConfigurationCatalogResource method addOrUpdateServiceConfiguration.

@PUT
@Path("/services/{serviceId}/configurations/{id}")
@Timed
public Response addOrUpdateServiceConfiguration(@PathParam("serviceId") Long serviceId, @PathParam("id") Long serviceConfigurationId, ServiceConfiguration serviceConfiguration, @Context SecurityContext securityContext) {
    SecurityUtil.checkPermissions(authorizer, securityContext, Cluster.NAMESPACE, getClusterId(serviceId), WRITE);
    // overwrite service id to given path param
    serviceConfiguration.setServiceId(serviceId);
    ServiceConfiguration newConfiguration = environmentService.addOrUpdateServiceConfiguration(serviceId, serviceConfigurationId, serviceConfiguration);
    return WSUtils.respondEntity(newConfiguration, CREATED);
}
Also used : ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) PUT(javax.ws.rs.PUT)

Example 37 with ServiceConfiguration

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

the class OverrideHadoopConfiguration method override.

public static <T extends Configuration> T override(EnvironmentService environmentService, Long clusterId, ServiceConfigurations service, List<String> configNames, T configuration, Map<String, Function<String, String>> samOverrides) throws IOException, ServiceConfigurationNotFoundException, ServiceNotFoundException {
    for (String configName : configNames) {
        final ServiceConfiguration serviceConfig = environmentService.getServiceConfigurationByName(getServiceIdByClusterId(environmentService, clusterId, service), configName);
        if (serviceConfig != null) {
            final Map<String, String> configurationMap = serviceConfig.getConfigurationMap();
            if (configurationMap != null) {
                for (Map.Entry<String, String> propKeyVal : configurationMap.entrySet()) {
                    LOG.debug("Overriding property {}", propKeyVal);
                    final String key = propKeyVal.getKey();
                    final String val = samOverrides.containsKey(key) ? getSamOverride(samOverrides, propKeyVal) : propKeyVal.getValue();
                    if (key != null && val != null) {
                        configuration.set(key, val);
                        LOG.debug("Set property {}={}", key, val);
                    } else {
                        LOG.warn("Skipping null key/val property {}", propKeyVal);
                    }
                }
            }
        } else {
            throw new ServiceConfigurationNotFoundException("Required [" + configName + "] configuration not found for service [" + service.name() + "]");
        }
    }
    return configuration;
}
Also used : ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) ServiceConfigurationNotFoundException(com.hortonworks.streamline.streams.cluster.exception.ServiceConfigurationNotFoundException) Map(java.util.Map)

Example 38 with ServiceConfiguration

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

the class ClusterImporter method removeAllServices.

private void removeAllServices(Cluster cluster) {
    Collection<Service> services = environmentService.listServices(cluster.getId());
    for (Service service : services) {
        Collection<Component> components = environmentService.listComponents(service.getId());
        for (Component component : components) {
            environmentService.listComponentProcesses(component.getId()).forEach(componentProcess -> environmentService.removeComponentProcess(componentProcess.getId()));
            environmentService.removeComponent(component.getId());
        }
        Collection<ServiceConfiguration> configurations = environmentService.listServiceConfigurations(service.getId());
        for (ServiceConfiguration configuration : configurations) {
            environmentService.removeServiceConfiguration(configuration.getId());
        }
        environmentService.removeService(service.getId());
    }
}
Also used : ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) EnvironmentService(com.hortonworks.streamline.streams.cluster.service.EnvironmentService) Service(com.hortonworks.streamline.streams.cluster.catalog.Service) Component(com.hortonworks.streamline.streams.cluster.catalog.Component)

Example 39 with ServiceConfiguration

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

the class DruidSinkBundleHintProvider method getHintsOnCluster.

@Override
public Map<String, Object> getHintsOnCluster(Cluster cluster, SecurityContext securityContext, Subject subject) {
    Map<String, Object> hintMap = new HashMap<>();
    try {
        Service druid = environmentService.getServiceByName(cluster.getId(), Constants.Druid.SERVICE_NAME);
        if (druid == null) {
            throw new ServiceNotFoundException(Constants.Druid.SERVICE_NAME);
        }
        ServiceConfiguration commonRuntime = environmentService.getServiceConfigurationByName(druid.getId(), Constants.Druid.CONF_TYPE_COMMON_RUNTIME);
        if (commonRuntime == null) {
            throw new ServiceConfigurationNotFoundException(Constants.Druid.CONF_TYPE_COMMON_RUNTIME);
        }
        Map<String, String> configurationMap = commonRuntime.getConfigurationMap();
        putToHintMapIfAvailable(configurationMap, hintMap, Constants.Druid.PROPERTY_KEY_ZK_SERVICE_HOSTS, FIELD_NAME_ZK_CONNECT);
        putToHintMapIfAvailable(configurationMap, hintMap, Constants.Druid.PROPERTY_KEY_INDEXING_SERVICE_NAME, FIELD_NAME_INDEX_SERVICE);
        putToHintMapIfAvailable(configurationMap, hintMap, Constants.Druid.PROPERTY_KEY_DISCOVERY_CURATOR_PATH, FIELD_NAME_DISCOVERY_PATH);
        // exceptional case for Ambari import
        if (!hintMap.containsKey(FIELD_NAME_INDEX_SERVICE)) {
            ServiceConfiguration druidOverload = environmentService.getServiceConfigurationByName(druid.getId(), Constants.Druid.CONF_TYPE_DRUID_OVERLOAD);
            if (druidOverload != null) {
                putToHintMapIfAvailable(druidOverload.getConfigurationMap(), hintMap, Constants.Druid.PROPERTY_KEY_SERVICE_NAME, FIELD_NAME_INDEX_SERVICE);
            }
        }
    } catch (ServiceNotFoundException e) {
        // we access it from mapping information so shouldn't be here
        throw new IllegalStateException("Service " + Constants.Druid.SERVICE_NAME + " in cluster " + cluster.getName() + " not found but mapping information exists.");
    } catch (ServiceConfigurationNotFoundException e) {
    // there's Druid 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 40 with ServiceConfiguration

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

the class TopologyActionsService method setUpClusterArtifacts.

public void setUpClusterArtifacts(Topology topology, TopologyActions topologyActions) throws IOException {
    Namespace namespace = environmentService.getNamespace(topology.getNamespaceId());
    if (namespace == null) {
        throw new RuntimeException("Corresponding namespace not found: " + topology.getNamespaceId());
    }
    ObjectMapper objectMapper = new ObjectMapper();
    Path artifactsDir = topologyActions.getArtifactsLocation(CatalogToLayoutConverter.getTopologyLayout(topology));
    makeEmptyDir(artifactsDir);
    Collection<NamespaceServiceClusterMap> serviceClusterMappings = environmentService.listServiceClusterMapping(namespace.getId());
    for (NamespaceServiceClusterMap serviceClusterMapping : serviceClusterMappings) {
        Service service = environmentService.getServiceByName(serviceClusterMapping.getClusterId(), serviceClusterMapping.getServiceName());
        if (service != null) {
            Collection<ServiceConfiguration> serviceConfigurations = environmentService.listServiceConfigurations(service.getId());
            if (serviceConfigurations != null) {
                for (ServiceConfiguration serviceConfiguration : serviceConfigurations) {
                    writeConfigurationFile(objectMapper, artifactsDir, serviceConfiguration);
                }
            }
        }
    }
}
Also used : Path(java.nio.file.Path) ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) Service(com.hortonworks.streamline.streams.cluster.catalog.Service) EnvironmentService(com.hortonworks.streamline.streams.cluster.service.EnvironmentService) StreamCatalogService(com.hortonworks.streamline.streams.catalog.service.StreamCatalogService) NamespaceServiceClusterMap(com.hortonworks.streamline.streams.cluster.catalog.NamespaceServiceClusterMap) Namespace(com.hortonworks.streamline.streams.cluster.catalog.Namespace) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

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