spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From squito <...@git.apache.org>
Subject [GitHub] spark pull request: [Spark-8426] [scheduler] enhance blacklist mec...
Date Tue, 24 Nov 2015 16:37:56 GMT
Github user squito commented on a diff in the pull request:

    https://github.com/apache/spark/pull/8760#discussion_r45759807
  
    --- Diff: core/src/test/scala/org/apache/spark/scheduler/BlacklistTrackerSuite.scala ---
    @@ -0,0 +1,200 @@
    +/*
    + * 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.scheduler
    +
    +import org.apache.spark.SparkFunSuite
    +import org.scalatest.BeforeAndAfter
    +import org.apache.spark.SparkConf
    +import org.apache.spark.TaskEndReason
    +import org.apache.spark.Success
    +import org.apache.spark.ExceptionFailure
    +import org.apache.spark.LocalSparkContext
    +import org.apache.spark.SparkContext
    +import org.mockito.Mockito.{when, spy}
    +import org.apache.spark.util.ManualClock
    +
    +class BlacklistTrackerSuite extends SparkFunSuite with BeforeAndAfter with LocalSparkContext
{
    +
    +  val FAILURE: TaskEndReason = new ExceptionFailure(
    +      "Fake",
    +      "fake failure",
    +      Array.empty[StackTraceElement],
    +      "fake stack trace",
    +      None,
    +      None)
    +
    +  val stage1 = 1
    +  val stage2 = 2
    +  // Variable name can indicate basic information of taskInfo
    +  // The format is "taskInfo_executorId_taskIndex_hostName"
    +  val taskInfo_1_1_hostA = new TaskInfo(1L, 1, 1, 0L, "1", "hostA", TaskLocality.ANY,
false)
    +  val taskInfo_1_2_hostA = new TaskInfo(2L, 2, 1, 0L, "1", "hostA", TaskLocality.ANY,
false)
    +  val taskInfo_2_1_hostA = new TaskInfo(3L, 1, 1, 0L, "2", "hostA", TaskLocality.ANY,
false)
    +  val taskInfo_2_2_hostA = new TaskInfo(4L, 2, 1, 0L, "2", "hostA", TaskLocality.ANY,
false)
    +  val taskInfo_3_3_hostB = new TaskInfo(5L, 3, 1, 0L, "3", "hostB", TaskLocality.ANY,
false)
    +
    +  val clock = new ManualClock(0)
    +
    +  test ("expireExecutorsInBlacklist works") {
    +    // expire time is set to 6s
    +    val conf = new SparkConf().setAppName("test").setMaster("local")
    +      .set("spark.ui.enabled", "false")
    +      .set("spark.scheduler.executorTaskBlacklistTime", "6000")
    +
    +    sc = new SparkContext(conf)
    +    val scheduler = new TaskSchedulerImpl(sc, 1)
    +
    +    val tracker = new BlacklistTracker(conf, clock)
    +    // Executor 1 into blacklist at Time 00:00:00
    +    tracker.updateFailureExecutors(stage1, taskInfo_1_1_hostA, FAILURE)
    +    assert(tracker.executorBlacklist(scheduler, stage1, 1) === Set("1"))
    +
    +    clock.setTime(2000)
    +    tracker.expireExecutorsInBlackList()
    +    assert(tracker.executorBlacklist(scheduler, stage1, 1) === Set("1"))
    +    // Executor 1 failed again at Time 00::00:02
    +    tracker.updateFailureExecutors(stage1, taskInfo_1_1_hostA, FAILURE)
    +
    +    clock.setTime(3000)
    +    // Executor 2 failed at Time 00:00:03
    +    tracker.updateFailureExecutors(stage1, taskInfo_2_1_hostA, FAILURE)
    +    assert(tracker.executorBlacklist(scheduler, stage1, 1) === Set("1", "2"))
    +
    +    clock.setTime(6000)
    +    tracker.expireExecutorsInBlackList()
    +    assert(tracker.executorBlacklist(scheduler, stage1, 1) === Set("1", "2"))
    +
    +    clock.setTime(8000)
    +    tracker.expireExecutorsInBlackList()
    +    assert(tracker.executorBlacklist(scheduler, stage1, 1) === Set("2"))
    +
    +    clock.setTime(10000)
    +    tracker.expireExecutorsInBlackList()
    +    assert(tracker.executorBlacklist(scheduler, stage1, 1) === Set())
    +  }
    +
    +  test("blacklist feature is off by default") {
    +    val conf = new SparkConf().setAppName("test").setMaster("local")
    +      .set("spark.ui.enabled", "false")
    +    sc = new SparkContext(conf)
    +
    +    val scheduler = new TaskSchedulerImpl(sc, 1)
    +
    +    val tracker = new BlacklistTracker(conf, clock)
    +    tracker.updateFailureExecutors(stage1, taskInfo_1_1_hostA, FAILURE)
    +    tracker.updateFailureExecutors(stage1, taskInfo_2_1_hostA, FAILURE)
    +    assert(tracker.executorBlacklist(scheduler, stage1, 1) === Set())
    +    assert(tracker.executorBlacklist(scheduler, stage1, 1) === Set())
    +
    +    tracker.updateFailureExecutors(stage1, taskInfo_3_3_hostB, FAILURE)
    +    assert(tracker.executorBlacklist(scheduler, stage1, 3) === Set())
    +    assert(tracker.nodeBlacklist() === Set())
    +  }
    +
    +  test("default strategy works") {
    +    val conf = new SparkConf().setAppName("test").setMaster("local")
    +      .set("spark.ui.enabled", "false")
    +      .set("spark.scheduler.executorTaskBlacklistTime", "1000")
    +    sc = new SparkContext(conf)
    +    val scheduler = new TaskSchedulerImpl(sc, 1)
    +
    +    val tracker = new BlacklistTracker(conf, clock)
    +    tracker.updateFailureExecutors(stage1, taskInfo_1_1_hostA, FAILURE)
    +    tracker.updateFailureExecutors(stage1, taskInfo_2_1_hostA, FAILURE)
    +    assert(tracker.executorBlacklist(scheduler, stage1, 1) === Set("1", "2"))
    +    assert(tracker.executorBlacklist(scheduler, stage1, 2) === Set())
    +
    +    tracker.updateFailureExecutors(stage1, taskInfo_1_1_hostA, Success)
    +    assert(tracker.executorBlacklist(scheduler, stage1, 1) === Set("2"))
    +    assert(tracker.nodeBlacklist() === Set())
    +
    +    tracker.updateFailureExecutors(stage1, taskInfo_3_3_hostB, Success)
    +    assert(tracker.executorBlacklist(scheduler, stage1, 1) === Set("2"))
    +
    +    tracker.updateFailureExecutors(stage1, taskInfo_3_3_hostB, FAILURE)
    +    assert(tracker.executorBlacklist(scheduler, stage1, 3) === Set("3"))
    +    assert(tracker.nodeBlacklist() === Set())
    +
    +    tracker.updateFailureExecutors(stage1, taskInfo_2_1_hostA, Success)
    +    assert(tracker.executorBlacklist(scheduler, stage1, 1) === Set())
    +
    +    // Task 2 on Stage 2 failed on Executor 2
    +    tracker.updateFailureExecutors(stage2, taskInfo_2_2_hostA, FAILURE)
    +    assert(tracker.executorBlacklist(scheduler, stage1, 1) === Set())
    +    assert(tracker.executorBlacklist(scheduler, stage2, 1) === Set())
    +    assert(tracker.executorBlacklist(scheduler, stage1, 2) === Set())
    +    assert(tracker.executorBlacklist(scheduler, stage2, 2) === Set("2"))
    +  }
    +
    +  test ("threshold strategy works") {
    +    val conf = new SparkConf().setAppName("test").setMaster("local")
    +      .set("spark.ui.enabled", "false")
    +      .set("spark.scheduler.blacklist.strategy", "threshold")
    +      .set("spark.scheduler.blacklist.threshold.maxFailureTaskNumber", "1")
    +      .set("spark.scheduler.blacklist.threshold.maxBlackExecutorNumber", "1")
    +
    +    sc = new SparkContext(conf)
    +    val scheduler = spy(new TaskSchedulerImpl(sc, 1))
    +    when(scheduler.getExecutorsAliveOnHost("hostA")).thenReturn(Some(Set("1", "2", "4")))
    +
    +    val tracker = new BlacklistTracker(conf, clock)
    +    // Task 1 failed on Executor 1
    +    tracker.updateFailureExecutors(stage1, taskInfo_1_1_hostA, FAILURE)
    +    assert(tracker.executorBlacklist(scheduler, stage1, 1) === Set())
    +    // Task 2 failed on Executor 1
    +    tracker.updateFailureExecutors(stage1, taskInfo_1_2_hostA, FAILURE)
    +    // Executor 1 is now blacklisted from "all" tasks
    +    (0 until 10).foreach { case i: Int =>
    +      assert(tracker.executorBlacklist(scheduler, stage1, i) === Set("1"))
    +    }
    +    assert(tracker.nodeBlacklist() === Set())
    +
    +    // Task 1 and Task 2 failed on Executor 2
    +    tracker.updateFailureExecutors(stage1, taskInfo_2_1_hostA, FAILURE)
    +    tracker.updateFailureExecutors(stage1, taskInfo_2_2_hostA, FAILURE)
    +    // Executor 2 is blacklisted and Executor 4 is blacklisted at the same time
    +    assert(tracker.executorBlacklist(scheduler, stage1, 2) === Set("1", "2", "4"))
    +    assert(tracker.nodeBlacklist() === Set("hostA"))
    +
    +    // Task 1 succeeded on Executor 1
    +    tracker.updateFailureExecutors(stage1, taskInfo_1_1_hostA, Success)
    +    assert(tracker.executorBlacklist(scheduler, stage1, 2) === Set("2"))
    +    assert(tracker.nodeBlacklist() === Set())
    +
    +    // Task 2 succeeded on Executor 2
    +    tracker.updateFailureExecutors(stage1, taskInfo_2_2_hostA, Success)
    +    assert(tracker.executorBlacklist(scheduler, stage1, 1) === Set())
    +
    +    // Task 2 on Stage 2 failed on Executor 2
    +    tracker.updateFailureExecutors(stage2, taskInfo_2_2_hostA, FAILURE)
    +    assert(tracker.executorBlacklist(scheduler, stage1, 1) === Set("2"))
    +    assert(tracker.executorBlacklist(scheduler, stage2, 1) === Set("2"))
    +    assert(tracker.executorBlacklist(scheduler, stage1, 2) === Set("2"))
    +    assert(tracker.executorBlacklist(scheduler, stage2, 2) === Set("2"))
    +  }
    +
    +  test ("unsupported strategy throws helpful exception") {
    +    val ex = intercept[Exception]{
    +      val conf = new SparkConf().setAppName("test").setMaster("local")
    +        .set("spark.ui.enabled", "false")
    +        .set("spark.scheduler.blacklist.strategy", "FAKE")
    +      sc = new SparkContext(conf)
    --- End diff --
    
    here you can just call `BlacklistStrategy(conf)` directly without creating a SparkContext


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


Mime
View raw message