use of com.thinkbiganalytics.kylo.util.HadoopClassLoader in project kylo by Teradata.
the class DefaultCatalogFileManager method isolatedFunction.
/**
* Executes the specified function in a separate class loader containing the jars of the specified template.
*/
@VisibleForTesting
protected <R> R isolatedFunction(@Nonnull final DataSetTemplate template, @Nonnull final Path path, @Nonnull final FileSystemFunction<R> function) throws IOException {
final Configuration conf = DataSetUtil.getConfiguration(template, defaultConf);
try (final HadoopClassLoader classLoader = new HadoopClassLoader(conf)) {
if (template.getJars() != null) {
log.debug("Adding jars to HadoopClassLoader: {}", template.getJars());
classLoader.addJars(template.getJars());
}
log.debug("Creating FileSystem from path: {}", path);
try (final FileSystem fs = FileSystem.newInstance(path.toUri(), conf)) {
return function.apply(fs);
}
}
}
use of com.thinkbiganalytics.kylo.util.HadoopClassLoader in project kylo by Teradata.
the class DefaultCatalogTableManager method isolatedFunction.
/**
* Executes the specified function in a separate class loader containing the jars of the specified template.
*/
@VisibleForTesting
protected <R> R isolatedFunction(@Nonnull final DataSetTemplate template, @Nullable final String catalog, @Nonnull final SqlSchemaFunction<R> function) throws SQLException {
// Get Hadoop configuration
final Configuration conf = DataSetUtil.getConfiguration(template, defaultConf);
final HadoopClassLoader classLoader = new HadoopClassLoader(conf);
if (template.getJars() != null) {
log.debug("Adding jars to HadoopClassLoader: {}", template.getJars());
classLoader.addJars(template.getJars());
}
// Get data source configuration
DataSourceProperties properties = getDataSourceProperties(template, classLoader);
final JdbcSchemaParser schemaParser = schemaParserProvider.getSchemaParser(properties.getUrl());
properties = schemaParser.prepareDataSource(properties, catalog);
// Connect to data source
final javax.sql.DataSource dataSource = PoolingDataSourceService.getDataSource(properties);
try (final Connection connection = KerberosUtil.getConnectionWithOrWithoutKerberos(dataSource, new KerberosTicketConfiguration())) {
return function.apply(connection, schemaParser);
}
}
Aggregations