[ 
https://issues.apache.org/jira/browse/FLINK-13406?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16909002#comment-16909002
 ] 

Chesnay Schepler commented on FLINK-13406:
------------------------------------------

Not necessarily.

So let's go through all scenarios:

# An actual cluster, with a job submitted through the CLI, with only the 
flink-conf.yaml as an input for config parameters.
In this case, the Configuration only contains strings, the MetricConfig only 
contains strings, and everything works as expected.
This is the case that the current code was written for.
# A local cluster, where a custom Configuration was passed to the 
ExecutionEnvironment.
Here, the Configuration may contain values that are not strings, in turn the 
MetricConfig may contain values that are not strings, and reporters may run 
into issues when trying to retrieve a non-string value. This is the originally 
reported issue.
# A MetricConfig is manually created by putting in arbitrary objects.
The MetricConfig does not do any type conversions, and reporters may run into 
the same issues as in 2).
This case should mostly apply to unit tests.

So, with that said:

Changing the Configuration, or the transformation of Configuration -> 
MetricConfig can only cover case 2). I would regard this option as undesirable 
for that reason, although I would generally prefer if the Configuration were 
entirely based on strings. (But IIRC the Streaming API does some funky things 
with the Configuration, so I don't know how feasible this is).

Thus we effectively have to touch the MetricConfig instead, and there are 2 
approaches we can opt for:
# Sanitize inputs; override all methods that add entries and convert objects to 
strings if necessary.
# Beef up accessors, to account for cases where properties may not be strings. 
(Basically, if (property is String) -> parse; elif (property is targetType) -> 
return; else -> fail)

Or, we just don't do anything and attribute it to user error.



> MetricConfig.getInteger() always returns null
> ---------------------------------------------
>
>                 Key: FLINK-13406
>                 URL: https://issues.apache.org/jira/browse/FLINK-13406
>             Project: Flink
>          Issue Type: Bug
>          Components: Runtime / Metrics
>    Affects Versions: 1.6.3
>            Reporter: Ori Popowski
>            Priority: Minor
>
> {{MetricConfig}}'s {{getInteger}} will always return the default value.
> The reason is, since it delegates to Java's {{Properties.getProperty}} which 
> returns null if the type of the value is not {{String}}.
> h3. Reproduce
>  # Create a class {{MyReporter}} implementing {{MetricReporter}}
>  # Implment the {{open()}} method so that you do {{config.getInteger("foo", 
> null)}}
>  # Start an {{ExecutionEnvironment}} with and give it the following 
> Configuration object:
> {code:java}
> configuration.setString("metrics.reporters", "my");
> configuration.setClass("metrics.reporter.my.class", MyReporter.class)
> configuration.setInteger("metrics.reporter.my.foo", 42);{code}
>  # In {{open()}} the value of {{foo}} is null.



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

Reply via email to