Search in sources :

Example 1 with LivyConfigurationException

use of com.thinkbiganalytics.kylo.spark.exceptions.LivyConfigurationException in project kylo by Teradata.

the class LivyProperties method postConstruct.

@PostConstruct
private void postConstruct() {
    logger.debug("PostConstruct called for LivyProperties");
    if (!Lists.newArrayList(env.getActiveProfiles()).contains("kylo-livy")) {
        throw new IllegalStateException("Attempting to instantiate LivyProperties bean when 'kylo-livy' is not an active profile");
    }
    if (!StringUtils.isNotEmpty(hostname)) {
        throw new LivyConfigurationException("Attempt to start when 'kylo-livy' is an active profile and property 'spark.livy.hostname' not defined, or invalid.");
    }
    if (port == null || port <= 0) {
        throw new LivyConfigurationException("Attempt to start when 'kylo-livy' is an active profile and property 'spark.livy.port' not defined, or invalid.");
    }
    logger.debug("determine the set of spark properties to pass to Livy");
    MutablePropertySources propSrcs = ((AbstractEnvironment) env).getPropertySources();
    StreamSupport.stream(propSrcs.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource).map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::<String>stream).filter(propName -> propName.startsWith("spark.") && !(propName.startsWith("spark.livy.") || propName.startsWith("spark.shell."))).forEach(propName -> sparkProperties.put(propName, env.getProperty(propName)));
    logger.debug("Validate session kinds are supportable");
    if (!(livySessionKind.equals(SessionKind.shared) || livySessionKind.equals(SessionKind.spark))) {
        throw new LivyConfigurationException(String.format("Session kind='%s' is not yet supported"));
    }
    logger.info("The following spark properties were found in kylo config files: '{}'", sparkProperties);
}
Also used : LivyConfigurationException(com.thinkbiganalytics.kylo.spark.exceptions.LivyConfigurationException) LivyConfigurationException(com.thinkbiganalytics.kylo.spark.exceptions.LivyConfigurationException) Arrays(java.util.Arrays) Logger(org.slf4j.Logger) SessionKind(com.thinkbiganalytics.kylo.spark.model.enums.SessionKind) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) EnumerablePropertySource(org.springframework.core.env.EnumerablePropertySource) HashMap(java.util.HashMap) StringUtils(org.apache.commons.lang3.StringUtils) Lists(com.google.common.collect.Lists) Environment(org.springframework.core.env.Environment) Map(java.util.Map) PostConstruct(javax.annotation.PostConstruct) StreamSupport(java.util.stream.StreamSupport) MutablePropertySources(org.springframework.core.env.MutablePropertySources) AbstractEnvironment(org.springframework.core.env.AbstractEnvironment) EnumerablePropertySource(org.springframework.core.env.EnumerablePropertySource) AbstractEnvironment(org.springframework.core.env.AbstractEnvironment) MutablePropertySources(org.springframework.core.env.MutablePropertySources) Arrays(java.util.Arrays) PostConstruct(javax.annotation.PostConstruct)

Aggregations

Lists (com.google.common.collect.Lists)1 LivyConfigurationException (com.thinkbiganalytics.kylo.spark.exceptions.LivyConfigurationException)1 SessionKind (com.thinkbiganalytics.kylo.spark.model.enums.SessionKind)1 Arrays (java.util.Arrays)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 StreamSupport (java.util.stream.StreamSupport)1 PostConstruct (javax.annotation.PostConstruct)1 StringUtils (org.apache.commons.lang3.StringUtils)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 AbstractEnvironment (org.springframework.core.env.AbstractEnvironment)1 EnumerablePropertySource (org.springframework.core.env.EnumerablePropertySource)1 Environment (org.springframework.core.env.Environment)1 MutablePropertySources (org.springframework.core.env.MutablePropertySources)1