[GitHub] [ignite] SomeFire commented on a change in pull request #7566: Ignite 12832
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 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [ignite] SomeFire commented on a change in pull request #7566: Ignite 12832
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 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 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 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [ignite] SomeFire commented on a change in pull request #7566: Ignite 12832
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 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [ignite] SomeFire commented on a change in pull request #7566: Ignite 12832
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 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [ignite] SomeFire commented on a change in pull request #7566: Ignite 12832
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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [ignite] SomeFire commented on a change in pull request #7566: Ignite 12832
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 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 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [ignite] SomeFire commented on a change in pull request #7566: Ignite 12832
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 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 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [ignite] SomeFire commented on a change in pull request #7566: Ignite 12832
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 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [ignite] SomeFire commented on a change in pull request #7566: Ignite 12832
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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [ignite] SomeFire commented on a change in pull request #7566: Ignite 12832
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 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: us...@infra.apache.org With regards, Apache Git Services