本文整理了Java中org.apache.hadoop.hive.ql.exec.Utilities.getSessionSpecifiedClassLoader()
方法的一些代码示例,展示了Utilities.getSessionSpecifiedClassLoader()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utilities.getSessionSpecifiedClassLoader()
方法的具体详情如下:
包路径:org.apache.hadoop.hive.ql.exec.Utilities
类名称:Utilities
方法名:getSessionSpecifiedClassLoader
[英]get session specified class loader and get current class loader if fall
[中]获取会话指定的类加载器,如果失败,则获取当前类加载器
代码示例来源:origin: apache/hive
private Class<?> getUdfClass(CreateFunctionDesc desc) throws ClassNotFoundException {
// get the session specified class loader from SessionState
ClassLoader classLoader = Utilities.getSessionSpecifiedClassLoader();
return Class.forName(desc.getClassName(), true, classLoader);
}
代码示例来源:origin: apache/hive
/** Gets the UDF class and checks it against the whitelist, if any. */
private Class<? extends UDF> getUdfClassInternal()
throws ClassNotFoundException {
@SuppressWarnings("unchecked")
Class<? extends UDF> clazz = (Class<? extends UDF>) Class.forName(
udfClassName, true, Utilities.getSessionSpecifiedClassLoader());
if (udfChecker != null && !udfChecker.isUdfAllowed(clazz)) {
throw new SecurityException("UDF " + clazz.getCanonicalName() + " is not allowed");
}
return clazz;
}
代码示例来源:origin: apache/hive
public Class<? extends Deserializer> getDeserializerClass() {
try {
return (Class<? extends Deserializer>) Class.forName(
getSerdeClassName(), true, Utilities.getSessionSpecifiedClassLoader());
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: apache/hive
public static String ensureClassExists(String className)
throws SemanticException {
if (className == null) {
return null;
}
try {
Class.forName(className, true, Utilities.getSessionSpecifiedClassLoader());
} catch (ClassNotFoundException e) {
throw new SemanticException("Cannot find class '" + className + "'", e);
}
return className;
}
代码示例来源:origin: apache/drill
private Class<?> getUdfClass(CreateFunctionDesc desc) throws ClassNotFoundException {
// get the session specified class loader from SessionState
ClassLoader classLoader = Utilities.getSessionSpecifiedClassLoader();
return Class.forName(desc.getClassName(), true, classLoader);
}
代码示例来源:origin: apache/drill
public Class<? extends Deserializer> getDeserializerClass() {
try {
return (Class<? extends Deserializer>) Class.forName(
getSerdeClassName(), true, Utilities.getSessionSpecifiedClassLoader());
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: apache/drill
/** Gets the UDF class and checks it against the whitelist, if any. */
private Class<? extends UDF> getUdfClassInternal()
throws ClassNotFoundException {
@SuppressWarnings("unchecked")
Class<? extends UDF> clazz = (Class<? extends UDF>) Class.forName(
udfClassName, true, Utilities.getSessionSpecifiedClassLoader());
if (udfChecker != null && !udfChecker.isUdfAllowed(clazz)) {
throw new SecurityException("UDF " + clazz.getCanonicalName() + " is not allowed");
}
return clazz;
}
代码示例来源:origin: apache/drill
public static String ensureClassExists(String className)
throws SemanticException {
if (className == null) {
return null;
}
try {
Class.forName(className, true, Utilities.getSessionSpecifiedClassLoader());
} catch (ClassNotFoundException e) {
throw new SemanticException("Cannot find class '" + className + "'", e);
}
return className;
}
代码示例来源:origin: apache/hive
public static <T extends Hook> List<T> readHooksFromConf(HiveConf conf, HiveConf.ConfVars hookConfVar)
throws InstantiationException, IllegalAccessException, ClassNotFoundException {
String csHooks = conf.getVar(hookConfVar);
List<T> hooks = new ArrayList<>();
if (Strings.isBlank(csHooks)) {
return hooks;
}
String[] hookClasses = csHooks.split(",");
for (String hookClass : hookClasses) {
T hook = (T) Class.forName(hookClass.trim(), true, Utilities.getSessionSpecifiedClassLoader()).newInstance();
hooks.add(hook);
}
return hooks;
}
}
代码示例来源:origin: apache/hive
private Class<?> getPermanentUdfClass(FunctionInfo function) {
Class<?> functionClass = function.getFunctionClass();
if (functionClass == null) {
// Expected for permanent UDFs at this point.
ClassLoader loader = Utilities.getSessionSpecifiedClassLoader();
try {
functionClass = Class.forName(function.getClassName(), true, loader);
} catch (ClassNotFoundException ex) {
throw new RuntimeException(ex);
}
}
return functionClass;
}
代码示例来源:origin: apache/hive
private Class<? extends RecordReader> getDefaultRecordReader()
throws SemanticException {
String name;
name = conf.getVar(HiveConf.ConfVars.HIVESCRIPTRECORDREADER);
try {
return (Class<? extends RecordReader>) Class.forName(name, true,
Utilities.getSessionSpecifiedClassLoader());
} catch (ClassNotFoundException e) {
throw new SemanticException(e);
}
}
代码示例来源:origin: apache/drill
private Class<? extends RecordReader> getDefaultRecordReader()
throws SemanticException {
String name;
name = conf.getVar(HiveConf.ConfVars.HIVESCRIPTRECORDREADER);
try {
return (Class<? extends RecordReader>) Class.forName(name, true,
Utilities.getSessionSpecifiedClassLoader());
} catch (ClassNotFoundException e) {
throw new SemanticException(e);
}
}
代码示例来源:origin: apache/hive
private boolean initialize(String type) {
ClassLoader classLoader = Utilities.getSessionSpecifiedClassLoader();
try {
StatDB statDB = StatDB.valueOf(type);
publisherImplementation = (Class<? extends Serializable>)
Class.forName(statDB.getPublisher(jobConf), true, classLoader);
aggregatorImplementation = (Class<? extends Serializable>)
Class.forName(statDB.getAggregator(jobConf), true, classLoader);
} catch (Exception e) {
LOG.error(type + " Publisher/Aggregator classes cannot be loaded.", e);
return false;
}
return true;
}
代码示例来源:origin: apache/hive
/**
* @param plan Usually of type MapredWork, MapredLocalWork etc.
* @param out stream in which serialized plan is written into
*/
private static void serializeObjectByKryo(Kryo kryo, Object plan, OutputStream out) {
Output output = new Output(out);
kryo.setClassLoader(Utilities.getSessionSpecifiedClassLoader());
kryo.writeObject(output, plan);
output.close();
}
代码示例来源:origin: apache/hive
private static <T> T deserializeObjectByKryo(Kryo kryo, InputStream in, Class<T> clazz ) {
Input inp = new Input(in);
kryo.setClassLoader(Utilities.getSessionSpecifiedClassLoader());
T t = kryo.readObject(inp,clazz);
inp.close();
return t;
}
代码示例来源:origin: apache/hive
public void setInputFormatClass(String name) throws HiveException {
if (name == null) {
inputFormatClass = null;
tTable.getSd().setInputFormat(null);
return;
}
try {
setInputFormatClass((Class<? extends InputFormat<WritableComparable, Writable>>) Class
.forName(name, true, Utilities.getSessionSpecifiedClassLoader()));
} catch (ClassNotFoundException e) {
throw new HiveException("Class not found: " + name, e);
}
}
代码示例来源:origin: apache/hive
public void setOutputFormatClass(String name) throws HiveException {
if (name == null) {
outputFormatClass = null;
tTable.getSd().setOutputFormat(null);
return;
}
try {
Class<?> origin = Class.forName(name, true, Utilities.getSessionSpecifiedClassLoader());
setOutputFormatClass(HiveFileFormatUtils.getOutputFormatSubstitute(origin));
} catch (ClassNotFoundException e) {
throw new HiveException("Class not found: " + name, e);
}
}
代码示例来源:origin: apache/drill
private static <T> T deserializeObjectByKryo(Kryo kryo, InputStream in, Class<T> clazz ) {
Input inp = new Input(in);
kryo.setClassLoader(Utilities.getSessionSpecifiedClassLoader());
T t = kryo.readObject(inp,clazz);
inp.close();
return t;
}
代码示例来源:origin: apache/drill
/**
* @param plan Usually of type MapredWork, MapredLocalWork etc.
* @param out stream in which serialized plan is written into
*/
private static void serializeObjectByKryo(Kryo kryo, Object plan, OutputStream out) {
Output output = new Output(out);
kryo.setClassLoader(Utilities.getSessionSpecifiedClassLoader());
kryo.writeObject(output, plan);
output.close();
}
代码示例来源:origin: apache/hive
private Class<? extends RecordReader> getRecordReader(ASTNode node)
throws SemanticException {
String name;
if (node.getChildCount() == 0) {
name = conf.getVar(HiveConf.ConfVars.HIVESCRIPTRECORDREADER);
} else {
name = unescapeSQLString(node.getChild(0).getText());
}
try {
return (Class<? extends RecordReader>) Class.forName(name, true,
Utilities.getSessionSpecifiedClassLoader());
} catch (ClassNotFoundException e) {
throw new SemanticException(e);
}
}
内容来源于网络,如有侵权,请联系作者删除!