aboutsummaryrefslogtreecommitdiff
path: root/core/src/test/scala
diff options
context:
space:
mode:
authorMarcelo Vanzin <vanzin@cloudera.com>2014-10-01 19:24:22 -0700
committerJosh Rosen <joshrosen@apache.org>2014-10-01 19:24:22 -0700
commit29c3513203218af33bea2f6d99d622cf263d55dd (patch)
treed748542676bbd645ac0a6fc434787b59beb105e7 /core/src/test/scala
parent93861a5e876fa57f509cce82768656ddf8d4ef00 (diff)
downloadspark-29c3513203218af33bea2f6d99d622cf263d55dd.tar.gz
spark-29c3513203218af33bea2f6d99d622cf263d55dd.tar.bz2
spark-29c3513203218af33bea2f6d99d622cf263d55dd.zip
[SPARK-3446] Expose underlying job ids in FutureAction.
FutureAction is the only type exposed through the async APIs, so for job IDs to be useful they need to be exposed there. The complication is that some async jobs run more than one job (e.g. takeAsync), so the exposed ID has to actually be a list of IDs that can actually change over time. So the interface doesn't look very nice, but... Change is actually small, I just added a basic test to make sure it works. Author: Marcelo Vanzin <vanzin@cloudera.com> Closes #2337 from vanzin/SPARK-3446 and squashes the following commits: e166a68 [Marcelo Vanzin] Fix comment. 1fed2bc [Marcelo Vanzin] [SPARK-3446] Expose underlying job ids in FutureAction.
Diffstat (limited to 'core/src/test/scala')
-rw-r--r--core/src/test/scala/org/apache/spark/FutureActionSuite.scala49
1 files changed, 49 insertions, 0 deletions
diff --git a/core/src/test/scala/org/apache/spark/FutureActionSuite.scala b/core/src/test/scala/org/apache/spark/FutureActionSuite.scala
new file mode 100644
index 0000000000..db9c25fc45
--- /dev/null
+++ b/core/src/test/scala/org/apache/spark/FutureActionSuite.scala
@@ -0,0 +1,49 @@
+/*
+ * 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
+
+import scala.concurrent.Await
+import scala.concurrent.duration.Duration
+
+import org.scalatest.{BeforeAndAfter, FunSuite, Matchers}
+
+import org.apache.spark.SparkContext._
+
+class FutureActionSuite extends FunSuite with BeforeAndAfter with Matchers with LocalSparkContext {
+
+ before {
+ sc = new SparkContext("local", "FutureActionSuite")
+ }
+
+ test("simple async action") {
+ val rdd = sc.parallelize(1 to 10, 2)
+ val job = rdd.countAsync()
+ val res = Await.result(job, Duration.Inf)
+ res should be (10)
+ job.jobIds.size should be (1)
+ }
+
+ test("complex async action") {
+ val rdd = sc.parallelize(1 to 15, 3)
+ val job = rdd.takeAsync(10)
+ val res = Await.result(job, Duration.Inf)
+ res should be (1 to 10)
+ job.jobIds.size should be (2)
+ }
+
+}