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);
}
Aggregations