spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markhamstra <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-9026] [SPARK-4514] Modifications to Job...
Date Thu, 10 Dec 2015 06:10:21 GMT
Github user markhamstra commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9264#discussion_r47192089
  
    --- Diff: core/src/test/scala/org/apache/spark/rdd/AsyncRDDActionsSuite.scala ---
    @@ -197,4 +197,34 @@ class AsyncRDDActionsSuite extends SparkFunSuite with BeforeAndAfterAll
with Tim
           Await.result(f, Duration(20, "milliseconds"))
         }
       }
    +
    +  private def testAsyncAction[R](action: RDD[Int] => FutureAction[R]): Unit = {
    +    val executionContextInvoked = Promise[Unit]
    +    val fakeExecutionContext = new ExecutionContext {
    +      override def execute(runnable: Runnable): Unit = {
    +        executionContextInvoked.success(())
    +      }
    +      override def reportFailure(t: Throwable): Unit = ()
    +    }
    +    val starter = Smuggle(new Semaphore(0))
    +    starter.drainPermits()
    +    val rdd = sc.parallelize(1 to 100, 4).mapPartitions {itr => starter.acquire(1);
itr}
    +    val f = action(rdd)
    +    f.onComplete(_ => ())(fakeExecutionContext)
    +    // Here we verify that registering the callback didn't cause a thread to be consumed.
    +    assert(!executionContextInvoked.isCompleted)
    +    // Now allow the executors to proceed with task processing.
    +    starter.release(rdd.partitions.length)
    +    // Waiting for the result verifies that the tasks were successfully processed.
    +    // This mainly exists to verify that we didn't break task deserialization.
    --- End diff --
    
    How did you test it?  My expectation is the same as Richard's, that `Await.result` will
throw the underlying exception.  For example:
    ```
    scala> val fi: Future[Int] = Future { throw new java.lang.RuntimeException() }
    fi: scala.concurrent.Future[Int] = scala.concurrent.impl.Promise$DefaultPromise@3f200884
    
    scala> try { Await.result(fi, 3 seconds) } catch {
         | case _: java.util.concurrent.TimeoutException => println("Timeout")
         | case _: java.lang.RuntimeException => println("Runtime")
         | case _: Throwable => println("Huh?")
         | }
    Runtime
    res1: AnyVal = ()
    ```


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