andrey-kuznetsov 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_r397925003
 
 

 ##########
 File path: 
modules/core/src/main/java/org/apache/ignite/internal/commandline/CommonArgParser.java
 ##########
 @@ -336,4 +375,48 @@ private String securityWarningMessage(String password) {
 
         return String.format(pwdArgWarnFmt, password, password);
     }
+
+    /**
+     * Extracts user attributes from attribute string.
+     *
+     * @param attrMap {@code Map} Attribute map.
+     * @param attrs {@code String} Attribute string.
+     */
+    private void parseAttributesFromString(Map<String, String> attrMap, String 
attrs) {
+        final int partsOfAttrStr = 2;
+
+        for (String attr : attrs.split(",")) {
+            if (!attr.contains("="))
+                throw new RuntimeException(String.format("Failed to parse 
attribute %s", attr));
+
+            String[] keyVal = attr.split("=", partsOfAttrStr);
+
+            if (!attrMap.containsKey(keyVal[0]))
+                attrMap.put(keyVal[0], keyVal[1]);
+        }
+    }
+
+    /**
+     * Extracts user attributes from a given file.
+     *
+     * @param attrMap {@code Map} Attribute map.
+     * @param path {@code String} Path to the file.
+     */
+    private void parseAttributesFromFile(Map<String, String> attrMap, String 
path) {
+        Properties attrs = new Properties();
+
+        try (InputStream is = new FileInputStream(new File(path))) {
+            attrs.load(is);
+        }
+        catch (IOException e) {
+            logger.log(Level.SEVERE, "Failed to read property file: " + path, 
e);
+
+            throw new RuntimeException(e);
+        }
+
+        attrs.forEach((key, value) -> {
+            if (!attrMap.containsKey(key.toString()))
 
 Review comment:
   Why not putIfAbsent() ?

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