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-8160]Extend OperatorHarness to expose... #6047

Closed
wants to merge 5 commits into from

Conversation

wangtuo21
Copy link

@wangtuo21 wangtuo21 commented May 19, 2018

...metricsGroup

What is the purpose of the change

To better test interactions between operators and metrics the harness should expose the metrics registered by the operator.

Brief change log

add method getMetricGroup() to class AbstractStreamOperatorTestHarness

Verifying this change

This change is a trivial rework / code cleanup without any test coverage.

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

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

Documentation

  • Does this pull request introduce a new feature? no

@zentol
Copy link
Contributor

zentol commented May 22, 2018

Please explain how this solution allows the user of a AbstractStreamOperatorTestHarness to access the metrics registered by the contained operator.

@wangtuo21
Copy link
Author

@zentol , I misunderstood the request. Does it go in the right direction now? Thank you

@zentol
Copy link
Contributor

zentol commented Jun 4, 2018

No, this still doesn't work.

The MetricGroup you're trying to expose is created in AbstractStreamOperator#setup. However, the parent MetricGroup retrieved through Environment#getMetricGroup is null since this method is never mocked for the MockEnvironment in AbstractStreamOperatorTestHarness. Thus, in AbstractStreamOperator#setup we're entering the fail-safe block which creates a dummy MetricGroup that never stores anything.
As such no metric can actually be retrieved from the MetricGroup.

Please, ask questions if you don't know to fix an issue or verify the fix. And at the very least try it out once, otherwise you're just wasting the committers' time.

For a proper solution you have to create a TaskMetricGroup in the AbstractStreamOperatorTestHarness, which you then use in the MockEnvironment by returning it from Environment#getMetricGroup
With this scheme however metrics are only available while the task hasn't been closed (as metrics are cleaned up), so for better usability your TaskMetricGroup must override TaskMetricGroup#getOperator to return a special OperatorMetricGroup that also stores registered metrics in the AbstractStreamOperatorTestHarness. We do not store them indefinitely in the OperatorMetricGroup since that would change one of the core behaviors of the MetricGroup. Finally, add a getMetrics method to the AbstractStreamOperatorTestHarness to actually access registered metrics.

asfgit pushed a commit that referenced this pull request Jul 3, 2018
@asfgit asfgit closed this in 8c15d37 Jul 3, 2018
asfgit pushed a commit that referenced this pull request Jul 3, 2018
sampathBhat pushed a commit to sampathBhat/flink that referenced this pull request Jul 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants