Search in sources :

Example 6 with ServiceNotFoundException

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

ServiceNotFoundException (com.hortonworks.streamline.streams.cluster.exception.ServiceNotFoundException)6 ServiceConfigurationNotFoundException (com.hortonworks.streamline.streams.cluster.exception.ServiceConfigurationNotFoundException)4 HashMap (java.util.HashMap)4 Service (com.hortonworks.streamline.streams.cluster.catalog.Service)2 ServiceConfiguration (com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration)2 ServiceComponentNotFoundException (com.hortonworks.streamline.streams.cluster.exception.ServiceComponentNotFoundException)2 KafkaTopics (com.hortonworks.streamline.streams.cluster.service.metadata.json.KafkaTopics)2 List (java.util.List)2 Cluster (com.hortonworks.streamline.streams.cluster.catalog.Cluster)1 Component (com.hortonworks.streamline.streams.cluster.catalog.Component)1 ComponentProcess (com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess)1 ComponentPropertyPattern (com.hortonworks.streamline.streams.cluster.discovery.ambari.ComponentPropertyPattern)1 ServiceConfigurations (com.hortonworks.streamline.streams.cluster.discovery.ambari.ServiceConfigurations)1 EnvironmentService (com.hortonworks.streamline.streams.cluster.service.EnvironmentService)1 HDFSMetadataService (com.hortonworks.streamline.streams.cluster.service.metadata.HDFSMetadataService)1 KafkaMetadataService (com.hortonworks.streamline.streams.cluster.service.metadata.KafkaMetadataService)1 HostPort (com.hortonworks.streamline.streams.cluster.service.metadata.common.HostPort)1 Collection (java.util.Collection)1 Collectors (java.util.stream.Collectors)1 Collectors.toList (java.util.stream.Collectors.toList)1