use of com.alibaba.alink.common.io.plugin.TemporaryClassLoaderContext in project Alink by alibaba.
the class HiveClassLoaderFactory method installSecurity.
private void installSecurity(ClassLoader classLoader) {
if (installed == null || !installed) {
try (TemporaryClassLoaderContext context = TemporaryClassLoaderContext.of(classLoader)) {
if (System.getProperties().containsKey("java.security.krb5.conf") && Files.exists(Paths.get(System.getProperty("java.security.krb5.conf")))) {
Configuration configuration = GlobalConfiguration.loadConfiguration();
if (!(configuration.containsKey(ConfigConstants.PATH_HADOOP_CONFIG))) {
LOG.warn("Could not find hadoop configure, but the krb file has been set.");
installed = true;
return;
}
try {
Class<?> initializer = Class.forName("com.alibaba.alink.common.io.catalog.hive.plugin.initializer.HivePluginInitializer", true, classLoader);
Method method = initializer.getMethod("initialize", String.class);
method.invoke(null, configuration.getString(ConfigConstants.PATH_HADOOP_CONFIG, null));
} catch (ClassNotFoundException e) {
LOG.warn("Could not find HivePluginInitializer.", e);
} catch (NoSuchMethodException e) {
LOG.warn("Could not find the initialize method.", e);
} catch (IllegalAccessException | InvocationTargetException e) {
LOG.warn("Invoke the initialize error.", e);
}
}
}
installed = true;
}
}
Aggregations