taklwu commented on a change in pull request #4069:
URL: https://github.com/apache/hbase/pull/4069#discussion_r798646753



##########
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 was trying to separate them and throws with different message, so, I 
think merging them may confuse operators and they won't know it was caused by 
loading system coprocessor remotely
   




-- 
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]


Reply via email to