Github user JoshRosen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/4155#discussion_r23434185
  
    --- Diff: 
core/src/test/scala/org/apache/spark/scheduler/OutputCommitCoordinatorSuite.scala
 ---
    @@ -0,0 +1,176 @@
    +/*
    + * 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 java.io.{ObjectInputStream, ObjectOutputStream, IOException}
    +
    +import scala.collection.mutable
    +
    +import org.scalatest.concurrent.Timeouts
    +import org.scalatest.{BeforeAndAfter, FunSuiteLike}
    +
    +import org.apache.hadoop.mapred.{TaskAttemptID, JobConf, 
TaskAttemptContext, OutputCommitter}
    +import org.mockito.Mockito._
    +
    +import org.apache.spark._
    +import org.apache.spark.executor.{TaskMetrics}
    +import org.apache.spark.rdd.FakeOutputCommitter
    +
    +/**
    + * Unit tests for the output commit coordination functionality. Overrides 
the
    + * SchedulerImpl to just run the tasks directly and send completion or 
error
    + * messages back to the DAG scheduler.
    + */
    +class OutputCommitCoordinatorSuite
    +    extends FunSuiteLike
    +    with BeforeAndAfter
    +    with LocalSparkContext
    +    with Timeouts {
    +
    +  val conf = new SparkConf().set("spark.localExecution.enabled", "true")
    +
    +  var taskScheduler: TaskSchedulerImpl = null
    +  var dagScheduler: DAGScheduler = null
    +  var dagSchedulerEventProcessLoop: DAGSchedulerEventProcessLoop = null
    +  var accum: Accumulator[Int] = null
    +  var accumId: Long = 0
    +
    +  before {
    +    sc = new SparkContext("local", "Output Commit Coordinator Suite")
    +    accum = sc.accumulator[Int](0)
    +    Accumulators.register(accum, true)
    +    accumId = accum.id
    +
    +    taskScheduler = new TaskSchedulerImpl(sc, 4, true) {
    +      override def submitTasks(taskSet: TaskSet) {
    +        // Instead of submitting a task to some executor, just run the 
task directly.
    +        // Make two attempts. The first may or may not succeed. If the 
first
    +        // succeeds then the second is redundant and should be handled
    +        // accordingly by OutputCommitCoordinator. Otherwise the second
    +        // should not be blocked from succeeding.
    +        execTasks(taskSet, 0)
    +        execTasks(taskSet, 1)
    +      }
    +
    +      private def execTasks(taskSet: TaskSet, attemptNumber: Int) {
    +        var taskIndex = 0
    +        taskSet.tasks.foreach(t => {
    --- End diff --
    
    Minor style thing, but you can just use a curly brace w/ foreach and remove 
the second level of braces, e.g. `foreach{ t => `


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to