s0nskar commented on code in PR #2698:
URL: https://github.com/apache/celeborn/pull/2698#discussion_r1724500061


##########
service/src/main/java/org/apache/celeborn/server/common/service/config/DynamicConfigServiceFactory.java:
##########
@@ -17,40 +17,30 @@
 
 package org.apache.celeborn.server.common.service.config;
 
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Locale;
+import java.util.ServiceLoader;
 
 import org.apache.celeborn.common.CelebornConf;
 import org.apache.celeborn.common.util.Utils;
 
 public class DynamicConfigServiceFactory {
   private static volatile ConfigService _INSTANCE;
 
-  // short names for dynamic config store backends
-  private static final HashMap<String, String> 
dynamicConfigStoreBackendShortNames =
-      new HashMap<String, String>() {
-        {
-          put("FS", FsConfigServiceImpl.class.getName());
-          put("DB", DbConfigServiceImpl.class.getName());
-        }
-      };
-
-  public static ConfigService getConfigService(CelebornConf celebornConf) 
throws IOException {
+  public static ConfigService getConfigService(CelebornConf celebornConf) {
     if (celebornConf.dynamicConfigStoreBackend().isEmpty()) {
       return null;
     }
 
     if (_INSTANCE == null) {
       synchronized (DynamicConfigServiceFactory.class) {
         if (_INSTANCE == null) {
-          String configStoreBackendName = 
celebornConf.dynamicConfigStoreBackend().get();
-          String configStoreBackendClass =
-              dynamicConfigStoreBackendShortNames.getOrDefault(
-                  configStoreBackendName.toUpperCase(Locale.ROOT), 
configStoreBackendName);
-
-          _INSTANCE =
-              
Utils.instantiateDynamicConfigStoreBackend(configStoreBackendClass, 
celebornConf);
+          String configStoreBackend = 
celebornConf.dynamicConfigStoreBackend().get();
+          for (ConfigStore configStore : 
ServiceLoader.load(ConfigStore.class)) {
+            String configService = configStore.getService();
+            if (configService.equalsIgnoreCase(configStoreBackend)
+                || configStore.getName().equalsIgnoreCase(configStoreBackend)) 
{
+              _INSTANCE = 
Utils.instantiateDynamicConfigStoreBackend(configService, celebornConf);

Review Comment:
   We can break the loop here.



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