Browse Source

fix:针对hive进行了一些优化

pull/4/head
Munin 6 years ago
parent
commit
24eac105ef
  1. 1
      plugin.xml
  2. 14
      src/main/java/com/fr/plugin/dialect/classloader/ClassLoaderHandler.java
  3. 2
      src/main/java/com/fr/plugin/dialect/classloader/DriverClassLoader.java

1
plugin.xml

@ -12,6 +12,7 @@
[2019-05-20]优化逻辑。<br/>
[2019-05-30]实现一个可用的ClassLoader。<br/>
[2019-05-31]修改Mysql的key为Hive。<br/>
[2019-05-31]考虑一下并发问题,针对hive修改了一下加载机制。<br/>
]]></change-notes>
<main-package>com.fr.plugin.dialect.classloader</main-package>
<extra-core>

14
src/main/java/com/fr/plugin/dialect/classloader/ClassLoaderHandler.java

@ -20,6 +20,7 @@ import java.util.List;
@EnableMetrics
public class ClassLoaderHandler extends AbstractDataSourceDriverLoader {
private ClassLoader driverClassLoader;
//插件获取jar的路径,和lib同级的driverlib目录
public static final String DRIVER_LIB_DIR = "driverlib";
@ -41,11 +42,14 @@ public class ClassLoaderHandler extends AbstractDataSourceDriverLoader {
@Focus(id = "com.fr.plugin.dialect.classloader.ClassLoaderHandler", text = "", source = Original.PLUGIN)
public ClassLoader getClassLoader() {
FineLoggerFactory.getLogger().info("====== Loading Mysql ClassLoader ... ======");
URL[] urls = getJarURLS();
ClassLoader cl = new DriverClassLoader(urls);
Thread.currentThread().setContextClassLoader(cl);
return cl;
FineLoggerFactory.getLogger().info("====== Loading Hive ClassLoader ... ======");
synchronized (this) {
if (this.driverClassLoader == null) {
URL[] urls = getJarURLS();
this.driverClassLoader = new DriverClassLoader(urls);
}
return driverClassLoader;
}
}

2
src/main/java/com/fr/plugin/dialect/classloader/DriverClassLoader.java

@ -33,8 +33,8 @@ public class DriverClassLoader extends URLClassLoader {
FineLoggerFactory.getLogger().debug("Did not find class{}, in the paths {}, try to get from common lib", name, this.getUrlStrings());
c = super.loadClass(name);
}
return c;
}
}

Loading…
Cancel
Save