ankitsinghal commented on a change in pull request #4069:
URL: https://github.com/apache/hbase/pull/4069#discussion_r798981675
##########
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:
`LOG.error("Cannot fetch external System coprocessor class {} with path
{}", className,
path);`
The error message doesn't seem correct as the class will be fetched(or
loaded) in the next step. And I also still believe that as the IOException
should already be covering the reason if the path is incorrect, we should merge
this try-catch with the other to avoid the redundant code.
--
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]