Skip to content

Conversation

@hmcc
Copy link
Contributor

@hmcc hmcc commented Apr 22, 2017

Addresses https://issues.apache.org/jira/browse/STORM-2421 by:

  • changing the annotation on DaemonConfig childopts to isStringOrStringList
  • providing a utility method to read such values as a space-separated string

@harshach
Copy link
Contributor

+1.

* @throws IllegalArgumentException if conf is null
* @throws NullPointerException if name is null and the conf map doesn't support null keys
*/
public static String getConfigValueAsString(String name, Map<?, ?> conf) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are going to a common type for *childopts it should be a List<String> not String. The reason for a list is that something with whitespace in it can be properly represented this breaks that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@revans2 You mean, replace this method with

public static String getConfigValueAsList(String name, Map<?, ?> conf) {
    // if the value is a list, return it
    // if the value is a string, split it by space and return the resulting list
}

and the caller can convert it to a space-separated string if needed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hmcc Yes, except the caller should not be converting it to a space separated string because it will break some use cases.

@erikdw
Copy link
Contributor

erikdw commented Apr 29, 2017

@hmcc : I put a comment in the bug -- the problem isn't sufficiently specified IMHO.

@hmcc
Copy link
Contributor Author

hmcc commented May 18, 2017

#2112 makes most of the checkstyle changes unnecessary, which is great! Rebased & squashed commits.

Copy link
Contributor

@revans2 revans2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Overall it looks really good, but one minor nit that you can probably ignore if you want to. In the future I would love to see configValue replaced as it cannot express anything but a very simple type, and it only outputs a single value at a time. But it works OK for now, and it is probably big enough that it would need a separate JIRA.

* @throws IllegalArgumentException if conf is null
* @throws NullPointerException if name is null and the conf map doesn't support null keys
*/
public static List<String> getValueAsList(String name, Map<?, ?> conf) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit: we tend to use Map<String, Object> for conf.

@mal
Copy link
Contributor

mal commented May 20, 2017

Any hope of this getting backported into 1.0.x?

@revans2
Copy link
Contributor

revans2 commented May 22, 2017

@hmcc looks like there is a merge conflict now. If you could resolve it I would be happy to check this in.

@hmcc hmcc force-pushed the STORM-2421 branch 2 times, most recently from 08d72da to d618cae Compare May 27, 2017 13:03
@HeartSaVioR
Copy link
Contributor

@hmcc I'm really sorry but there's another merge conflict now. Please resolve this and mention me so that I can check this in soon.

@mal
Copy link
Contributor

mal commented Jun 22, 2017

Not sure how serious this is considered, but I figured I'd raise it for discussion just in case:

if the value is a string, split it by space and return the resulting list

Does this not risk breaking backwards compat in cases where the current value is a string containing arguments with spaces?

// i.e.
-foo "hello world" => ["-foo", "\"hello", "world\""]
// or a more contrived example
-padding "     "   => ["-padding", "\"", "\""]

Perhaps there's an existing CLI parser better suited to handling the conversion to List<String>?

@revans2
Copy link
Contributor

revans2 commented Jun 22, 2017

@mal that is not an issue right now. There are a lot of changes to the code, but most of that is creating some common helper methods and refactoring. The only configs really impacted by this change are the daemon childopts {nimbus,drpc,pacemaker,logviewer,ui}.childopts these were all really just read by storm.py by way of the ConfigValue command. Which would then parse them using

https://github.com/apache/storm/blob/master/bin/storm.py#L217-L234

the old code just output the value by calling .toString on it, but the new ConfigValue will first check if it is a list and stitch it back together into a String. So

"-foo \"hello world\"" => "-foo \"hello world\"" => ["-foo", "hello world"]
"-padding \"     \""   => "-padding \"     \""  => ["-padding", "     "]

but

["-foo", "hello world"] => "-foo hello world" => ["-foo", "hello", "world"]
["-padding", "    "] => "-padding     " => ["-padding"]

This is not ideal, I agree. Ultimately we need to add in an option to storm config to print out the config as a JSON string, or a set of JSON strings. Then have storm.py parse it properly and add in the arguments the right way to respect white space instead of what is happening right now.

@HeartSaVioR
Copy link
Contributor

+1

@asfgit asfgit merged commit 9858a60 into apache:master Jun 30, 2017
@hmcc hmcc deleted the STORM-2421 branch August 12, 2017 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants