You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by ash211 <gi...@git.apache.org> on 2017/03/23 20:43:45 UTC

[GitHub] spark pull request #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffl...

GitHub user ash211 opened a pull request:

    https://github.com/apache/spark/pull/17401

    [SPARK-18364][YARN] Expose metrics for YarnShuffleService

    Registers the shuffle server's metrics with the Hadoop Node Manager's
    DefaultMetricsSystem.
    
    ## What changes were proposed in this pull request?
    
    Expose the shuffle service metrics not only on the ExternalShuffleService as done in SPARK-16405, but also in the YarnShuffleService.  Because the YARN Node Manager operates under
    
    ## How was this patch tested?
    
    Manual deploy of new yarn-shuffle jar into a Node Manager and verifying that the metrics appear in the Node Manager-standard location.  This is JMX with an query endpoint at `/jmx`.
    
    Resulting metrics look like this:
    
    ```
    [user@host ~]$ curl -sk -XGET https://`hostname -f`:8042/jmx | jq . | grep 'shuffleservice' -B 1 -A 18
        {
          "name": "Hadoop:service=NodeManager,name=shuffleservice",
          "modelerType": "shuffleservice",
          "tag.Hostname": "<redacted>",
          "openBlockRequestLatencyMillis_count": 1,
          "openBlockRequestLatencyMillis_rate15": 0.0011080303990206543,
          "openBlockRequestLatencyMillis_rate5": 0.0033057092356765017,
          "openBlockRequestLatencyMillis_rate1": 0.015991117074135343,
          "openBlockRequestLatencyMillis_rateMean": 0.003843993699021382,
          "blockTransferRateBytes_count": 118,
          "blockTransferRateBytes_rate15": 0.1307475870844372,
          "blockTransferRateBytes_rate5": 0.39007368980982715,
          "blockTransferRateBytes_rate1": 1.8869518147479705,
          "blockTransferRateBytes_rateMean": 0.45359183094454836,
          "registeredExecutorsSize": 2,
          "registerExecutorRequestLatencyMillis_count": 2,
          "registerExecutorRequestLatencyMillis_rate15": 0.001697343764758814,
          "registerExecutorRequestLatencyMillis_rate5": 0.002970701813078509,
          "registerExecutorRequestLatencyMillis_rate1": 0.0005857750515146702,
          "registerExecutorRequestLatencyMillis_rateMean": 0.007687995987242345
        },
    [user@host ~]$
    ```

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

    $ git pull https://github.com/ash211/spark spark-18364

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

    https://github.com/apache/spark/pull/17401.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 #17401
    
----
commit 4caf4d28819d82240f1d61e11cdabd68fafad14a
Author: Andrew Ash <an...@andrewash.com>
Date:   2017-03-23T02:59:38Z

    [SPARK-18364][YARN] Expose metrics for YarnShuffleService
    
    Registers the shuffle server's metrics with the Hadoop Node Manager's
    DefaultMetricsSystem.

----


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffleServic...

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

    https://github.com/apache/spark/pull/17401
  
    @jerryshao ready for re-review


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffleServic...

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

    https://github.com/apache/spark/pull/17401
  
    Ready for further review.


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffleServic...

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

    https://github.com/apache/spark/pull/17401
  
    Thanks again for the comments @jerryshao !  I've now added some tests to verify that the metrics get converted in the expected way to the collector, and camel-cased shuffleService


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffl...

