public static boolean unregisterJar(String jarsToUnregister) { LogHelper console = getConsole(); try { Utilities.removeFromClassPath(StringUtils.split(jarsToUnregister, ",")); console.printInfo("Deleted " + jarsToUnregister + " from class path"); return true; } catch (Exception e) { console.printError( "Unable to unregister " + jarsToUnregister + "\nException: " + e.getMessage(), "\n" + org.apache.hadoop.util.StringUtils.stringifyException(e)); return false; } }
// reloading the jars under the path specified in hive.reloadable.aux.jars.path property public void reloadAuxJars() throws IOException { final Set<String> reloadedAuxJars = new HashSet<String>(); final String renewableJarPath = conf.getVar(ConfVars.HIVERELOADABLEJARS); // do nothing if this property is not specified or empty if (renewableJarPath == null || renewableJarPath.isEmpty()) { return; } Set<String> jarPaths = Utilities.getJarFilesByPath(renewableJarPath); // load jars under the hive.reloadable.aux.jars.path if (!jarPaths.isEmpty()) { reloadedAuxJars.addAll(jarPaths); } // remove the previous renewable jars try { if (preReloadableAuxJars != null && !preReloadableAuxJars.isEmpty()) { Utilities.removeFromClassPath(preReloadableAuxJars.toArray(new String[0])); } } catch (Exception e) { String msg = "Fail to remove the reloaded jars loaded last time: " + e; throw new IOException(msg, e); } try { if (reloadedAuxJars != null && !reloadedAuxJars.isEmpty()) { URLClassLoader currentCLoader = (URLClassLoader) SessionState.get().getConf().getClassLoader(); currentCLoader = (URLClassLoader) Utilities.addToClassPath(currentCLoader, reloadedAuxJars.toArray(new String[0])); conf.setClassLoader(currentCLoader); Thread.currentThread().setContextClassLoader(currentCLoader); } preReloadableAuxJars.clear(); preReloadableAuxJars.addAll(reloadedAuxJars); } catch (Exception e) { String msg = "Fail to add jars from the path specified in hive.reloadable.aux.jars.path property: " + e; throw new IOException(msg, e); } }