use of org.talend.core.hadoop.HadoopConfJarBean in project tbd-studio-se by Talend.
the class HadoopClusterService method getCustomConfsJar.
@Override
public Optional<HadoopConfJarBean> getCustomConfsJar(ConnectionItem connectionItem, boolean createJarIfNotExist, boolean addExtraIds) {
if (connectionItem instanceof HadoopClusterConnectionItem) {
HadoopClusterConnectionItem item = (HadoopClusterConnectionItem) connectionItem;
HadoopClusterConnection connection = (HadoopClusterConnection) item.getConnection();
if (connection != null && connection.isUseCustomConfs()) {
String extraIds = null;
boolean isContextMode = connection.isContextMode();
if (addExtraIds && isContextMode) {
ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(connection, true);
extraIds = contextType.getName();
}
String defaultName = null;
if (extraIds == null) {
defaultName = HadoopConfsUtils.getConfsJarDefaultName(item, createJarIfNotExist);
} else {
defaultName = HadoopConfsUtils.getConfsJarDefaultName(item, createJarIfNotExist, extraIds);
}
return Optional.of(new HadoopConfJarBean(isContextMode, connection.isUseCustomConfs() && HCParameterUtil.isOverrideHadoopConfs(connection), HCParameterUtil.getHadoopConfSpecificJar(connection, false), HCParameterUtil.getHadoopConfSpecificJar(connection, true), defaultName));
}
}
return Optional.ofNullable(null);
}
use of org.talend.core.hadoop.HadoopConfJarBean in project tbd-studio-se by Talend.
the class HadoopClassLoaderFactory method loadCustomConfJar.
private static ClassLoader loadCustomConfJar(HDFSConnectionBean connectionBean, ClassLoader loader) {
if ((connectionBean.getRelativeHadoopClusterId() != null || connectionBean.isUseCustomConfs()) && loader instanceof DynamicClassLoader) {
try {
HadoopConfJarBean confJarBean = getCustomConfsJarName(connectionBean.getRelativeHadoopClusterId());
if (confJarBean != null) {
Consumer<DynamicClassLoader> afterLoad = null;
String[] addingJars = null;
if (confJarBean.isOverrideCustomConf()) {
String overrideCustomConfPath = confJarBean.getOriginalOverrideCustomConfPath();
if (StringUtils.isBlank(overrideCustomConfPath) || !new File(overrideCustomConfPath).exists()) {
ExceptionHandler.process(new Exception("Set Hadoop configuration JAR path is invalid: " + overrideCustomConfPath));
} else {
afterLoad = (t) -> t.addLibrary(overrideCustomConfPath);
}
} else {
String customConfsJarName = confJarBean.getCustomConfJarName();
if (customConfsJarName != null) {
addingJars = new String[] { customConfsJarName };
}
}
if (afterLoad != null || addingJars != null) {
loader = DynamicClassLoader.createNewOneBaseLoader((DynamicClassLoader) loader, addingJars, EHadoopConfigurationJars.HDFS.getEnableSecurityJars());
if (afterLoad != null) {
afterLoad.accept((DynamicClassLoader) loader);
}
}
}
// Add webhdfs extra jars
loader = HadoopClassLoaderUtil.addExtraJars(loader, EHadoopCategory.HDFS, connectionBean.getNameNodeURI());
} catch (MalformedURLException e) {
ExceptionHandler.process(e);
}
}
return loader;
}
Aggregations