taklwu commented on a change in pull request #4069:
URL: https://github.com/apache/hbase/pull/4069#discussion_r798996726
##########
File path:
hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.java
##########
@@ -144,21 +145,42 @@ protected void loadSystemCoprocessors(Configuration conf,
String confKey) {
int currentSystemPriority = Coprocessor.PRIORITY_SYSTEM;
for (String className : defaultCPClasses) {
- String[] classNameAndPriority = className.split("\\|");
+ // After HBASE-23710 and HBASE-26714 when configuring for system
coprocessor, we accept
+ // an optional format of className|priority|path
+ String[] classNameToken = className.split("\\|");
boolean hasPriorityOverride = false;
- className = classNameAndPriority[0];
+ boolean hasPath = false;
+ className = classNameToken[0];
int overridePriority = Coprocessor.PRIORITY_SYSTEM;
- if (classNameAndPriority.length > 1){
- overridePriority = Integer.parseInt(classNameAndPriority[1]);
+ Path path = null;
+ if (classNameToken.length > 1 &&
!Strings.isNullOrEmpty(classNameToken[1])) {
+ overridePriority = Integer.parseInt(classNameToken[1]);
hasPriorityOverride = true;
}
+ if (classNameToken.length > 2 &&
!Strings.isNullOrEmpty(classNameToken[2])) {
+ path = new Path(classNameToken[2].trim());
+ hasPath = true;
+ }
className = className.trim();
if (findCoprocessor(className) != null) {
// If already loaded will just continue
LOG.warn("Attempted duplicate loading of " + className + "; skipped");
continue;
}
ClassLoader cl = this.getClass().getClassLoader();
+ // override the class loader if a path for the system coprocessor is
provided.
+ if (hasPath) {
+ String pathPrefix = UUID.randomUUID().toString();
+ try {
+ cl = CoprocessorClassLoader.getClassLoader(path,
this.getClass().getClassLoader(),
+ pathPrefix, conf);
+ } catch (IOException ioe) {
+ // if system coprocessors cannot be obtained, we also about the
region server
+ LOG.error("Cannot fetch external System coprocessor class {} with
path {}", className,
+ path);
+ abortServer(className, ioe);
Review comment:
I agreed that the IOException will cover the right stacktrace, and just
to clarify that `CoprocessorClassLoader.getClassLoader` internally will first
check if the given path exist before actually loading the classname from the
jar, that's why I split them into two blocks originally and want to tell the
operators from logs that the jar file does not exist and it's not only about
give coprocessor class does not exist
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]