You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2020/03/25 06:55:22 UTC

[GitHub] [ignite] oleg-ostanin opened a new pull request #7566: Ignite 12832

oleg-ostanin opened a new pull request #7566: Ignite 12832
URL: https://github.com/apache/ignite/pull/7566
 
 
   

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


With regards,
Apache Git Services

[GitHub] [ignite] oleg-ostanin commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
oleg-ostanin 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_r400868662
 
 

 ##########
 File path: modules/core/src/test/resources/user-attribute.properties
 ##########
 @@ -0,0 +1 @@
+attr3=val3
 
 Review comment:
   fixed

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


With regards,
Apache Git Services

[GitHub] [ignite] oleg-ostanin commented on a change in pull request #7566: Ignite 12832

Posted by GitBox <gi...@apache.org>.
oleg-ostanin commented on a change in pull request #7566: Ignite 12832
URL: https://github.com/apache/ignite/pull/7566#discussion_r397729772
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/CommonArgParser.java
 ##########
 @@ -336,4 +374,52 @@ 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 extractAttributesFromString(Map<String, String> attrMap, String attrs) {
+        final int partsOfAttrStr = 2;
+
+        for (String attr : attrs.split(",")) {
+            if (!attr.contains("=")) {
+                logger.warning(String.format("Failed to parse attribute %s", attr));
+
+                continue;
+            }
+
+            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 extractAttributesFromFile(Map<String, String> attrMap, String path) {
+        Properties attrs = new Properties();
+
+        try (InputStream is = new FileInputStream(new File(path))) {
+            attrs.load(is);
+        } catch (Exception e) {
+            logger.log(Level.SEVERE, "Failed to read property file: " + path, e);
+
+            throw new RuntimeException(e);
+        }
+
+        attrs.forEach((key, value) ->
+                {
 
 Review comment:
   fixed

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


With regards,
Apache Git Services

[GitHub] [ignite] andrey-kuznetsov commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
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_r397931652
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/commandline/CommandHandlerParsingTest.java
 ##########
 @@ -277,6 +291,59 @@ public void testParseAndValidateSSLArguments() {
         }
     }
 
+    /**
+     * Tests parsing user attribute arguments from string.
+     */
+    @Test
+    public void testParseUserAttrStringArguments() {
+        List<String> cmdArgs = new ArrayList<>(DFLT_ARGS);
+
+        cmdArgs.add(CommandList.TX.text());
+        cmdArgs.add(CommonArgParser.CMD_USER_ATTR);
+        cmdArgs.add("attr1=val1,attr2=val2,attr3=mode=test");
+
+        ConnectionAndSslParameters args = parseArgs(cmdArgs);
+
+        assertEquals(args.userAttributes().get("attr1"), "val1");
+        assertNotEquals(args.userAttributes().get("attr1"), "val2");
+        assertEquals(args.userAttributes().get("attr3"), "mode=test");
+    }
+
+    /**
+     * Tests parsing user attribute arguments from file.
+     */
+    @Test
+    public void testParseUserAttrFileArguments() {
+        List<String> cmdArgs = new ArrayList<>(DFLT_ARGS);
+
+        cmdArgs.add(CommandList.TX.text());
+        cmdArgs.add(CommonArgParser.CMD_USER_ATTR_PATH);
+        cmdArgs.add(IgniteUtils.resolveIgnitePath(USER_ATTRIBUTE_PATH).getAbsolutePath());
+
+        ConnectionAndSslParameters args = parseArgs(cmdArgs);
+
+        assertEquals(args.userAttributes().get("attr3"), "val3");
+        assertEquals(args.userAttributes().get("attr4"), "mode=test");
+    }
+
+    /**
+     * Tests parsing user attribute arguments from file.
+     */
+    @Test
+    public void testParseUserAttrStringFileArguments() {
+        List<String> cmdArgs = new ArrayList<>(DFLT_ARGS);
+
+        cmdArgs.add(CommandList.TX.text());
+        cmdArgs.add(CommonArgParser.CMD_USER_ATTR_PATH);
+        cmdArgs.add(IgniteUtils.resolveIgnitePath(USER_ATTRIBUTE_PATH).getAbsolutePath());
+        cmdArgs.add(CommonArgParser.CMD_USER_ATTR);
+        cmdArgs.add("attr1=val1,attr3=val4");
+
+        ConnectionAndSslParameters args = parseArgs(cmdArgs);
+
+        assertEquals(args.userAttributes().get("attr3"), "val4");
 
 Review comment:
   We are to ensure all other attributes from both sources are still 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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] oleg-ostanin commented on a change in pull request #7566: Ignite 12832

Posted by GitBox <gi...@apache.org>.
oleg-ostanin commented on a change in pull request #7566: Ignite 12832
URL: https://github.com/apache/ignite/pull/7566#discussion_r397728666
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/CommonArgParser.java
 ##########
 @@ -336,4 +374,52 @@ 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 extractAttributesFromString(Map<String, String> attrMap, String attrs) {
+        final int partsOfAttrStr = 2;
+
+        for (String attr : attrs.split(",")) {
+            if (!attr.contains("=")) {
+                logger.warning(String.format("Failed to parse attribute %s", attr));
+
+                continue;
+            }
+
+            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 extractAttributesFromFile(Map<String, String> attrMap, String path) {
 
 Review comment:
   done

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


With regards,
Apache Git Services

[GitHub] [ignite] oleg-ostanin commented on a change in pull request #7566: Ignite 12832

Posted by GitBox <gi...@apache.org>.
oleg-ostanin commented on a change in pull request #7566: Ignite 12832
URL: https://github.com/apache/ignite/pull/7566#discussion_r397730183
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/ConnectionAndSslParameters.java
 ##########
 @@ -17,8 +17,11 @@
 
 package org.apache.ignite.internal.commandline;
 
+import java.util.HashMap;
 import org.apache.ignite.internal.client.GridClientConfiguration;
 
+import java.util.Map;
 
 Review comment:
   done

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


With regards,
Apache Git Services

[GitHub] [ignite] oleg-ostanin commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
oleg-ostanin 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_r399969942
 
 

 ##########
 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){
 
 Review comment:
   fixed

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


With regards,
Apache Git Services

[GitHub] [ignite] oleg-ostanin commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
oleg-ostanin 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_r399969660
 
 

 ##########
 File path: modules/core/src/test/resources/user.properties
 ##########
 @@ -0,0 +1,19 @@
+#
 
 Review comment:
   Yep, you are absolutely right. Fixed.

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


With regards,
Apache Git Services

[GitHub] [ignite] oleg-ostanin commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
oleg-ostanin 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_r399958096
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/CommonArgParser.java
 ##########
 @@ -310,6 +331,16 @@ ConnectionAndSslParameters parseAndValidate(Iterator<String> rawArgIter) {
 
                         break;
 
+                    case CMD_USER_PROPS:
+                        userPropStr = argIter.nextArg("Expected user property string.");
+
+                        break;
+
+                    case CMD_USER_PROPS_PATH:
+                        userPropPath = argIter.nextArg("Expected user property path.");
 
 Review comment:
   fixed

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


With regards,
Apache Git Services

[GitHub] [ignite] oleg-ostanin commented on a change in pull request #7566: Ignite 12832

Posted by GitBox <gi...@apache.org>.
oleg-ostanin commented on a change in pull request #7566: Ignite 12832
URL: https://github.com/apache/ignite/pull/7566#discussion_r397730883
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/ConnectionAndSslParameters.java
 ##########
 @@ -269,6 +275,13 @@ public String sslTrustStoreType() {
         return sslTrustStorePassword;
     }
 
+    /**
+     * @return {@code Map} User attributes.
+     */
+    public Map<String, String> userAttributes(){
 
 Review comment:
   done

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


With regards,
Apache Git Services

[GitHub] [ignite] oleg-ostanin commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
oleg-ostanin 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_r398450448
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/CommonArgParser.java
 ##########
 @@ -310,20 +333,36 @@ ConnectionAndSslParameters parseAndValidate(Iterator<String> rawArgIter) {
 
                         break;
 
+                    case CMD_USER_ATTR:
+                        userAttrStr = argIter.nextArg("Expected user attribute string.");
 
 Review comment:
   renamed to 'property'

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


With regards,
Apache Git Services

[GitHub] [ignite] pavlukhin commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
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_r399744612
 
 

 ##########
 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));
 
 Review comment:
   Is it common to use `RuntimeException` in control utility code to handle input exceptions? Applicable to `parsePropertiesFromFile` method as well. What will user see in case of such input exceptions? It might be useful to write tests checking it.

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


With regards,
Apache Git Services

[GitHub] [ignite] oleg-ostanin commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
oleg-ostanin 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_r398473418
 
 

 ##########
 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:
   fixed

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


With regards,
Apache Git Services

[GitHub] [ignite] pavlukhin commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] oleg-ostanin commented on a change in pull request #7566: Ignite 12832

Posted by GitBox <gi...@apache.org>.
oleg-ostanin commented on a change in pull request #7566: Ignite 12832
URL: https://github.com/apache/ignite/pull/7566#discussion_r397731240
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/ConnectionAndSslParameters.java
 ##########
 @@ -277,4 +290,15 @@ public String sslTrustStoreType() {
     public void sslTrustStorePassword(char[] sslTrustStorePassword) {
         this.sslTrustStorePassword = sslTrustStorePassword;
     }
+
+    /**
+     * Set user attributes.
+     *
+     * @param userAttrs user attributes.
+     */
+    public ConnectionAndSslParameters withUserAttributes(Map<String, String> userAttrs){
 
 Review comment:
   done

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


With regards,
Apache Git Services

[GitHub] [ignite] oleg-ostanin commented on a change in pull request #7566: Ignite 12832

Posted by GitBox <gi...@apache.org>.
oleg-ostanin commented on a change in pull request #7566: Ignite 12832
URL: https://github.com/apache/ignite/pull/7566#discussion_r397727678
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/CommonArgParser.java
 ##########
 @@ -336,4 +374,52 @@ 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 extractAttributesFromString(Map<String, String> attrMap, String attrs) {
+        final int partsOfAttrStr = 2;
+
+        for (String attr : attrs.split(",")) {
+            if (!attr.contains("=")) {
+                logger.warning(String.format("Failed to parse attribute %s", attr));
+
+                continue;
 
 Review comment:
   fixed

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


With regards,
Apache Git Services

[GitHub] [ignite] Sega76 commented on a change in pull request #7566: Ignite 12832

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #7566: Ignite 12832
URL: https://github.com/apache/ignite/pull/7566#discussion_r397652677
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/commandline/CommandHandlerParsingTest.java
 ##########
 @@ -204,7 +215,9 @@ public void testFindAndDeleteGarbage() {
         return res;
     }
 
-    /** */
+    /**
+     *
 
 Review comment:
   replace / ** */

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


With regards,
Apache Git Services

[GitHub] [ignite] oleg-ostanin commented on a change in pull request #7566: Ignite 12832

Posted by GitBox <gi...@apache.org>.
oleg-ostanin commented on a change in pull request #7566: Ignite 12832
URL: https://github.com/apache/ignite/pull/7566#discussion_r397727879
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/CommonArgParser.java
 ##########
 @@ -336,4 +374,52 @@ 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 extractAttributesFromString(Map<String, String> attrMap, String attrs) {
+        final int partsOfAttrStr = 2;
+
+        for (String attr : attrs.split(",")) {
+            if (!attr.contains("=")) {
+                logger.warning(String.format("Failed to parse attribute %s", attr));
+
+                continue;
+            }
+
+            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 extractAttributesFromFile(Map<String, String> attrMap, String path) {
 
 Review comment:
   done

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


With regards,
Apache Git Services

[GitHub] [ignite] SomeFire commented on a change in pull request #7566: Ignite 12832

Posted by GitBox <gi...@apache.org>.
SomeFire commented on a change in pull request #7566: Ignite 12832
URL: https://github.com/apache/ignite/pull/7566#discussion_r397698671
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/CommonArgParser.java
 ##########
 @@ -336,4 +374,52 @@ 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 extractAttributesFromString(Map<String, String> attrMap, String attrs) {
+        final int partsOfAttrStr = 2;
+
+        for (String attr : attrs.split(",")) {
+            if (!attr.contains("=")) {
+                logger.warning(String.format("Failed to parse attribute %s", attr));
+
+                continue;
+            }
+
+            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 extractAttributesFromFile(Map<String, String> attrMap, String path) {
+        Properties attrs = new Properties();
+
+        try (InputStream is = new FileInputStream(new File(path))) {
+            attrs.load(is);
+        } catch (Exception e) {
+            logger.log(Level.SEVERE, "Failed to read property file: " + path, e);
+
+            throw new RuntimeException(e);
+        }
+
+        attrs.forEach((key, value) ->
+                {
 
 Review comment:
   K&R bracing and indentation style should be used. { starts on the same line as the opening block statement.
   See https://cwiki.apache.org/confluence/display/IGNITE/Coding+Guidelines#CodingGuidelines-BracesandIdentation

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


With regards,
Apache Git Services

[GitHub] [ignite] oleg-ostanin commented on a change in pull request #7566: Ignite 12832

Posted by GitBox <gi...@apache.org>.
oleg-ostanin commented on a change in pull request #7566: Ignite 12832
URL: https://github.com/apache/ignite/pull/7566#discussion_r397670090
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/CommonArgParser.java
 ##########
 @@ -310,20 +332,38 @@ ConnectionAndSslParameters parseAndValidate(Iterator<String> rawArgIter) {
 
                         break;
 
+                    case CMD_USER_ATTR:
+                        userAttrStr = argIter.nextArg("Expected user attribute string.");
+                        ;
 
 Review comment:
   fixed

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


With regards,
Apache Git Services

[GitHub] [ignite] oleg-ostanin commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
oleg-ostanin 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_r400868970
 
 

 ##########
 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:
   done

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


With regards,
Apache Git Services

[GitHub] [ignite] oleg-ostanin commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
oleg-ostanin 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_r398450824
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/CommonArgParser.java
 ##########
 @@ -310,20 +333,36 @@ ConnectionAndSslParameters parseAndValidate(Iterator<String> rawArgIter) {
 
                         break;
 
+                    case CMD_USER_ATTR:
+                        userAttrStr = argIter.nextArg("Expected user attribute string.");
+
+                        break;
+
+                    case CMD_USER_ATTR_PATH:
+                        userAttrPath = argIter.nextArg("Expected user attribute file.");
 
 Review comment:
   renamed to 'property'
   
   

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


With regards,
Apache Git Services

[GitHub] [ignite] andrey-kuznetsov commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] oleg-ostanin commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
oleg-ostanin 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_r398476391
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/commandline/CommandHandlerParsingTest.java
 ##########
 @@ -277,6 +291,59 @@ public void testParseAndValidateSSLArguments() {
         }
     }
 
+    /**
+     * Tests parsing user attribute arguments from string.
+     */
+    @Test
+    public void testParseUserAttrStringArguments() {
+        List<String> cmdArgs = new ArrayList<>(DFLT_ARGS);
+
+        cmdArgs.add(CommandList.TX.text());
+        cmdArgs.add(CommonArgParser.CMD_USER_ATTR);
+        cmdArgs.add("attr1=val1,attr2=val2,attr3=mode=test");
+
+        ConnectionAndSslParameters args = parseArgs(cmdArgs);
+
+        assertEquals(args.userAttributes().get("attr1"), "val1");
+        assertNotEquals(args.userAttributes().get("attr1"), "val2");
+        assertEquals(args.userAttributes().get("attr3"), "mode=test");
+    }
+
+    /**
+     * Tests parsing user attribute arguments from file.
+     */
+    @Test
+    public void testParseUserAttrFileArguments() {
+        List<String> cmdArgs = new ArrayList<>(DFLT_ARGS);
+
+        cmdArgs.add(CommandList.TX.text());
+        cmdArgs.add(CommonArgParser.CMD_USER_ATTR_PATH);
+        cmdArgs.add(IgniteUtils.resolveIgnitePath(USER_ATTRIBUTE_PATH).getAbsolutePath());
+
+        ConnectionAndSslParameters args = parseArgs(cmdArgs);
+
+        assertEquals(args.userAttributes().get("attr3"), "val3");
+        assertEquals(args.userAttributes().get("attr4"), "mode=test");
+    }
+
+    /**
+     * Tests parsing user attribute arguments from file.
+     */
+    @Test
+    public void testParseUserAttrStringFileArguments() {
+        List<String> cmdArgs = new ArrayList<>(DFLT_ARGS);
+
+        cmdArgs.add(CommandList.TX.text());
+        cmdArgs.add(CommonArgParser.CMD_USER_ATTR_PATH);
+        cmdArgs.add(IgniteUtils.resolveIgnitePath(USER_ATTRIBUTE_PATH).getAbsolutePath());
+        cmdArgs.add(CommonArgParser.CMD_USER_ATTR);
+        cmdArgs.add("attr1=val1,attr3=val4");
+
+        ConnectionAndSslParameters args = parseArgs(cmdArgs);
+
+        assertEquals(args.userAttributes().get("attr3"), "val4");
 
 Review comment:
   done

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


With regards,
Apache Git Services

[GitHub] [ignite] andrey-kuznetsov commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
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_r397888751
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/ConnectionAndSslParameters.java
 ##########
 @@ -277,4 +285,20 @@ public String sslTrustStoreType() {
     public void sslTrustStorePassword(char[] sslTrustStorePassword) {
         this.sslTrustStorePassword = sslTrustStorePassword;
     }
+
+    /**
+     * @return {@code Map} User attributes.
 
 Review comment:
   ```suggestion
        * @return User attributes.
   ```

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


With regards,
Apache Git Services

[GitHub] [ignite] oleg-ostanin commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
oleg-ostanin 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_r398474306
 
 

 ##########
 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]))
 
 Review comment:
   fixed

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


With regards,
Apache Git Services

[GitHub] [ignite] oleg-ostanin commented on a change in pull request #7566: Ignite 12832

Posted by GitBox <gi...@apache.org>.
oleg-ostanin commented on a change in pull request #7566: Ignite 12832
URL: https://github.com/apache/ignite/pull/7566#discussion_r397728495
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/CommonArgParser.java
 ##########
 @@ -336,4 +374,52 @@ 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 extractAttributesFromString(Map<String, String> attrMap, String attrs) {
+        final int partsOfAttrStr = 2;
+
+        for (String attr : attrs.split(",")) {
+            if (!attr.contains("=")) {
+                logger.warning(String.format("Failed to parse attribute %s", attr));
+
+                continue;
+            }
+
+            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 extractAttributesFromFile(Map<String, String> attrMap, String path) {
+        Properties attrs = new Properties();
+
+        try (InputStream is = new FileInputStream(new File(path))) {
+            attrs.load(is);
+        } catch (Exception e) {
 
 Review comment:
   fixed

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


With regards,
Apache Git Services

[GitHub] [ignite] SomeFire commented on a change in pull request #7566: Ignite 12832

Posted by GitBox <gi...@apache.org>.
SomeFire commented on a change in pull request #7566: Ignite 12832
URL: https://github.com/apache/ignite/pull/7566#discussion_r397701133
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/ConnectionAndSslParameters.java
 ##########
 @@ -269,6 +275,13 @@ public String sslTrustStoreType() {
         return sslTrustStorePassword;
     }
 
+    /**
+     * @return {@code Map} User attributes.
+     */
+    public Map<String, String> userAttributes(){
 
 Review comment:
   Place getter after `sslTrustStorePassword()`.
   
   Need space before `{`.

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


With regards,
Apache Git Services

[GitHub] [ignite] oleg-ostanin commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
oleg-ostanin 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_r400868421
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/ConnectionAndSslParameters.java
 ##########
 @@ -71,6 +73,9 @@
     /** Truststore Password. */
     private char[] sslTrustStorePassword;
 
+    /** Truststore Password. */
 
 Review comment:
   done

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


With regards,
Apache Git Services

[GitHub] [ignite] pavlukhin commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
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_r399744965
 
 

 ##########
 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){
 
 Review comment:
   Space between `)` and `{` in the end of line.

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


With regards,
Apache Git Services

[GitHub] [ignite] oleg-ostanin commented on a change in pull request #7566: Ignite 12832

Posted by GitBox <gi...@apache.org>.
oleg-ostanin commented on a change in pull request #7566: Ignite 12832
URL: https://github.com/apache/ignite/pull/7566#discussion_r397727041
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/CommonArgParser.java
 ##########
 @@ -336,4 +374,52 @@ 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 extractAttributesFromString(Map<String, String> attrMap, String attrs) {
 
 Review comment:
   done

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


With regards,
Apache Git Services

[GitHub] [ignite] SomeFire commented on a change in pull request #7566: Ignite 12832

Posted by GitBox <gi...@apache.org>.
SomeFire commented on a change in pull request #7566: Ignite 12832
URL: https://github.com/apache/ignite/pull/7566#discussion_r397688716
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/CommonArgParser.java
 ##########
 @@ -336,4 +374,52 @@ 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 extractAttributesFromString(Map<String, String> attrMap, String attrs) {
+        final int partsOfAttrStr = 2;
+
+        for (String attr : attrs.split(",")) {
+            if (!attr.contains("=")) {
+                logger.warning(String.format("Failed to parse attribute %s", attr));
+
+                continue;
 
 Review comment:
   I think we shouldn't continue with broken configuration.

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


With regards,
Apache Git Services

[GitHub] [ignite] Sega76 commented on a change in pull request #7566: Ignite 12832

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #7566: Ignite 12832
URL: https://github.com/apache/ignite/pull/7566#discussion_r397662421
 
 

 ##########
 File path: modules/core/src/test/resources/user-attribute.properties
 ##########
 @@ -0,0 +1 @@
+attr3=val3
 
 Review comment:
   newline

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


With regards,
Apache Git Services

[GitHub] [ignite] oleg-ostanin commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
oleg-ostanin 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_r398468705
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/CommonArgParser.java
 ##########
 @@ -310,20 +333,36 @@ ConnectionAndSslParameters parseAndValidate(Iterator<String> rawArgIter) {
 
                         break;
 
+                    case CMD_USER_ATTR:
+                        userAttrStr = argIter.nextArg("Expected user attribute string.");
+
+                        break;
+
+                    case CMD_USER_ATTR_PATH:
+                        userAttrPath = argIter.nextArg("Expected user attribute file.");
+
+                        break;
+
                     default:
                         throw new IllegalArgumentException("Unexpected argument: " + str);
                 }
             }
         }
 
+        if (userAttrStr != null)
 
 Review comment:
   done

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


With regards,
Apache Git Services

[GitHub] [ignite] oleg-ostanin commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
oleg-ostanin 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_r399965245
 
 

 ##########
 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));
 
 Review comment:
   Yes, we are already throwing RuntimeException in case of unexpected property.
   
   The user will see error message like this:
   
   Control utility [ver. 2.9.0-SNAPSHOT#20200327-sha1:1ae99695]
   2020 Copyright(C) Apache Software Foundation
   User: olegostanin
   Time: 2020-03-30T09:54:56.505
   Warning: --keystore-password is insecure. Whenever possible, use interactive prompt for password (just discard --keystore-password option).
   Warning: --truststore-password is insecure. Whenever possible, use interactive prompt for password (just discard --truststore-password option).
   Failed to read property file: /path_to_the_file
   java.io.FileNotFoundException: /path_to_the_file (No such file or directory)
   Command [] finished with code: 4
   Control utility has completed execution at: 2020-03-30T09:54:56.522
   Execution time: 17 ms

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


With regards,
Apache Git Services

[GitHub] [ignite] SomeFire commented on a change in pull request #7566: Ignite 12832

Posted by GitBox <gi...@apache.org>.
SomeFire commented on a change in pull request #7566: Ignite 12832
URL: https://github.com/apache/ignite/pull/7566#discussion_r397700283
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/ConnectionAndSslParameters.java
 ##########
 @@ -17,8 +17,11 @@
 
 package org.apache.ignite.internal.commandline;
 
+import java.util.HashMap;
 import org.apache.ignite.internal.client.GridClientConfiguration;
 
+import java.util.Map;
 
 Review comment:
   Compact import to a single import block.

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


With regards,
Apache Git Services

[GitHub] [ignite] andrey-kuznetsov commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
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_r397889188
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/ConnectionAndSslParameters.java
 ##########
 @@ -277,4 +285,20 @@ public String sslTrustStoreType() {
     public void sslTrustStorePassword(char[] sslTrustStorePassword) {
         this.sslTrustStorePassword = sslTrustStorePassword;
     }
+
+    /**
+     * @return {@code Map} User attributes.
+     */
+    public Map<String, String> userAttributes() {
+        return userAttrs;
+    }
+
+    /**
+     * Set user attributes.
+     *
+     * @param userAttrs {@code Map} User attributes.
 
 Review comment:
   ```suggestion
        * @param userAttrs User attributes.
   ```

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


With regards,
Apache Git Services

[GitHub] [ignite] SomeFire commented on a change in pull request #7566: Ignite 12832

Posted by GitBox <gi...@apache.org>.
SomeFire commented on a change in pull request #7566: Ignite 12832
URL: https://github.com/apache/ignite/pull/7566#discussion_r397691441
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/CommonArgParser.java
 ##########
 @@ -336,4 +374,52 @@ 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 extractAttributesFromString(Map<String, String> attrMap, String attrs) {
+        final int partsOfAttrStr = 2;
+
+        for (String attr : attrs.split(",")) {
+            if (!attr.contains("=")) {
+                logger.warning(String.format("Failed to parse attribute %s", attr));
+
+                continue;
+            }
+
+            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 extractAttributesFromFile(Map<String, String> attrMap, String path) {
 
 Review comment:
   `parseUserAttributesFromFile`

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


With regards,
Apache Git Services

[GitHub] [ignite] andrey-kuznetsov commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
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_r397887739
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/ConnectionAndSslParameters.java
 ##########
 @@ -97,7 +102,8 @@ public ConnectionAndSslParameters(Command command, String host, String port, Str
         Long pingTimeout, Long pingInterval, boolean autoConfirmation,
         String sslProtocol, String sslCipherSuites, String sslKeyAlgorithm,
         String sslKeyStorePath, char[] sslKeyStorePassword, String sslKeyStoreType,
-        String sslTrustStorePath, char[] sslTrustStorePassword, String sslTrustStoreType
+        String sslTrustStorePath, char[] sslTrustStorePassword, String sslTrustStoreType,
+        Map<String, String> userAttrs
 
 Review comment:
   userAttr param should be described in javadoc.

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


With regards,
Apache Git Services

[GitHub] [ignite] oleg-ostanin commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
oleg-ostanin 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_r398449358
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/CommonArgParser.java
 ##########
 @@ -91,6 +99,12 @@
     /** */
     static final String CMD_TRUSTSTORE_TYPE = "--truststore-type";
 
+    /** */
+    static final String CMD_USER_ATTR = "--user-attributes";
 
 Review comment:
   renamed ATTRS to PROPS to avoid confusion with existing --user-attributes option

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


With regards,
Apache Git Services

[GitHub] [ignite] oleg-ostanin commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
oleg-ostanin 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_r398469234
 
 

 ##########
 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);
 
 Review comment:
   IMO 'property file' sounds more naturally.

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


With regards,
Apache Git Services

[GitHub] [ignite] pavlukhin commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
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_r399745076
 
 

 ##########
 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)
 
 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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] pavlukhin commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
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_r399744270
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/CommonArgParser.java
 ##########
 @@ -310,6 +331,16 @@ ConnectionAndSslParameters parseAndValidate(Iterator<String> rawArgIter) {
 
                         break;
 
+                    case CMD_USER_PROPS:
+                        userPropStr = argIter.nextArg("Expected user property string.");
+
+                        break;
+
+                    case CMD_USER_PROPS_PATH:
+                        userPropPath = argIter.nextArg("Expected user property path.");
 
 Review comment:
   Expected user property **file** path.

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


With regards,
Apache Git Services

[GitHub] [ignite] SomeFire commented on a change in pull request #7566: Ignite 12832

Posted by GitBox <gi...@apache.org>.
SomeFire commented on a change in pull request #7566: Ignite 12832
URL: https://github.com/apache/ignite/pull/7566#discussion_r397702072
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/ConnectionAndSslParameters.java
 ##########
 @@ -277,4 +290,15 @@ public String sslTrustStoreType() {
     public void sslTrustStorePassword(char[] sslTrustStorePassword) {
         this.sslTrustStorePassword = sslTrustStorePassword;
     }
+
+    /**
+     * Set user attributes.
+     *
+     * @param userAttrs user attributes.
+     */
+    public ConnectionAndSslParameters withUserAttributes(Map<String, String> userAttrs){
 
 Review comment:
   Use ignite style setter `userAttributes` here.
   
   Need space before `{`.

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


With regards,
Apache Git Services

[GitHub] [ignite] pavlukhin commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
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_r399744864
 
 

 ##########
 File path: modules/core/src/test/resources/user.properties
 ##########
 @@ -0,0 +1,19 @@
+#
 
 Review comment:
   I suggest to move this file to a package with a test using it. `user.properties` file in a resources root directory can look confusing.

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


With regards,
Apache Git Services

[GitHub] [ignite] andrey-kuznetsov commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
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_r397917579
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/CommonArgParser.java
 ##########
 @@ -91,6 +99,12 @@
     /** */
     static final String CMD_TRUSTSTORE_TYPE = "--truststore-type";
 
+    /** */
+    static final String CMD_USER_ATTR = "--user-attributes";
 
 Review comment:
   Here and below: ATTRS sounds better to me than ATTR.

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


With regards,
Apache Git Services

[GitHub] [ignite] oleg-ostanin commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
oleg-ostanin 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_r398474087
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/ConnectionAndSslParameters.java
 ##########
 @@ -277,4 +285,20 @@ public String sslTrustStoreType() {
     public void sslTrustStorePassword(char[] sslTrustStorePassword) {
         this.sslTrustStorePassword = sslTrustStorePassword;
     }
+
+    /**
+     * @return {@code Map} User attributes.
+     */
+    public Map<String, String> userAttributes() {
+        return userAttrs;
+    }
+
+    /**
+     * Set user attributes.
+     *
+     * @param userAttrs {@code Map} User attributes.
 
 Review comment:
   fixed

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


With regards,
Apache Git Services

[GitHub] [ignite] oleg-ostanin commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
oleg-ostanin 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_r398473538
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/ConnectionAndSslParameters.java
 ##########
 @@ -97,7 +102,8 @@ public ConnectionAndSslParameters(Command command, String host, String port, Str
         Long pingTimeout, Long pingInterval, boolean autoConfirmation,
         String sslProtocol, String sslCipherSuites, String sslKeyAlgorithm,
         String sslKeyStorePath, char[] sslKeyStorePassword, String sslKeyStoreType,
-        String sslTrustStorePath, char[] sslTrustStorePassword, String sslTrustStoreType
+        String sslTrustStorePath, char[] sslTrustStorePassword, String sslTrustStoreType,
+        Map<String, String> userAttrs
 
 Review comment:
   done

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


With regards,
Apache Git Services

[GitHub] [ignite] oleg-ostanin commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
oleg-ostanin 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_r400868531
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/commandline/CommandHandlerParsingTest.java
 ##########
 @@ -204,7 +215,9 @@ public void testFindAndDeleteGarbage() {
         return res;
     }
 
-    /** */
+    /**
+     *
 
 Review comment:
   done

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


With regards,
Apache Git Services

[GitHub] [ignite] SomeFire commented on a change in pull request #7566: Ignite 12832

Posted by GitBox <gi...@apache.org>.
SomeFire commented on a change in pull request #7566: Ignite 12832
URL: https://github.com/apache/ignite/pull/7566#discussion_r397675983
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/CommandHandler.java
 ##########
 @@ -462,6 +465,11 @@ else if (clientCfg.getSecurityCredentialsProvider() == null)
         if (!F.isEmpty(args.sslKeyStorePath()))
             clientCfg.setSslContextFactory(createSslSupportFactory(args));
 
+        if (clientCfg.getUserAttributes() == null)
 
 Review comment:
   Always true because we created a new configuration.

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


With regards,
Apache Git Services

[GitHub] [ignite] andrey-kuznetsov commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
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_r397918242
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/CommonArgParser.java
 ##########
 @@ -310,20 +333,36 @@ ConnectionAndSslParameters parseAndValidate(Iterator<String> rawArgIter) {
 
                         break;
 
+                    case CMD_USER_ATTR:
+                        userAttrStr = argIter.nextArg("Expected user attribute string.");
 
 Review comment:
   ```suggestion
                           userAttrStr = argIter.nextArg("Expected user attributes string.");
   ```

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


With regards,
Apache Git Services

[GitHub] [ignite] SomeFire commented on a change in pull request #7566: Ignite 12832

Posted by GitBox <gi...@apache.org>.
SomeFire commented on a change in pull request #7566: Ignite 12832
URL: https://github.com/apache/ignite/pull/7566#discussion_r397691970
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/CommonArgParser.java
 ##########
 @@ -336,4 +374,52 @@ 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 extractAttributesFromString(Map<String, String> attrMap, String attrs) {
+        final int partsOfAttrStr = 2;
+
+        for (String attr : attrs.split(",")) {
+            if (!attr.contains("=")) {
+                logger.warning(String.format("Failed to parse attribute %s", attr));
+
+                continue;
+            }
+
+            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 extractAttributesFromFile(Map<String, String> attrMap, String path) {
+        Properties attrs = new Properties();
+
+        try (InputStream is = new FileInputStream(new File(path))) {
+            attrs.load(is);
+        } catch (Exception e) {
 
 Review comment:
   `IOException e`

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


With regards,
Apache Git Services

[GitHub] [ignite] Sega76 commented on a change in pull request #7566: Ignite 12832

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #7566: Ignite 12832
URL: https://github.com/apache/ignite/pull/7566#discussion_r397646229
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/CommonArgParser.java
 ##########
 @@ -310,20 +332,38 @@ ConnectionAndSslParameters parseAndValidate(Iterator<String> rawArgIter) {
 
                         break;
 
+                    case CMD_USER_ATTR:
+                        userAttrStr = argIter.nextArg("Expected user attribute string.");
+                        ;
 
 Review comment:
   excess ';'

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


With regards,
Apache Git Services

[GitHub] [ignite] Sega76 commented on a change in pull request #7566: Ignite 12832

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #7566: Ignite 12832
URL: https://github.com/apache/ignite/pull/7566#discussion_r397652032
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/ConnectionAndSslParameters.java
 ##########
 @@ -71,6 +73,9 @@
     /** Truststore Password. */
     private char[] sslTrustStorePassword;
 
+    /** Truststore Password. */
 
 Review comment:
   rename comments

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


With regards,
Apache Git Services

[GitHub] [ignite] andrey-kuznetsov commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
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_r397920679
 
 

 ##########
 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);
 
 Review comment:
   ```suggestion
               logger.log(Level.SEVERE, "Failed to read properties file: " + path, e);
   ```

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


With regards,
Apache Git Services

[GitHub] [ignite] andrey-kuznetsov commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
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_r397918403
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/CommonArgParser.java
 ##########
 @@ -310,20 +333,36 @@ ConnectionAndSslParameters parseAndValidate(Iterator<String> rawArgIter) {
 
                         break;
 
+                    case CMD_USER_ATTR:
+                        userAttrStr = argIter.nextArg("Expected user attribute string.");
+
+                        break;
+
+                    case CMD_USER_ATTR_PATH:
+                        userAttrPath = argIter.nextArg("Expected user attribute file.");
 
 Review comment:
   ```suggestion
                           userAttrPath = argIter.nextArg("Expected user attributes file.");
   ```

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


With regards,
Apache Git Services

[GitHub] [ignite] oleg-ostanin commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
oleg-ostanin 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_r399970203
 
 

 ##########
 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)
 
 Review comment:
   fixed

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


With regards,
Apache Git Services

[GitHub] [ignite] andrey-kuznetsov commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
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_r397926653
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/CommonArgParser.java
 ##########
 @@ -310,20 +333,36 @@ ConnectionAndSslParameters parseAndValidate(Iterator<String> rawArgIter) {
 
                         break;
 
+                    case CMD_USER_ATTR:
+                        userAttrStr = argIter.nextArg("Expected user attribute string.");
+
+                        break;
+
+                    case CMD_USER_ATTR_PATH:
+                        userAttrPath = argIter.nextArg("Expected user attribute file.");
+
+                        break;
+
                     default:
                         throw new IllegalArgumentException("Unexpected argument: " + str);
                 }
             }
         }
 
+        if (userAttrStr != null)
 
 Review comment:
   I suggest turning parse* methods in pure functions returning maps. Then merge 2 maps explicitly. Then it will be obvious what attribute values take precedence (from command line or from properties file).

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


With regards,
Apache Git Services

[GitHub] [ignite] SomeFire commented on a change in pull request #7566: Ignite 12832

Posted by GitBox <gi...@apache.org>.
SomeFire commented on a change in pull request #7566: Ignite 12832
URL: https://github.com/apache/ignite/pull/7566#discussion_r397691332
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/CommonArgParser.java
 ##########
 @@ -336,4 +374,52 @@ 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 extractAttributesFromString(Map<String, String> attrMap, String attrs) {
 
 Review comment:
   `parseUserAttributesFromString`

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


With regards,
Apache Git Services

[GitHub] [ignite] oleg-ostanin commented on a change in pull request #7566: Ignite 12832

Posted by GitBox <gi...@apache.org>.
oleg-ostanin commented on a change in pull request #7566: Ignite 12832
URL: https://github.com/apache/ignite/pull/7566#discussion_r397726928
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/CommonArgParser.java
 ##########
 @@ -310,20 +332,36 @@ ConnectionAndSslParameters parseAndValidate(Iterator<String> rawArgIter) {
 
                         break;
 
+                    case CMD_USER_ATTR:
+                        userAttrStr = argIter.nextArg("Expected user attribute string.");
+
+                        break;
+
+                    case CMD_USER_ATTR_PATH:
+                        userAttrPath = argIter.nextArg("Expected user attribute file.");
+
+                        break;
+
                     default:
                         throw new IllegalArgumentException("Unexpected argument: " + str);
                 }
             }
         }
 
+        if (userAttrStr != null)
+            extractAttributesFromString(userAttrs, userAttrStr);
+
+        if (userAttrPath != null)
+            extractAttributesFromFile(userAttrs, userAttrPath);
+
         if (command == null)
             throw new IllegalArgumentException("No action was specified");
 
         return new ConnectionAndSslParameters(command.command(), host, port, user, pwd,
                 pingTimeout, pingInterval, autoConfirmation,
                 sslProtocol, sslCipherSuites,
                 sslKeyAlgorithm, sslKeyStorePath, sslKeyStorePassword, sslKeyStoreType,
-                sslTrustStorePath, sslTrustStorePassword, sslTrustStoreType);
+                sslTrustStorePath, sslTrustStorePassword, sslTrustStoreType).withUserAttributes(userAttrs);
 
 Review comment:
   done

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


With regards,
Apache Git Services

[GitHub] [ignite] SomeFire commented on a change in pull request #7566: Ignite 12832

Posted by GitBox <gi...@apache.org>.
SomeFire commented on a change in pull request #7566: Ignite 12832
URL: https://github.com/apache/ignite/pull/7566#discussion_r397678353
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/commandline/CommonArgParser.java
 ##########
 @@ -310,20 +332,36 @@ ConnectionAndSslParameters parseAndValidate(Iterator<String> rawArgIter) {
 
                         break;
 
+                    case CMD_USER_ATTR:
+                        userAttrStr = argIter.nextArg("Expected user attribute string.");
+
+                        break;
+
+                    case CMD_USER_ATTR_PATH:
+                        userAttrPath = argIter.nextArg("Expected user attribute file.");
+
+                        break;
+
                     default:
                         throw new IllegalArgumentException("Unexpected argument: " + str);
                 }
             }
         }
 
+        if (userAttrStr != null)
+            extractAttributesFromString(userAttrs, userAttrStr);
+
+        if (userAttrPath != null)
+            extractAttributesFromFile(userAttrs, userAttrPath);
+
         if (command == null)
             throw new IllegalArgumentException("No action was specified");
 
         return new ConnectionAndSslParameters(command.command(), host, port, user, pwd,
                 pingTimeout, pingInterval, autoConfirmation,
                 sslProtocol, sslCipherSuites,
                 sslKeyAlgorithm, sslKeyStorePath, sslKeyStorePassword, sslKeyStoreType,
-                sslTrustStorePath, sslTrustStorePassword, sslTrustStoreType);
+                sslTrustStorePath, sslTrustStorePassword, sslTrustStoreType).withUserAttributes(userAttrs);
 
 Review comment:
   Additional constructor argument will be looks better (similar to other params).

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


With regards,
Apache Git Services

[GitHub] [ignite] andrey-kuznetsov commented on a change in pull request #7566: IGNITE-12832 Add user attributes support to control.sh

Posted by GitBox <gi...@apache.org>.
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_r397925118
 
 

 ##########
 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]))
 
 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:
users@infra.apache.org


With regards,
Apache Git Services