wu-sheng commented on a change in pull request #4514: Add selector property in 
application.yml
URL: https://github.com/apache/skywalking/pull/4514#discussion_r392670134
 
 

 ##########
 File path: 
oap-server/server-bootstrap/src/main/java/org/apache/skywalking/oap/server/starter/config/ApplicationConfigLoader.java
 ##########
 @@ -105,6 +112,48 @@ private void 
overrideConfigBySystemEnv(ApplicationConfiguration configuration) {
         }
     }
 
+    private void selectConfig(final Map<String, Map<String, Object>> 
moduleConfiguration) {
+        final Set<String> modulesWithoutProvider = new HashSet<>();
+        for (final Map.Entry<String, Map<String, Object>> entry : 
moduleConfiguration.entrySet()) {
+            final String moduleName = entry.getKey();
+            final Map<String, Object> providerConfig = entry.getValue();
+            if (!providerConfig.containsKey(SELECTOR)) {
+                continue;
+            }
+            final String selector = (String) providerConfig.get(SELECTOR);
+            final String resolvedSelector = 
PropertyPlaceholderHelper.INSTANCE.replacePlaceholders(
+                selector, System.getProperties()
+            );
+            providerConfig.entrySet().removeIf(e -> 
!resolvedSelector.equals(e.getKey()));
+
+            if (!providerConfig.isEmpty()) {
+                continue;
+            }
+
+            if (!DISABLE_SELECTOR.equals(resolvedSelector)) {
+                throw new RuntimeException(
+                    "no provider found for module " + moduleName + ", " +
+                        "if you're sure it's not required module and want to 
remove it, " +
+                        "set the selector to -"
+                );
+            }
+
+            // now the module can be safely removed
+            modulesWithoutProvider.add(moduleName);
+        }
+
+        moduleConfiguration.entrySet().removeIf(e -> {
+            final String module = e.getKey();
+            final boolean shouldBeRemoved = 
modulesWithoutProvider.contains(module);
+
+            if (shouldBeRemoved) {
+                logger.info("removing module {} without any provider", module);
 
 Review comment:
   ```suggestion
                   logger.info("Remove module {} without any provider", module);
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to