spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mareksimunek <...@git.apache.org>
Subject [GitHub] spark pull request #22485: [SPARK-18364][YARN] Expose metrics for YarnShuffl...
Date Mon, 24 Sep 2018 10:14:21 GMT
Github user mareksimunek commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22485#discussion_r219786966
  
    --- Diff: resource-managers/yarn/src/test/scala/org/apache/spark/network/yarn/YarnShuffleServiceMetricsSuite.scala
---
    @@ -0,0 +1,75 @@
    +/*
    + * 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 scala.collection.JavaConverters._
    +
    +import org.apache.hadoop.metrics2.MetricsRecordBuilder
    +import org.mockito.Matchers._
    +import org.mockito.Mockito.{mock, times, verify, when}
    +import org.scalatest.Matchers
    +
    +import org.apache.spark.SparkFunSuite
    +import org.apache.spark.network.server.OneForOneStreamManager
    +import org.apache.spark.network.shuffle.{ExternalShuffleBlockHandler, ExternalShuffleBlockResolver}
    +
    +class YarnShuffleServiceMetricsSuite extends SparkFunSuite with Matchers {
    +
    +  val streamManager = mock(classOf[OneForOneStreamManager])
    +  val blockResolver = mock(classOf[ExternalShuffleBlockResolver])
    +  when(blockResolver.getRegisteredExecutorsSize).thenReturn(42)
    +
    +  val metrics = new ExternalShuffleBlockHandler(streamManager, blockResolver).getAllMetrics
    +
    +  test("metrics named as expected") {
    +    val allMetrics = Set(
    +      "openBlockRequestLatencyMillis", "registerExecutorRequestLatencyMillis",
    +      "blockTransferRateBytes", "registeredExecutorsSize")
    +
    +    metrics.getMetrics.keySet().asScala should be (allMetrics)
    +  }
    +
    +  // these three metrics have the same effect on the collector
    +  for (testname <- Seq("openBlockRequestLatencyMillis",
    +      "registerExecutorRequestLatencyMillis",
    +      "blockTransferRateBytes")) {
    +    test(s"$testname - collector receives correct types") {
    +      val builder = mock(classOf[MetricsRecordBuilder])
    +      when(builder.addCounter(any(), anyLong())).thenReturn(builder)
    +      when(builder.addGauge(any(), anyDouble())).thenReturn(builder)
    +
    +      YarnShuffleServiceMetrics.collectMetric(builder, testname,
    --- End diff --
    
    fixed


---

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


Mime
View raw message