Posted by jerryshao <gi...@git.apache.org>.
Github user jerryshao commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17401#discussion_r107840363
  
    --- Diff: common/network-yarn/src/main/java/org/apache/spark/network/yarn/YarnShuffleServiceMetrics.java ---
    @@ -0,0 +1,118 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.network.yarn;
    +
    +import com.codahale.metrics.*;
    +import org.apache.hadoop.metrics2.MetricsCollector;
    +import org.apache.hadoop.metrics2.MetricsInfo;
    +import org.apache.hadoop.metrics2.MetricsRecordBuilder;
    +import org.apache.hadoop.metrics2.MetricsSource;
    +
    +import java.util.Map;
    +
    +/**
    + * Modeled off of YARN's NodeManagerMetrics.
    + */
    +public class YarnShuffleServiceMetrics implements MetricsSource {
    +
    +  private final MetricSet metricSet;
    +
    +  public YarnShuffleServiceMetrics(MetricSet metricSet) {
    +    this.metricSet = metricSet;
    +  }
    +
    +  /**
    +   * Get metrics from the source
    +   *
    +   * @param collector to contain the resulting metrics snapshot
    +   * @param all       if true, return all metrics even if unchanged.
    +   */
    +  @Override
    +  public void getMetrics(MetricsCollector collector, boolean all) {
    --- End diff --
    
    Yes, you're right. From my understanding the correctness means `Gauge` still coverts to `Gauge`, `Meter` still to `Meter`, not sure can it be guaranteed?


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffleServic...

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

    https://github.com/apache/spark/pull/17401
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/75150/
    Test PASSed.


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffleServic...

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

    https://github.com/apache/spark/pull/17401
  
    **[Test build #75150 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/75150/testReport)** for PR 17401 at commit [`13aa4ff`](https://github.com/apache/spark/commit/13aa4ff86038d706e7f3c3dfff449c6e762205f3).


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffleServic...

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

    https://github.com/apache/spark/pull/17401
  
    Actually we follow two space indent for java code in Spark, would you please change the format?


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffl...

Posted by ash211 <gi...@git.apache.org>.
Github user ash211 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17401#discussion_r107840148
  
    --- Diff: common/network-yarn/src/main/java/org/apache/spark/network/yarn/YarnShuffleServiceMetrics.java ---
    @@ -0,0 +1,118 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.network.yarn;
    +
    +import com.codahale.metrics.*;
    +import org.apache.hadoop.metrics2.MetricsCollector;
    +import org.apache.hadoop.metrics2.MetricsInfo;
    +import org.apache.hadoop.metrics2.MetricsRecordBuilder;
    +import org.apache.hadoop.metrics2.MetricsSource;
    +
    +import java.util.Map;
    +
    +/**
    + * Modeled off of YARN's NodeManagerMetrics.
    + */
    +public class YarnShuffleServiceMetrics implements MetricsSource {
    +
    +  private final MetricSet metricSet;
    +
    +  public YarnShuffleServiceMetrics(MetricSet metricSet) {
    +    this.metricSet = metricSet;
    +  }
    +
    +  /**
    +   * Get metrics from the source
    +   *
    +   * @param collector to contain the resulting metrics snapshot
    +   * @param all       if true, return all metrics even if unchanged.
    +   */
    +  @Override
    +  public void getMetrics(MetricsCollector collector, boolean all) {
    --- End diff --
    
    should be able to, I'm working on creating one now.  By correctness, I think you mostly mean that the values passed through are the same, even though the naming schemes are different?


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffl...

Posted by jerryshao <gi...@git.apache.org>.
Github user jerryshao commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17401#discussion_r109916009
  
    --- Diff: common/network-yarn/src/main/java/org/apache/spark/network/yarn/YarnShuffleServiceMetrics.java ---
    @@ -0,0 +1,123 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.network.yarn;
    +
    +import com.codahale.metrics.*;
    +import com.google.common.annotations.VisibleForTesting;
    +import org.apache.hadoop.metrics2.MetricsCollector;
    +import org.apache.hadoop.metrics2.MetricsInfo;
    +import org.apache.hadoop.metrics2.MetricsRecordBuilder;
    +import org.apache.hadoop.metrics2.MetricsSource;
    +
    +import java.util.Map;
    +
    +/**
    + * Modeled off of YARN's NodeManagerMetrics.
    + */
    +public class YarnShuffleServiceMetrics implements MetricsSource {
    +
    +  private final MetricSet metricSet;
    +
    +  public YarnShuffleServiceMetrics(MetricSet metricSet) {
    +    this.metricSet = metricSet;
    +  }
    +
    +  /**
    +   * Get metrics from the source
    +   *
    +   * @param collector to contain the resulting metrics snapshot
    +   * @param all       if true, return all metrics even if unchanged.
    +   */
    +  @Override
    +  public void getMetrics(MetricsCollector collector, boolean all) {
    +    MetricsRecordBuilder metricsRecordBuilder = collector.addRecord("shuffleService");
    +
    +    for (Map.Entry<String, Metric> entry : metricSet.getMetrics().entrySet()) {
    +      collectMetric(metricsRecordBuilder, entry.getKey(), entry.getValue());
    +    }
    +  }
    +
    +  @VisibleForTesting
    --- End diff --
    
    Also here.


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffleServic...

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

    https://github.com/apache/spark/pull/17401
  
    **[Test build #75115 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/75115/testReport)** for PR 17401 at commit [`4caf4d2`](https://github.com/apache/spark/commit/4caf4d28819d82240f1d61e11cdabd68fafad14a).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `public class YarnShuffleServiceMetrics implements MetricsSource `


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffl...

Posted by jerryshao <gi...@git.apache.org>.
Github user jerryshao commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17401#discussion_r108120305
  
    --- Diff: common/network-yarn/src/main/java/org/apache/spark/network/yarn/YarnShuffleService.java ---
    @@ -166,6 +170,23 @@ protected void serviceInit(Configuration conf) throws Exception {
           TransportConf transportConf = new TransportConf("shuffle", new HadoopConfigProvider(conf));
           blockHandler = new ExternalShuffleBlockHandler(transportConf, registeredExecutorFile);
     
    +      // register metrics on the block handler into the Node Manager's metrics system.
    +      try {
    +        YarnShuffleServiceMetrics serviceMetrics = new YarnShuffleServiceMetrics(
    +          blockHandler.getAllMetrics());
    +        MetricsSystemImpl metricsSystem = (MetricsSystemImpl) DefaultMetricsSystem.instance();
    +
    +        Method registerSourceMethod = metricsSystem.getClass().getDeclaredMethod("registerSource",
    +                String.class, String.class, MetricsSource.class);
    --- End diff --
    
    Nit, here I think should be 2 space indent follow the previous line.


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffleServic...

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

    https://github.com/apache/spark/pull/17401
  
    **[Test build #75165 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/75165/testReport)** for PR 17401 at commit [`96a0882`](https://github.com/apache/spark/commit/96a0882843e9072bb2ef02ee798a6e5d2f0a41b0).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffleServic...

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

    https://github.com/apache/spark/pull/17401
  
    Merged build finished. Test FAILed.


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffleServic...

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

    https://github.com/apache/spark/pull/17401
  
    Merged build finished. Test PASSed.


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffleServic...

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

    https://github.com/apache/spark/pull/17401
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/75322/
    Test PASSed.


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffleServic...

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

    https://github.com/apache/spark/pull/17401
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/75115/
    Test PASSed.


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffl...

Posted by jerryshao <gi...@git.apache.org>.
Github user jerryshao commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17401#discussion_r107838311
  
    --- Diff: common/network-yarn/src/main/java/org/apache/spark/network/yarn/YarnShuffleService.java ---
    @@ -166,6 +170,23 @@ protected void serviceInit(Configuration conf) throws Exception {
           TransportConf transportConf = new TransportConf("shuffle", new HadoopConfigProvider(conf));
           blockHandler = new ExternalShuffleBlockHandler(transportConf, registeredExecutorFile);
     
    +      // register metrics on the block handler into the Node Manager's metrics system.
    +      try {
    +        YarnShuffleServiceMetrics serviceMetrics = new YarnShuffleServiceMetrics(
    +          blockHandler.getAllMetrics());
    +        MetricsSystemImpl metricsSystem = (MetricsSystemImpl) DefaultMetricsSystem.instance();
    +
    +        Method registerSourceMethod = metricsSystem.getClass().getDeclaredMethod("registerSource",
    +                String.class, String.class, MetricsSource.class);
    +        registerSourceMethod.setAccessible(true);
    +        registerSourceMethod.invoke(metricsSystem, "shuffleservice", "Metrics on the Spark " +
    --- End diff --
    
    nit. "shuffleService" camel case might be better.


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffl...

Posted by jerryshao <gi...@git.apache.org>.
Github user jerryshao commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17401#discussion_r108123141
  
    --- Diff: common/network-yarn/src/main/java/org/apache/spark/network/yarn/YarnShuffleService.java ---
    @@ -166,6 +170,23 @@ protected void serviceInit(Configuration conf) throws Exception {
           TransportConf transportConf = new TransportConf("shuffle", new HadoopConfigProvider(conf));
           blockHandler = new ExternalShuffleBlockHandler(transportConf, registeredExecutorFile);
     
    +      // register metrics on the block handler into the Node Manager's metrics system.
    +      try {
    +        YarnShuffleServiceMetrics serviceMetrics = new YarnShuffleServiceMetrics(
    +          blockHandler.getAllMetrics());
    +        MetricsSystemImpl metricsSystem = (MetricsSystemImpl) DefaultMetricsSystem.instance();
    +
    +        Method registerSourceMethod = metricsSystem.getClass().getDeclaredMethod("registerSource",
    +                String.class, String.class, MetricsSource.class);
    +        registerSourceMethod.setAccessible(true);
    +        registerSourceMethod.invoke(metricsSystem, "shuffleService", "Metrics on the Spark " +
    +                "Shuffle Service", serviceMetrics);
    --- End diff --
    
    Also here.


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffleServic...

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

    https://github.com/apache/spark/pull/17401
  
    **[Test build #75165 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/75165/testReport)** for PR 17401 at commit [`96a0882`](https://github.com/apache/spark/commit/96a0882843e9072bb2ef02ee798a6e5d2f0a41b0).


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffl...

Posted by ash211 <gi...@git.apache.org>.
Github user ash211 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17401#discussion_r107840109
  
    --- Diff: common/network-yarn/src/main/java/org/apache/spark/network/yarn/YarnShuffleService.java ---
    @@ -166,6 +170,23 @@ protected void serviceInit(Configuration conf) throws Exception {
           TransportConf transportConf = new TransportConf("shuffle", new HadoopConfigProvider(conf));
           blockHandler = new ExternalShuffleBlockHandler(transportConf, registeredExecutorFile);
     
    +      // register metrics on the block handler into the Node Manager's metrics system.
    +      try {
    +        YarnShuffleServiceMetrics serviceMetrics = new YarnShuffleServiceMetrics(
    +          blockHandler.getAllMetrics());
    +        MetricsSystemImpl metricsSystem = (MetricsSystemImpl) DefaultMetricsSystem.instance();
    +
    +        Method registerSourceMethod = metricsSystem.getClass().getDeclaredMethod("registerSource",
    +                String.class, String.class, MetricsSource.class);
    +        registerSourceMethod.setAccessible(true);
    +        registerSourceMethod.invoke(metricsSystem, "shuffleservice", "Metrics on the Spark " +
    --- End diff --
    
    will change shortly


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffleServic...

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

    https://github.com/apache/spark/pull/17401
  
    **[Test build #75322 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/75322/testReport)** for PR 17401 at commit [`7c7d6d4`](https://github.com/apache/spark/commit/7c7d6d4c4c6f572e6e1646ff0b8e6e99e95b43c3).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffleServic...

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

    https://github.com/apache/spark/pull/17401
  
    Thanks for taking a look @jerryshao !  I've reformatted to two-space indentation and run `./dev/lint-java` to make sure this code passes the linter.
    
    `src/main/java/org/apache/spark/sql/streaming/GroupStateTimeout.java` still has some errors but those are separate from this change


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffleServic...

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

    https://github.com/apache/spark/pull/17401
  
    gentle ping @ash211. I just wonder if it is active now.


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffleServic...

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

    https://github.com/apache/spark/pull/17401
  
    Merged build finished. Test PASSed.


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffl...

Posted by jerryshao <gi...@git.apache.org>.
Github user jerryshao commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17401#discussion_r107838144
  
    --- Diff: common/network-yarn/src/main/java/org/apache/spark/network/yarn/YarnShuffleServiceMetrics.java ---
    @@ -0,0 +1,118 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.network.yarn;
    +
    +import com.codahale.metrics.*;
    +import org.apache.hadoop.metrics2.MetricsCollector;
    +import org.apache.hadoop.metrics2.MetricsInfo;
    +import org.apache.hadoop.metrics2.MetricsRecordBuilder;
    +import org.apache.hadoop.metrics2.MetricsSource;
    +
    +import java.util.Map;
    +
    +/**
    + * Modeled off of YARN's NodeManagerMetrics.
    + */
    +public class YarnShuffleServiceMetrics implements MetricsSource {
    +
    +  private final MetricSet metricSet;
    +
    +  public YarnShuffleServiceMetrics(MetricSet metricSet) {
    +    this.metricSet = metricSet;
    +  }
    +
    +  /**
    +   * Get metrics from the source
    +   *
    +   * @param collector to contain the resulting metrics snapshot
    +   * @param all       if true, return all metrics even if unchanged.
    +   */
    +  @Override
    +  public void getMetrics(MetricsCollector collector, boolean all) {
    --- End diff --
    
    Is it possible to add a unit test to verify the correctness of converting codahale metrics to Hadoop 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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffleServic...

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

    https://github.com/apache/spark/pull/17401
  
    **[Test build #75150 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/75150/testReport)** for PR 17401 at commit [`13aa4ff`](https://github.com/apache/spark/commit/13aa4ff86038d706e7f3c3dfff449c6e762205f3).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffl...

Posted by ash211 <gi...@git.apache.org>.
Github user ash211 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17401#discussion_r108562943
  
    --- Diff: common/network-yarn/src/main/java/org/apache/spark/network/yarn/YarnShuffleServiceMetrics.java ---
    @@ -0,0 +1,123 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.network.yarn;
    +
    +import com.codahale.metrics.*;
    +import com.google.common.annotations.VisibleForTesting;
    +import org.apache.hadoop.metrics2.MetricsCollector;
    +import org.apache.hadoop.metrics2.MetricsInfo;
    +import org.apache.hadoop.metrics2.MetricsRecordBuilder;
    +import org.apache.hadoop.metrics2.MetricsSource;
    +
    +import java.util.Map;
    +
    +/**
    + * Modeled off of YARN's NodeManagerMetrics.
    + */
    +public class YarnShuffleServiceMetrics implements MetricsSource {
    +
    +  private final MetricSet metricSet;
    +
    +  public YarnShuffleServiceMetrics(MetricSet metricSet) {
    +    this.metricSet = metricSet;
    +  }
    +
    +  /**
    +   * Get metrics from the source
    +   *
    +   * @param collector to contain the resulting metrics snapshot
    +   * @param all       if true, return all metrics even if unchanged.
    +   */
    +  @Override
    +  public void getMetrics(MetricsCollector collector, boolean all) {
    +    MetricsRecordBuilder metricsRecordBuilder = collector.addRecord("shuffleService");
    +
    +    for (Map.Entry<String, Metric> entry : metricSet.getMetrics().entrySet()) {
    +      collectMetric(metricsRecordBuilder, entry.getKey(), entry.getValue());
    +    }
    +  }
    +
    +  @VisibleForTesting
    +  public static void collectMetric(MetricsRecordBuilder metricsRecordBuilder, String name, Metric metric) {
    --- End diff --
    
    I use `static` here to make it clear that the method does not need to be run in the context of an instance.  This prevents it from accidentally accessing instance variables when I don't intend it to


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffleServic...

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

    https://github.com/apache/spark/pull/17401
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/75157/
    Test FAILed.


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffleServic...

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

    https://github.com/apache/spark/pull/17401
  
    **[Test build #75157 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/75157/testReport)** for PR 17401 at commit [`9992c10`](https://github.com/apache/spark/commit/9992c10ccb2f38a7089ac21c31d3adaf23c9a2ba).


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffl...

Posted by jerryshao <gi...@git.apache.org>.
Github user jerryshao commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17401#discussion_r109914966
  
    --- Diff: common/network-yarn/src/main/java/org/apache/spark/network/yarn/YarnShuffleService.java ---
    @@ -184,7 +204,7 @@ protected void serviceInit(Configuration conf) throws Exception {
           boundPort = port;
           String authEnabledString = authEnabled ? "enabled" : "not enabled";
           logger.info("Started YARN shuffle service for Spark on port {}. " +
    -        "Authentication is {}.  Registered executor file is {}", port, authEnabledString,
    +          "Authentication is {}.  Registered executor file is {}", port, authEnabledString,
    --- End diff --
    
    Nit: this 2 space indent looks like not necessary.


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffl...

Posted by jerryshao <gi...@git.apache.org>.
Github user jerryshao commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17401#discussion_r108119959
  
    --- Diff: resource-managers/yarn/src/test/scala/org/apache/spark/network/yarn/YarnShuffleServiceMetricsSuite.scala ---
    @@ -0,0 +1,74 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.spark.network.yarn
    +
    +import org.apache.hadoop.metrics2.MetricsRecordBuilder
    +import org.mockito.Matchers._
    +import org.mockito.Mockito.{mock, times, verify, when}
    +import org.scalatest.Matchers
    +import scala.collection.JavaConverters._
    --- End diff --
    
    The import ordering is not correct, Scala package should be before the third party packages.


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffleServic...

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

    https://github.com/apache/spark/pull/17401
  
    **[Test build #75157 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/75157/testReport)** for PR 17401 at commit [`9992c10`](https://github.com/apache/spark/commit/9992c10ccb2f38a7089ac21c31d3adaf23c9a2ba).
     * This patch **fails Scala style tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffleServic...

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

    https://github.com/apache/spark/pull/17401
  
    **[Test build #75322 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/75322/testReport)** for PR 17401 at commit [`7c7d6d4`](https://github.com/apache/spark/commit/7c7d6d4c4c6f572e6e1646ff0b8e6e99e95b43c3).


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffl...

Posted by jerryshao <gi...@git.apache.org>.
Github user jerryshao commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17401#discussion_r108119704
  
    --- Diff: common/network-yarn/src/main/java/org/apache/spark/network/yarn/YarnShuffleServiceMetrics.java ---
    @@ -0,0 +1,123 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.network.yarn;
    +
    +import com.codahale.metrics.*;
    +import com.google.common.annotations.VisibleForTesting;
    +import org.apache.hadoop.metrics2.MetricsCollector;
    +import org.apache.hadoop.metrics2.MetricsInfo;
    +import org.apache.hadoop.metrics2.MetricsRecordBuilder;
    +import org.apache.hadoop.metrics2.MetricsSource;
    +
    +import java.util.Map;
    +
    +/**
    + * Modeled off of YARN's NodeManagerMetrics.
    + */
    +public class YarnShuffleServiceMetrics implements MetricsSource {
    +
    +  private final MetricSet metricSet;
    +
    +  public YarnShuffleServiceMetrics(MetricSet metricSet) {
    +    this.metricSet = metricSet;
    +  }
    +
    +  /**
    +   * Get metrics from the source
    +   *
    +   * @param collector to contain the resulting metrics snapshot
    +   * @param all       if true, return all metrics even if unchanged.
    +   */
    +  @Override
    +  public void getMetrics(MetricsCollector collector, boolean all) {
    +    MetricsRecordBuilder metricsRecordBuilder = collector.addRecord("shuffleService");
    +
    +    for (Map.Entry<String, Metric> entry : metricSet.getMetrics().entrySet()) {
    +      collectMetric(metricsRecordBuilder, entry.getKey(), entry.getValue());
    +    }
    +  }
    +
    +  @VisibleForTesting
    +  public static void collectMetric(MetricsRecordBuilder metricsRecordBuilder, String name, Metric metric) {
    --- End diff --
    
    Is it necessary to use `static` here? Looks like here it is  it is only for the test convenience.


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffleServic...

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

    https://github.com/apache/spark/pull/17401
  
    **[Test build #75115 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/75115/testReport)** for PR 17401 at commit [`4caf4d2`](https://github.com/apache/spark/commit/4caf4d28819d82240f1d61e11cdabd68fafad14a).


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffleServic...

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

    https://github.com/apache/spark/pull/17401
  
    Merged build finished. Test PASSed.


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffleServic...

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

    https://github.com/apache/spark/pull/17401
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/75165/
    Test PASSed.


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffleServic...

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

    https://github.com/apache/spark/pull/17401
  
    Merged build finished. Test PASSed.


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffl...

Posted by jerryshao <gi...@git.apache.org>.
Github user jerryshao commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17401#discussion_r109918033
  
    --- Diff: common/network-yarn/src/main/java/org/apache/spark/network/yarn/YarnShuffleServiceMetrics.java ---
    @@ -0,0 +1,123 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.network.yarn;
    +
    +import com.codahale.metrics.*;
    +import com.google.common.annotations.VisibleForTesting;
    +import org.apache.hadoop.metrics2.MetricsCollector;
    +import org.apache.hadoop.metrics2.MetricsInfo;
    +import org.apache.hadoop.metrics2.MetricsRecordBuilder;
    +import org.apache.hadoop.metrics2.MetricsSource;
    +
    +import java.util.Map;
    +
    +/**
    + * Modeled off of YARN's NodeManagerMetrics.
    + */
    +public class YarnShuffleServiceMetrics implements MetricsSource {
    +
    +  private final MetricSet metricSet;
    +
    +  public YarnShuffleServiceMetrics(MetricSet metricSet) {
    +    this.metricSet = metricSet;
    +  }
    +
    +  /**
    +   * Get metrics from the source
    +   *
    +   * @param collector to contain the resulting metrics snapshot
    +   * @param all       if true, return all metrics even if unchanged.
    +   */
    +  @Override
    +  public void getMetrics(MetricsCollector collector, boolean all) {
    +    MetricsRecordBuilder metricsRecordBuilder = collector.addRecord("shuffleService");
    +
    +    for (Map.Entry<String, Metric> entry : metricSet.getMetrics().entrySet()) {
    +      collectMetric(metricsRecordBuilder, entry.getKey(), entry.getValue());
    +    }
    +  }
    +
    +  @VisibleForTesting
    +  public static void collectMetric(MetricsRecordBuilder metricsRecordBuilder, String name, Metric metric) {
    +
    +    // The metric types used in ExternalShuffleBlockHandler.ShuffleMetrics
    +    if (metric instanceof Timer) {
    +      Timer t = (Timer) metric;
    +      metricsRecordBuilder
    +        .addCounter(new ShuffleServiceMetricsInfo(name + "_count", "Count of timer " + name),
    +          t.getCount())
    +        .addGauge(
    +          new ShuffleServiceMetricsInfo(name + "_rate15", "15 minute rate of timer " + name),
    +          t.getFifteenMinuteRate())
    +        .addGauge(
    +          new ShuffleServiceMetricsInfo(name + "_rate5", "5 minute rate of timer " + name),
    +          t.getFiveMinuteRate())
    +        .addGauge(
    +          new ShuffleServiceMetricsInfo(name + "_rate1", "1 minute rate of timer " + name),
    +          t.getOneMinuteRate())
    +        .addGauge(new ShuffleServiceMetricsInfo(name + "_rateMean", "Mean rate of timer " + name),
    +          t.getMeanRate());
    +    } else if (metric instanceof Meter) {
    +      Meter m = (Meter) metric;
    +      metricsRecordBuilder
    +        .addCounter(new ShuffleServiceMetricsInfo(name + "_count", "Count of meter " + name),
    +          m.getCount())
    +        .addGauge(
    +          new ShuffleServiceMetricsInfo(name + "_rate15", "15 minute rate of meter " + name),
    +          m.getFifteenMinuteRate())
    +        .addGauge(
    +          new ShuffleServiceMetricsInfo(name + "_rate5", "5 minute rate of meter " + name),
    +          m.getFiveMinuteRate())
    +        .addGauge(
    +          new ShuffleServiceMetricsInfo(name + "_rate1", "1 minute rate of meter " + name),
    +          m.getOneMinuteRate())
    +        .addGauge(new ShuffleServiceMetricsInfo(name + "_rateMean", "Mean rate of meter " + name),
    +          m.getMeanRate());
    +    } else if (metric instanceof Gauge) {
    +      Gauge m = (Gauge) metric;
    +      Object gaugeValue = m.getValue();
    +      if (gaugeValue instanceof Integer) {
    +        Integer intValue = (Integer) gaugeValue;
    --- End diff --
    
    Does it mean that we could only handle integer Gauge, what if later on we add different metric in `ExternalShuffleBlockHandler`? Looks like we should also manually handle the case one by one here. At least we should an else branch for the fallback check.


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffl...

Posted by jerryshao <gi...@git.apache.org>.
Github user jerryshao commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17401#discussion_r109914191
  
    --- Diff: common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/ExternalShuffleBlockHandler.java ---
    @@ -176,7 +176,8 @@ private void checkAuth(TransportClient client, String appId) {
       /**
        * A simple class to wrap all shuffle service wrapper metrics
        */
    -  private class ShuffleMetrics implements MetricSet {
    +  @VisibleForTesting
    --- End diff --
    
    `@VisibleForTesting` causes classpath issues. Please note this in the java doc instead (SPARK-11615).
    
    This is a scalastyle output, would be better to remove this annotation.


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #17401: [SPARK-18364][YARN] Expose metrics for YarnShuffl...

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

    https://github.com/apache/spark/pull/17401


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org