Search in sources :

Example 21 with ServiceConfiguration

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

the class EnvironmentService method createServiceConfiguration.

public ServiceConfiguration createServiceConfiguration(Long serviceId, String confType, String actualFileName, Map<String, String> configuration) throws JsonProcessingException {
    ServiceConfiguration conf = new ServiceConfiguration();
    conf.setId(this.dao.nextId(SERVICE_CONFIGURATION_NAMESPACE));
    conf.setName(confType);
    conf.setServiceId(serviceId);
    conf.setFilename(actualFileName);
    conf.setConfiguration(objectMapper.writeValueAsString(configuration));
    conf.setTimestamp(System.currentTimeMillis());
    return conf;
}
Also used : ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration)

Example 22 with ServiceConfiguration

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

the class ClusterResourceUtil method enrichCluster.

public static ClusterServicesImportResult enrichCluster(Cluster cluster, EnvironmentService environmentService) {
    ClusterServicesImportResult result = new ClusterServicesImportResult(cluster);
    for (Service service : environmentService.listServices(cluster.getId())) {
        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);
        result.addService(s);
    }
    return result;
}
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) ServiceWithComponents(com.hortonworks.streamline.streams.cluster.model.ServiceWithComponents)

Example 23 with ServiceConfiguration

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

the class ServiceConfigurationCatalogResource method getConfigurationById.

@GET
@Path("/services/{serviceId}/configurations/{id}")
@Timed
public Response getConfigurationById(@PathParam("serviceId") Long serviceId, @PathParam("id") Long configurationId, @Context SecurityContext securityContext) {
    SecurityUtil.checkPermissions(authorizer, securityContext, Cluster.NAMESPACE, getClusterId(serviceId), READ);
    ServiceConfiguration configuration = environmentService.getServiceConfiguration(configurationId);
    if (configuration != null) {
        if (configuration.getServiceId() == null || !configuration.getServiceId().equals(serviceId)) {
            throw EntityNotFoundException.byId("service: " + serviceId.toString());
        }
        return WSUtils.respondEntity(configuration, OK);
    }
    throw EntityNotFoundException.byId(buildMessageForCompositeId(serviceId, configurationId));
}
Also used : ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET)

Example 24 with ServiceConfiguration

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

the class DruidServiceRegistrar method buildCommonRuntimeServiceConfiguration.

private ServiceConfiguration buildCommonRuntimeServiceConfiguration(Config config) {
    ServiceConfiguration commonRuntime = new ServiceConfiguration();
    commonRuntime.setName(Constants.Druid.CONF_TYPE_COMMON_RUNTIME);
    Map<String, String> confMap = new HashMap<>();
    if (config.contains(PARAM_ZOOKEEPER_CONNECTION_STRING)) {
        confMap.put(PARAM_ZOOKEEPER_CONNECTION_STRING, config.getString(PARAM_ZOOKEEPER_CONNECTION_STRING));
    }
    if (config.contains(PARAM_INDEXING_SERVICE_NAME)) {
        confMap.put(PARAM_INDEXING_SERVICE_NAME, config.getString(PARAM_INDEXING_SERVICE_NAME));
    }
    if (config.contains(PARAM_DISCOVERY_CURATOR_PATH)) {
        confMap.put(PARAM_DISCOVERY_CURATOR_PATH, config.getString(PARAM_DISCOVERY_CURATOR_PATH));
    }
    try {
        String json = objectMapper.writeValueAsString(confMap);
        commonRuntime.setConfiguration(json);
    } catch (JsonProcessingException e) {
        throw new RuntimeException(e);
    }
    return commonRuntime;
}
Also used : ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) HashMap(java.util.HashMap) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Example 25 with ServiceConfiguration

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

the class EmailServiceRegistrar method createServiceConfigurations.

@Override
protected List<ServiceConfiguration> createServiceConfigurations(Config config) {
    ServiceConfiguration serviceConfiguration = new ServiceConfiguration();
    serviceConfiguration.setName(Constants.Email.CONF_TYPE_PROPERTIES);
    Map<String, String> confMap = new HashMap<>();
    confMap.put(PARAM_HOST, config.get(Constants.Email.PROPERTY_KEY_HOST));
    confMap.put(PARAM_PORT, String.valueOf((Integer) config.getAny(Constants.Email.PROPERTY_KEY_PORT)));
    confMap.put(PARAM_SSL, String.valueOf((Boolean) config.getAny(Constants.Email.PROPERTY_KEY_SSL)));
    confMap.put(PARAM_STARTTLS, String.valueOf((Boolean) config.getAny(Constants.Email.PROPERTY_KEY_STARTTLS)));
    confMap.put(PARAM_PROTOCOL, config.get(Constants.Email.PROPERTY_KEY_PROTOCOL));
    confMap.put(PARAM_AUTH, String.valueOf((Boolean) config.getAny(Constants.Email.PROPERTY_KEY_AUTH)));
    ObjectMapper objectMapper = new ObjectMapper();
    try {
        String json = objectMapper.writeValueAsString(confMap);
        serviceConfiguration.setConfiguration(json);
    } catch (JsonProcessingException e) {
        throw new RuntimeException(e);
    }
    return Collections.singletonList(serviceConfiguration);
}
Also used : ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) HashMap(java.util.HashMap) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) 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