use of org.apache.hadoop.hive.ql.exec.UDFClassLoader in project hive by apache.
the class FunctionLocalizer method refreshClassloader.
public void refreshClassloader() throws IOException {
if (recentlyLocalizedJars.isEmpty())
return;
String[] jars = recentlyLocalizedJars.toArray(new String[0]);
recentlyLocalizedJars.clear();
ClassLoader updatedCl = null;
try {
AddToClassPathAction addAction = new AddToClassPathAction(executorClassloader, Arrays.asList(jars));
updatedCl = AccessController.doPrivileged(addAction);
if (LOG.isInfoEnabled()) {
LOG.info("Added " + jars.length + " jars to classpath");
}
} catch (Throwable t) {
// TODO: we could fall back to trying one by one and only ignore the failed ones.
logRefreshError("Unable to localize jars: ", jars, t);
// logRefreshError always throws.
return;
}
if (updatedCl != executorClassloader) {
throw new AssertionError("Classloader was replaced despite using UDFClassLoader: new " + updatedCl + ", old " + executorClassloader);
}
String[] classNames = recentlyLocalizedClasses.toArray(jars);
recentlyLocalizedClasses.clear();
try {
for (String className : classNames) {
allowedUdfClasses.put(Class.forName(className, false, executorClassloader), Boolean.TRUE);
}
} catch (Throwable t) {
// TODO: we could fall back to trying one by one and only ignore the failed ones.
logRefreshError("Unable to instantiate localized classes: ", classNames, t);
// logRefreshError always throws.
return;
}
}
Aggregations