From ecb1af576e5e0be9f67cf0375f998d1fa7ac3a07 Mon Sep 17 00:00:00 2001 From: Matei Zaharia <matei@eecs.berkeley.edu> Date: Fri, 15 Oct 2010 19:04:18 -0700 Subject: [PATCH] Moved ClassServer out of repl packaged and renamed it to HttpServer. --- .../ClassServer.scala => HttpServer.scala} | 18 ++++++++---------- src/scala/spark/repl/SparkInterpreter.scala | 6 ++++-- 2 files changed, 12 insertions(+), 12 deletions(-) rename src/scala/spark/{repl/ClassServer.scala => HttpServer.scala} (78%) diff --git a/src/scala/spark/repl/ClassServer.scala b/src/scala/spark/HttpServer.scala similarity index 78% rename from src/scala/spark/repl/ClassServer.scala rename to src/scala/spark/HttpServer.scala index 6a40d92765..55fb0a2218 100644 --- a/src/scala/spark/repl/ClassServer.scala +++ b/src/scala/spark/HttpServer.scala @@ -1,4 +1,4 @@ -package spark.repl +package spark import java.io.File import java.net.InetAddress @@ -8,22 +8,20 @@ import org.eclipse.jetty.server.handler.DefaultHandler import org.eclipse.jetty.server.handler.HandlerList import org.eclipse.jetty.server.handler.ResourceHandler -import spark.Logging - /** - * Exception type thrown by ClassServer when it is in the wrong state + * Exception type thrown by HttpServer when it is in the wrong state * for an operation. */ class ServerStateException(message: String) extends Exception(message) /** - * An HTTP server used by the interpreter to allow worker nodes to access - * class files created as the user types in lines of code. This is just a - * wrapper around a Jetty embedded HTTP server. + * An HTTP server for static content used to allow worker nodes to access JARs + * added to SparkContext as well as classes created by the interpreter when + * the user types in code. This is just a wrapper around a Jetty server. */ -class ClassServer(classDir: File) extends Logging { +class HttpServer(resourceBase: File) extends Logging { private var server: Server = null private var port: Int = -1 @@ -33,13 +31,13 @@ class ClassServer(classDir: File) extends Logging { } else { server = new Server(0) val resHandler = new ResourceHandler - resHandler.setResourceBase(classDir.getAbsolutePath) + resHandler.setResourceBase(resourceBase.getAbsolutePath) val handlerList = new HandlerList handlerList.setHandlers(Array(resHandler, new DefaultHandler)) server.setHandler(handlerList) server.start() port = server.getConnectors()(0).getLocalPort() - logDebug("ClassServer started at " + uri) + logDebug("HttpServer started at " + uri) } } diff --git a/src/scala/spark/repl/SparkInterpreter.scala b/src/scala/spark/repl/SparkInterpreter.scala index ae2e7e8a68..41324333a3 100644 --- a/src/scala/spark/repl/SparkInterpreter.scala +++ b/src/scala/spark/repl/SparkInterpreter.scala @@ -36,6 +36,8 @@ import scala.tools.nsc.{ InterpreterResults => IR } import interpreter._ import SparkInterpreter._ +import spark.HttpServer + /** <p> * An interpreter for Scala code. * </p> @@ -120,14 +122,14 @@ class SparkInterpreter(val settings: Settings, out: PrintWriter) { val virtualDirectory = new PlainFile(outputDir) /** Jetty server that will serve our classes to worker nodes */ - val classServer = new ClassServer(outputDir) + val classServer = new HttpServer(outputDir) // Start the classServer and store its URI in a spark system property // (which will be passed to executors so that they can connect to it) classServer.start() System.setProperty("spark.repl.class.uri", classServer.uri) if (SPARK_DEBUG_REPL) { - println("ClassServer started, URI = " + classServer.uri) + println("Class server started, URI = " + classServer.uri) } /** reporter */ -- GitLab