ivankelly commented on a change in pull request #1217:  Shade bookkeeper in 
distributedlog-core-shaded and allow using shaded bookkeeper client to resolve 
ledger manager factory class
URL: https://github.com/apache/bookkeeper/pull/1217#discussion_r171215566
 
 

 ##########
 File path: 
bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/AbstractZkLedgerManagerFactory.java
 ##########
 @@ -194,15 +200,78 @@ public static LedgerManagerFactory 
newLedgerManagerFactory(
                 }
                 factoryClass = theCls.asSubclass(LedgerManagerFactory.class);
             } catch (ClassNotFoundException cnfe) {
-                throw new IOException("Failed to instantiate ledger manager 
factory "
-                        + layout.getManagerFactoryClass());
+                factoryClass = attemptToResolveShadedLedgerManagerFactory(
+                    conf,
+                    layout.getManagerFactoryClass(),
+                    cnfe);
             }
         }
         // instantiate a factory
         lmFactory = ReflectionUtils.newInstance(factoryClass);
         return lmFactory.initialize(conf, layoutManager, 
layout.getManagerVersion());
     }
 
+    private static String normalizedLedgerManagerFactoryClassName(String 
factoryClass,
+                                                                  String 
shadedClassPrefix,
+                                                                  boolean 
isShadedClassAllowed) {
+        if (isShadedClassAllowed) {
+            if (null == factoryClass || null == shadedClassPrefix) {
+                return factoryClass;
+            } else {
+                return factoryClass.replace(shadedClassPrefix, "");
+            }
+        } else {
+            return factoryClass;
+        }
+    }
+
+    private static boolean isSameLedgerManagerFactory(
+            AbstractConfiguration<?> conf, String leftFactoryClass, String 
rightFactoryClass) {
+        leftFactoryClass = normalizedLedgerManagerFactoryClassName(
 
 Review comment:
   ```
   return leftFactoryClass.endsWith(rightFactoryClass) || 
rightFactoryClass.endsWith(leftFactoryClass)
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to