Moved ClassServer out of repl packaged and renamed it to HttpServer.
This commit is contained in:
parent
a768cf417b
commit
ecb1af576e
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in a new issue