You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by zentol <gi...@git.apache.org> on 2016/08/31 15:50:16 UTC

[GitHub] flink pull request #2445: [FLINK-4544] Refactor old CPU metric initializatio...

GitHub user zentol opened a pull request:

    https://github.com/apache/flink/pull/2445

    [FLINK-4544] Refactor old CPU metric initialization

    This PR refactors the old CPU metric initialization code to no longer rely on reflection.
    
    Instead it eagerly casts the `OperatingSystemMXBean` returned by `ManagementFactory#getOperationSystemMXBean()` to `com.sun.management.OperatingSystemMXBean`. Should this succeed it is now guaranteed that the gauge will not throw a `ClassCastException` since it doesn't have to cast anything; if it fails a dummy Gauge is registered that returns -1 in order to retain existing behavior.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/zentol/flink 4544_tm_cpu

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/flink/pull/2445.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #2445
    
----
commit 51ff47711cde8d32d8d0b6d2abf3bd264d207342
Author: zentol <ch...@apache.org>
Date:   2016-08-31T15:46:10Z

    [FLINK-4544] Refactor old CPU metric initialization

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink issue #2445: [FLINK-4544] Refactor old CPU metric initialization

Posted by StephanEwen <gi...@git.apache.org>.
Github user StephanEwen commented on the issue:

    https://github.com/apache/flink/pull/2445
  
    Does this work? The reason for the initial reflection-based initialization was that the sun-specific class may not be available in some environments. I am unsure when the "ClassNotFound" error will be thrown. Upon loading of the TaskManager? Or upon running the code that installs the Gauge. I fear it may be thrown earlier than when the Gauge is created.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink issue #2445: [FLINK-4544] Refactor old CPU metric initialization

Posted by zentol <gi...@git.apache.org>.
Github user zentol commented on the issue:

    https://github.com/apache/flink/pull/2445
  
    that should be doable, yes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink issue #2445: [FLINK-4544] Refactor old CPU metric initialization

Posted by StephanEwen <gi...@git.apache.org>.
Github user StephanEwen commented on the issue:

    https://github.com/apache/flink/pull/2445
  
    Can we move this code out of the TaskManager as a whole, into a metrics Utility?
    We could make it reusable for the JobManager as well, by passing the metric group where that should be added.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #2445: [FLINK-4544] Refactor old CPU metric initializatio...

Posted by zentol <gi...@git.apache.org>.
Github user zentol closed the pull request at:

    https://github.com/apache/flink/pull/2445


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink issue #2445: [FLINK-4544] Refactor old CPU metric initialization

Posted by zentol <gi...@git.apache.org>.
Github user zentol commented on the issue:

    https://github.com/apache/flink/pull/2445
  
    But i see the issue that could arise, will rework the solution.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink issue #2445: [FLINK-4544] Refactor old CPU metric initialization

Posted by zentol <gi...@git.apache.org>.
Github user zentol commented on the issue:

    https://github.com/apache/flink/pull/2445
  
    @StephanEwen I moved the code into a separate class.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink issue #2445: [FLINK-4544] Refactor old CPU metric initialization

Posted by StephanEwen <gi...@git.apache.org>.
Github user StephanEwen commented on the issue:

    https://github.com/apache/flink/pull/2445
  
    The approach looks good, but I think it would be good to adjust a few things:
      - We are migrating most of the Scala code in `flink-runtime` to Java (for example in FLIP-6), so would be good if this new code was also Java
      - Some of the Gauges use some form of JMX querying (`getAttribute(ObjectName)`) that looks more expensive then directly accessing a bean (calling a method)
      - Some metrics may not be available on all JVMs (like mapped direct memory). Can this make sure we don't log an exception on each access to the Gauge, when the JMX query fails?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink issue #2445: [FLINK-4544] Refactor old CPU metric initialization

Posted by zentol <gi...@git.apache.org>.
Github user zentol commented on the issue:

    https://github.com/apache/flink/pull/2445
  
    Version 2 is up. Essentially, we now attempt to use the methods before registering the metrics. I've also adjusted the new CPU metrics.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink issue #2445: [FLINK-4544] Refactor old CPU metric initialization

Posted by zentol <gi...@git.apache.org>.
Github user zentol commented on the issue:

    https://github.com/apache/flink/pull/2445
  
    This is the pretty-much same code that the new CPU metric uses which has not caused issues so far.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---