Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FLINK-14070] [runtime] Use TimeUtils to parse duration configs in flink-runtime #9745

Closed

Conversation

zhuzhurk
Copy link
Contributor

What is the purpose of the change

TimeUtils now can parse all duration configs supported by scala FiniteDuration.
And we'd like to use it to replace scala Duration for duration config parsing.

This is one step to make flink-runtime scala free.

Brief change log

  • The duration configs in flink-runtime are now parsed using TimeUtils#parseDuration

Verifying this change

This change is already covered by existing tests of changed components.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): (yes / no)
  • The public API, i.e., is any changed class annotated with @Public(Evolving): (yes / no)
  • The serializers: (yes / no / don't know)
  • The runtime per-record code paths (performance sensitive): (yes / no / don't know)
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Yarn/Mesos, ZooKeeper: (yes / no / don't know)
  • The S3 file system connector: (yes / no / don't know)

Documentation

  • Does this pull request introduce a new feature? (yes / no)
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)

@flinkbot
Copy link
Collaborator

flinkbot commented Sep 23, 2019

Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
to review your pull request. We will use this comment to track the progress of the review.

Automated Checks

Last check on commit 8097abd (Wed Oct 16 08:28:53 UTC 2019)

Warnings:

  • No documentation files were touched! Remember to keep the Flink docs up to date!

Mention the bot in a comment to re-run the automated checks.

Review Progress

  • ❓ 1. The [description] looks good.
  • ❓ 2. There is [consensus] that the contribution should go into to Flink.
  • ❓ 3. Needs [attention] from.
  • ❓ 4. The change fits into the overall [architecture].
  • ❓ 5. Overall code [quality] is good.

Please see the Pull Request Review Guide for a full explanation of the review process.


The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required Bot commands
The @flinkbot bot supports the following commands:

  • @flinkbot approve description to approve one or more aspects (aspects: description, consensus, architecture and quality)
  • @flinkbot approve all to approve all aspects
  • @flinkbot approve-until architecture to approve everything until architecture
  • @flinkbot attention @username1 [@username2 ..] to require somebody's attention
  • @flinkbot disapprove architecture to remove an approval you gave earlier

@flinkbot
Copy link
Collaborator

flinkbot commented Sep 23, 2019

CI report:

@@ -49,8 +51,6 @@ import scala.language.postfixOps
object AkkaUtils {
Copy link
Contributor Author

@zhuzhurk zhuzhurk Sep 23, 2019

Choose a reason for hiding this comment

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

The parsing of akka configs are not replaced by TimeUtils.parseDuration(..), since they are directly used for ActorSystem creation.
The only exception is "akka.ask.timeout" which is also widely used as Flink RPC timeout config. So I parsed it with TimeUtils only when it is used by Flink components (in AkkaUtils#getTimeout). It is still parsed by scala Duration when used by akka (in AkkaUtils#getRemoteAkkaConfig).
The configs "akka.lookup.timeout" and "akka.client.timeout" are actually not akka configs. They are only used by Flink components so the parsing logics for them are updated.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it hurt to replace https://github.com/apache/flink/blob/master/flink-runtime/src/main/scala/org/apache/flink/runtime/akka/AkkaUtils.scala#L400 with val akkaAskTimeout = Duration(getTimeout(configuration).toMillis, TimeUnit.MILLISECONDS)? The benefit would be that we don't use two mechanisms for parsing. Consequently, these two mechanism don't need to stay in sync in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I gave it a thought again and I think we can replace them.

The concern was that scala Duration supports infinite values like Inf, +Inf, etc. Replacing the parsing may break jobs specifying infinite values. However, since we never mentioned infinite durations in the config descriptors, I think we can treat them as finite durations and throw errors for infinite values.

Besides that, do you think we should parse the other duration configs (e.g. "akka.tcp.timeout") which were treated as string and directly set to Akka configs? Parsing them can help to do an early check, rather than expecting Akka to fail due to bad configs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A hotfix is added to convert akka duration configs to akka recognizable duration format.
Given that "these two mechanism don't need to stay in sync in the future" and TimeUtils currently supports non-labeled config, I think the hotfix is necessary.

@zhuzhurk zhuzhurk force-pushed the FLINK_14070_duration_config_parsing branch 3 times, most recently from cdc9812 to b0cd94b Compare September 24, 2019 08:47
@zhuzhurk zhuzhurk force-pushed the FLINK_14070_duration_config_parsing branch from b0cd94b to 156dcfe Compare September 24, 2019 09:56
@tillrohrmann tillrohrmann self-assigned this Sep 24, 2019
Copy link
Contributor

@tillrohrmann tillrohrmann left a comment

Choose a reason for hiding this comment

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

Thanks for reducing flink-runtime's Scala dependency @zhuzhurk. The change looks good to me. I had a couple of minor comments and a question whether we should not also use AkkaUtils#getTimeout in #getRemoteAkkaConfig.


new FiniteDuration(duration.toMillis, TimeUnit.MILLISECONDS)
def getTimeout(config: Configuration): time.Duration = {
return TimeUtils.parseDuration(config.getString(AkkaOptions.ASK_TIMEOUT))
Copy link
Contributor

Choose a reason for hiding this comment

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

return is not needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.


new FiniteDuration(duration.toMillis, TimeUnit.MILLISECONDS)
def getLookupTimeout(config: Configuration): time.Duration = {
return TimeUtils.parseDuration(config.getString(AkkaOptions.LOOKUP_TIMEOUT))
Copy link
Contributor

Choose a reason for hiding this comment

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

same here with return

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.


new FiniteDuration(duration.toMillis, TimeUnit.MILLISECONDS)
def getClientTimeout(config: Configuration): time.Duration = {
return TimeUtils.parseDuration(config.getString(AkkaOptions.CLIENT_TIMEOUT))
Copy link
Contributor

Choose a reason for hiding this comment

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

and here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

@@ -49,8 +51,6 @@ import scala.language.postfixOps
object AkkaUtils {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it hurt to replace https://github.com/apache/flink/blob/master/flink-runtime/src/main/scala/org/apache/flink/runtime/akka/AkkaUtils.scala#L400 with val akkaAskTimeout = Duration(getTimeout(configuration).toMillis, TimeUnit.MILLISECONDS)? The benefit would be that we don't use two mechanisms for parsing. Consequently, these two mechanism don't need to stay in sync in the future.

Copy link
Contributor

@tillrohrmann tillrohrmann left a comment

Choose a reason for hiding this comment

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

Thanks for the fixups @zhuzhurk. LGTM. Merging now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants