diff options
Diffstat (limited to 'examples/src/main/scala/SleepJob.scala')
-rw-r--r-- | examples/src/main/scala/SleepJob.scala | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/examples/src/main/scala/SleepJob.scala b/examples/src/main/scala/SleepJob.scala new file mode 100644 index 0000000000..a5e0ea0dc2 --- /dev/null +++ b/examples/src/main/scala/SleepJob.scala @@ -0,0 +1,19 @@ +import spark._ + +object SleepJob { + def main(args: Array[String]) { + if (args.length != 3) { + System.err.println("Usage: SleepJob <master> <tasks> <task_duration>"); + System.exit(1) + } + val sc = new SparkContext(args(0), "Sleep job") + val tasks = args(1).toInt + val duration = args(2).toInt + def task { + val start = System.currentTimeMillis + while (System.currentTimeMillis - start < duration * 1000L) + Thread.sleep(200) + } + sc.runTasks(Array.make(tasks, () => task)) + } +} |