From 8f18e7e863728734f927edbcb928a37cdccc4d63 Mon Sep 17 00:00:00 2001
From: Imran Rashid <imran@quantifind.com>
Date: Wed, 13 Feb 2013 13:05:13 -0800
Subject: [PATCH] include jobid in Executor commandline args

---
 core/src/main/scala/spark/deploy/worker/ExecutorRunner.scala | 2 +-
 .../scala/spark/executor/StandaloneExecutorBackend.scala     | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/core/src/main/scala/spark/deploy/worker/ExecutorRunner.scala b/core/src/main/scala/spark/deploy/worker/ExecutorRunner.scala
index 4ef637090c..69f34e604a 100644
--- a/core/src/main/scala/spark/deploy/worker/ExecutorRunner.scala
+++ b/core/src/main/scala/spark/deploy/worker/ExecutorRunner.scala
@@ -77,7 +77,7 @@ private[spark] class ExecutorRunner(
     val command = jobDesc.command
     val script = if (System.getProperty("os.name").startsWith("Windows")) "run.cmd" else "run";
     val runScript = new File(sparkHome, script).getCanonicalPath
-    Seq(runScript, command.mainClass) ++ command.arguments.map(substituteVariables)
+    Seq(runScript, command.mainClass) ++ (command.arguments ++ Seq(jobId)).map(substituteVariables)
   }
 
   /** Spawn a thread that will redirect a given stream to a file */
diff --git a/core/src/main/scala/spark/executor/StandaloneExecutorBackend.scala b/core/src/main/scala/spark/executor/StandaloneExecutorBackend.scala
index 224c126fdd..06229f39d9 100644
--- a/core/src/main/scala/spark/executor/StandaloneExecutorBackend.scala
+++ b/core/src/main/scala/spark/executor/StandaloneExecutorBackend.scala
@@ -68,8 +68,9 @@ private[spark] object StandaloneExecutorBackend {
   }
 
   def main(args: Array[String]) {
-    if (args.length != 4) {
-      System.err.println("Usage: StandaloneExecutorBackend <driverUrl> <executorId> <hostname> <cores>")
+    if (!(args.length >= 4)) {
+      //the reason we allow the last frameworkId argument is to make it easy to kill rogue executors
+      System.err.println("Usage: StandaloneExecutorBackend <driverUrl> <executorId> <hostname> <cores> [<frameworkid>]")
       System.exit(1)
     }
     run(args(0), args(1), args(2), args(3).toInt)
-- 
GitLab