coolbeevip commented on a change in pull request #2347:
URL: https://github.com/apache/bookkeeper/pull/2347#discussion_r429752745



##########
File path: 
bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/AbstractConfiguration.java
##########
@@ -224,6 +227,19 @@ public void loadConf(URL confURL) throws 
ConfigurationException {
         }
     }
 
+    /**
+     * Load configurations from environment variables prefixed with BK_.
+     */
+    public void loadEnv() {

Review comment:
       I changed the loadConfEnv method of Main.java to the following
   
   ```
       private static void loadConfEnv(ServerConfiguration conf) throws 
IllegalArgumentException {
           try {
               System.getenv().entrySet().stream().filter(entry -> 
entry.getKey().startsWith(ENV_PREFIX))
                   .forEach(entry -> {
                       String name = 
entry.getKey().substring(ENV_PREFIX.length());
                       String value = entry.getValue();
                       log.info("load environment {}={}", name, value);
                       conf.setProperty(name, value);
                   });
               conf.validate();
           } catch (ConfigurationException e) {
               log.error("Malformed configuration file: {}", e);
               throw new IllegalArgumentException();
           }
       }
   ```
   
   Do you have any suggestions about defining the location of constant 
ENV_PREFIX?
   
   ```
       // Environment Parameters Prefix
       protected static final String ENV_PREFIX = "BK_";
   ```




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


Reply via email to