Github user mengxr commented on a diff in the pull request:
https://github.com/apache/spark/pull/21898#discussion_r206718064
--- Diff:
core/src/test/scala/org/apache/spark/scheduler/BarrierTaskContextSuite.scala ---
@@ -0,0 +1,144 @@
+/*
+ * 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 scala.util.Random
+
+import org.apache.spark._
+
+class BarrierTaskContextSuite extends SparkFunSuite with LocalSparkContext
{
+
+ test("global sync by barrier() call") {
+ val conf = new SparkConf()
+ .setMaster("local-cluster[4, 1, 1024]")
+ .setAppName("test-cluster")
+ sc = new SparkContext(conf)
+ val rdd = sc.makeRDD(1 to 10, 4)
+ val rdd2 = rdd.barrier().mapPartitions { (it, context) =>
+ // Sleep for a random time before global sync.
+ Thread.sleep(Random.nextInt(1000))
+ context.barrier()
+ Seq(System.currentTimeMillis()).iterator
+ }
+
+ val times = rdd2.collect()
+ // All the tasks shall finish global sync within a short time slot.
+ assert(times.max - times.min <= 5)
--- End diff --
5ms seem too risky to me. Actually, 1 second is perhaps okay here.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]