You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by el...@apache.org on 2019/09/05 22:53:02 UTC
[hbase] branch branch-2 updated: HBASE-22701 Disable the
DynamicClassLoader when it fails to initialize
This is an automated email from the ASF dual-hosted git repository.
elserj pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2 by this push:
new 2feca0a HBASE-22701 Disable the DynamicClassLoader when it fails to initialize
2feca0a is described below
commit 2feca0abded953add6c807c9f8c483a719fedcd7
Author: Josh Elser <el...@apache.org>
AuthorDate: Tue Jul 16 17:10:27 2019 -0400
HBASE-22701 Disable the DynamicClassLoader when it fails to initialize
Signed-off-by: Ankit Singhal <an...@gmail.com>
---
.../hadoop/hbase/util/DynamicClassLoader.java | 31 ++++++++++++++++------
1 file changed, 23 insertions(+), 8 deletions(-)
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/DynamicClassLoader.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/DynamicClassLoader.java
index 28fce21..e769e7f 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/DynamicClassLoader.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/DynamicClassLoader.java
@@ -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 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;
@@ -91,12 +94,23 @@ public class DynamicClassLoader extends ClassLoaderBase {
final Configuration conf, final ClassLoader 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);
- if (useDynamicJars) {
- initTempDir(conf);
+ boolean dynamicJarsEnabled = userConfigUseDynamicJars;
+ if (dynamicJarsEnabled) {
+ try {
+ 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
@@ -132,12 +146,13 @@ public class DynamicClassLoader extends ClassLoaderBase {
try {
return parent.loadClass(name);
} catch (ClassNotFoundException e) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Class " + name + " not found - using dynamical class loader");
- }
-
if (useDynamicJars) {
+ LOG.debug("Class {} not found - using dynamical class loader", 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;
}