pavlukhin commented on a change in pull request #7566: IGNITE-12832 Add user 
attributes support to control.sh
URL: https://github.com/apache/ignite/pull/7566#discussion_r399745118
 
 

 ##########
 File path: 
modules/core/src/main/java/org/apache/ignite/internal/commandline/CommonArgParser.java
 ##########
 @@ -336,4 +369,70 @@ private String securityWarningMessage(String password) {
 
         return String.format(pwdArgWarnFmt, password, password);
     }
+
+    /**
+     * Extracts user properties from property string or file.
+     *
+     * @param userPropStr {@code String} Property string.
+     * @param userPropPath {@code String} Property file path.
+     */
+    private Map<String, String> userProperties(String userPropStr, String 
userPropPath){
+        Map<String, String> res = parsePropertiesFromString(userPropStr);
+
+        parsePropertiesFromFile(userPropPath).forEach(res::putIfAbsent);
+
+        return res;
+    }
+
+    /**
+     * Extracts user properties from attribute string.
+     *
+     * @param propStr {@code String} Attribute string.
+     */
+    private Map<String, String> parsePropertiesFromString(String propStr) {
+        Map<String, String> res = new HashMap<>();
+
+        if(propStr == null)
+            return res;
+
+        final int partsOfPropStr = 2;
+
+        for (String prop : propStr.split(",")) {
+            if (!prop.contains("="))
+                throw new RuntimeException(String.format("Failed to parse 
property %s", prop));
+
+            String[] keyVal = prop.split("=", partsOfPropStr);
+
+            res.putIfAbsent(keyVal[0], keyVal[1]);
+        }
+
+        return res;
+    }
+
+    /**
+     * Extracts user properties from a given file.
+     *
+     * @param userPropPath {@code String} Property file path.
+     */
+    private Map<String, String> parsePropertiesFromFile(String userPropPath) {
+        Map<String, String> res = new HashMap<>();
+
+        if(userPropPath == null)
 
 Review comment:
   Space between `if` and `(`.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to