Search in sources :

Example 1 with ServiceConfigurationNotFoundException

use of com.hortonworks.streamline.streams.cluster.exception.ServiceConfigurationNotFoundException 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 2 with ServiceConfigurationNotFoundException

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

use of com.hortonworks.streamline.streams.cluster.exception.ServiceConfigurationNotFoundException in project streamline by hortonworks.

the class AbstractKafkaBundleHintProvider method getHintsOnCluster.

@Override
public Map<String, Object> getHintsOnCluster(Cluster cluster, SecurityContext securityContext, Subject subject) {
    Map<String, Object> hintClusterMap = new HashMap<>();
    try (KafkaMetadataService kms = KafkaMetadataService.newInstance(environmentService, cluster.getId(), securityContext)) {
        KafkaTopics topics = kms.getTopicsFromZk();
        hintClusterMap.put(FIELD_NAME_TOPIC, topics.list());
        fillZookeeperHints(cluster, hintClusterMap);
        final Map<KafkaBrokerListeners.Protocol, List<String>> protocolToHostsWithPort = kms.getKafkaBrokerListeners().getProtocolToHostsWithPort();
        hintClusterMap.put(FIELD_NAME_BOOTSTRAP_SERVERS, mapValuesJoiner(protocolToHostsWithPort, ","));
        hintClusterMap.put(FIELD_NAME_SECURITY_PROTOCOL, protocolToHostsWithPort.keySet());
        hintClusterMap.put(FIELD_NAME_KAFKA_SERVICE_NAME, kms.getKafkaServiceName());
    } catch (ServiceNotFoundException e) {
        // we access it from mapping information so shouldn't be here
        throw new IllegalStateException("Service " + Constants.Kafka.SERVICE_NAME + " in cluster " + cluster.getName() + " not found but mapping information exists.");
    } catch (ServiceConfigurationNotFoundException e) {
    // there's KAFKA service but not enough configuration info.
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return hintClusterMap;
}
Also used : HashMap(java.util.HashMap) KafkaMetadataService(com.hortonworks.streamline.streams.cluster.service.metadata.KafkaMetadataService) ServiceComponentNotFoundException(com.hortonworks.streamline.streams.cluster.exception.ServiceComponentNotFoundException) ServiceConfigurationNotFoundException(com.hortonworks.streamline.streams.cluster.exception.ServiceConfigurationNotFoundException) ServiceNotFoundException(com.hortonworks.streamline.streams.cluster.exception.ServiceNotFoundException) KafkaTopics(com.hortonworks.streamline.streams.cluster.service.metadata.json.KafkaTopics) ServiceNotFoundException(com.hortonworks.streamline.streams.cluster.exception.ServiceNotFoundException) ServiceConfigurationNotFoundException(com.hortonworks.streamline.streams.cluster.exception.ServiceConfigurationNotFoundException) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList)

Example 4 with ServiceConfigurationNotFoundException

use of com.hortonworks.streamline.streams.cluster.exception.ServiceConfigurationNotFoundException in project streamline by hortonworks.

the class AbstractHDFSBundleHintProvider method getHintsOnCluster.

@Override
public Map<String, Object> getHintsOnCluster(Cluster cluster, SecurityContext securityContext, Subject subject) {
    Map<String, Object> hintMap = new HashMap<>();
    try {
        HDFSMetadataService hdfsMetadataService = HDFSMetadataService.newInstance(environmentService, cluster.getId());
        hintMap.put(getFieldNameForFSUrl(), hdfsMetadataService.getDefaultFsUrl());
    } catch (ServiceNotFoundException e) {
        // we access it from mapping information so shouldn't be here
        throw new IllegalStateException("Service " + Constants.HDFS.SERVICE_NAME + " in cluster " + cluster.getName() + " not found but mapping information exists.");
    } catch (ServiceConfigurationNotFoundException e) {
    // there's HBASE service but not enough configuration info.
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return hintMap;
}
Also used : HashMap(java.util.HashMap) ServiceNotFoundException(com.hortonworks.streamline.streams.cluster.exception.ServiceNotFoundException) ServiceConfigurationNotFoundException(com.hortonworks.streamline.streams.cluster.exception.ServiceConfigurationNotFoundException) HDFSMetadataService(com.hortonworks.streamline.streams.cluster.service.metadata.HDFSMetadataService) ServiceConfigurationNotFoundException(com.hortonworks.streamline.streams.cluster.exception.ServiceConfigurationNotFoundException) ServiceNotFoundException(com.hortonworks.streamline.streams.cluster.exception.ServiceNotFoundException)

Example 5 with ServiceConfigurationNotFoundException

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

Aggregations

ServiceConfigurationNotFoundException (com.hortonworks.streamline.streams.cluster.exception.ServiceConfigurationNotFoundException)5 ServiceNotFoundException (com.hortonworks.streamline.streams.cluster.exception.ServiceNotFoundException)4 HashMap (java.util.HashMap)4 ServiceConfiguration (com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration)3 Service (com.hortonworks.streamline.streams.cluster.catalog.Service)2 ServiceComponentNotFoundException (com.hortonworks.streamline.streams.cluster.exception.ServiceComponentNotFoundException)1 HDFSMetadataService (com.hortonworks.streamline.streams.cluster.service.metadata.HDFSMetadataService)1 KafkaMetadataService (com.hortonworks.streamline.streams.cluster.service.metadata.KafkaMetadataService)1 KafkaTopics (com.hortonworks.streamline.streams.cluster.service.metadata.json.KafkaTopics)1 List (java.util.List)1 Map (java.util.Map)1 Collectors.toList (java.util.stream.Collectors.toList)1