HBASE-22701 Disable the DynamicClassLoader when it fails to initialize
Signed-off-by: Ankit Singhal <ankitsinghal59@gmail.com>
This commit is contained in:
parent
5130bc52d5
commit
b566a4f9bc
|
@ -69,7 +69,10 @@ public class DynamicClassLoader extends ClassLoaderBase {
|
||||||
private static final String DYNAMIC_JARS_OPTIONAL_CONF_KEY = "hbase.use.dynamic.jars";
|
private static final String DYNAMIC_JARS_OPTIONAL_CONF_KEY = "hbase.use.dynamic.jars";
|
||||||
private static final boolean DYNAMIC_JARS_OPTIONAL_DEFAULT = true;
|
private static final boolean DYNAMIC_JARS_OPTIONAL_DEFAULT = true;
|
||||||
|
|
||||||
private boolean useDynamicJars;
|
// The user-provided value for using the DynamicClassLoader
|
||||||
|
private final boolean userConfigUseDynamicJars;
|
||||||
|
// The current state of whether to use the DynamicClassLoader
|
||||||
|
private final boolean useDynamicJars;
|
||||||
|
|
||||||
private File localDir;
|
private File localDir;
|
||||||
|
|
||||||
|
@ -91,13 +94,24 @@ public class DynamicClassLoader extends ClassLoaderBase {
|
||||||
final Configuration conf, final ClassLoader parent) {
|
final Configuration conf, final ClassLoader parent) {
|
||||||
super(parent);
|
super(parent);
|
||||||
|
|
||||||
useDynamicJars = conf.getBoolean(
|
// Save off the user's original configuration value for the DynamicClassLoader
|
||||||
|
userConfigUseDynamicJars = conf.getBoolean(
|
||||||
DYNAMIC_JARS_OPTIONAL_CONF_KEY, DYNAMIC_JARS_OPTIONAL_DEFAULT);
|
DYNAMIC_JARS_OPTIONAL_CONF_KEY, DYNAMIC_JARS_OPTIONAL_DEFAULT);
|
||||||
|
|
||||||
if (useDynamicJars) {
|
boolean dynamicJarsEnabled = userConfigUseDynamicJars;
|
||||||
|
if (dynamicJarsEnabled) {
|
||||||
|
try {
|
||||||
initTempDir(conf);
|
initTempDir(conf);
|
||||||
|
dynamicJarsEnabled = true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error("Disabling the DynamicClassLoader as it failed to initialize its temp directory."
|
||||||
|
+ " Check your configuration and filesystem permissions. Custom coprocessor code may"
|
||||||
|
+ " not be loaded as a result of this failure.", e);
|
||||||
|
dynamicJarsEnabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
useDynamicJars = dynamicJarsEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
// FindBugs: Making synchronized to avoid IS2_INCONSISTENT_SYNC complaints about
|
// FindBugs: Making synchronized to avoid IS2_INCONSISTENT_SYNC complaints about
|
||||||
// remoteDirFs and jarModifiedTime being part synchronized protected.
|
// remoteDirFs and jarModifiedTime being part synchronized protected.
|
||||||
|
@ -132,12 +146,13 @@ public class DynamicClassLoader extends ClassLoaderBase {
|
||||||
try {
|
try {
|
||||||
return parent.loadClass(name);
|
return parent.loadClass(name);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
if (LOG.isDebugEnabled()) {
|
|
||||||
LOG.debug("Class " + name + " not found - using dynamical class loader");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (useDynamicJars) {
|
if (useDynamicJars) {
|
||||||
|
LOG.debug("Class " + name + " not found - using dynamical class loader");
|
||||||
return tryRefreshClass(name);
|
return tryRefreshClass(name);
|
||||||
|
} else if (userConfigUseDynamicJars) {
|
||||||
|
// If the user tried to enable the DCL, then warn again.
|
||||||
|
LOG.debug("Not checking DynamicClassLoader for missing class because it is disabled."
|
||||||
|
+ " See the log for previous errors.");
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue