Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REPL cleanup. #451

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 33 additions & 22 deletions repl/src/main/scala/org/apache/spark/repl/SparkIMain.scala
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,19 @@ import org.apache.spark.util.Utils
val conf = new SparkConf()

val SPARK_DEBUG_REPL: Boolean = (System.getenv("SPARK_DEBUG_REPL") == "1")
/** Local directory to save .class files too */
val outputDir = {
val tmp = System.getProperty("java.io.tmpdir")
val rootDir = conf.get("spark.repl.classdir", tmp)
Utils.createTempDir(rootDir)
}
if (SPARK_DEBUG_REPL) {
echo("Output directory: " + outputDir)
}
/** Local directory to save .class files too */
lazy val outputDir = {
val tmp = System.getProperty("java.io.tmpdir")
val rootDir = conf.get("spark.repl.classdir", tmp)
Utils.createTempDir(rootDir)
}
if (SPARK_DEBUG_REPL) {
echo("Output directory: " + outputDir)
}

val virtualDirectory = new PlainFile(outputDir) // "directory" for classfiles
val classServer = new HttpServer(outputDir,
new SecurityManager(conf)) /** Jetty server that will serve our classes to worker nodes */
/** Jetty server that will serve our classes to worker nodes */
val classServer = new HttpServer(outputDir, new SecurityManager(conf))
private var currentSettings: Settings = initialSettings
var printResults = true // whether to print result lines
var totalSilence = false // whether to print anything
Expand All @@ -112,12 +112,12 @@ import org.apache.spark.util.Utils
private var _executionWrapper = "" // code to be wrapped around all lines


// Start the classServer and store its URI in a spark system property
// 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()
if (SPARK_DEBUG_REPL) {
echo("Class server started, URI = " + classServer.uri)
}
classServer.start()
if (SPARK_DEBUG_REPL) {
echo("Class server started, URI = " + classServer.uri)
}

/** We're going to go to some trouble to initialize the compiler asynchronously.
* It's critical that nothing call into it until it's been initialized or we will
Expand All @@ -138,7 +138,7 @@ import org.apache.spark.util.Utils
if (isInitializeComplete) global.classPath.asURLs
else new PathResolver(settings).result.asURLs // the compiler's classpath
)
def settings = currentSettings
def settings = currentSettings
def mostRecentLine = prevRequestList match {
case Nil => ""
case req :: _ => req.originalLine
Expand Down Expand Up @@ -725,6 +725,17 @@ import org.apache.spark.util.Utils
classServer.stop()
}

/**
* Captures the session names (which are set by system properties) once, instead of for each line.
*/
object FixedSessionNames {
val lineName = sessionNames.line
val readName = sessionNames.read
val evalName = sessionNames.eval
val printName = sessionNames.print
val resultName = sessionNames.result
}

/** Here is where we:
*
* 1) Read some source code, and put it in the "read" object.
Expand All @@ -740,11 +751,11 @@ import org.apache.spark.util.Utils
private var evalCaught: Option[Throwable] = None
private var conditionalWarnings: List[ConditionalWarning] = Nil

val packageName = sessionNames.line + lineId
val readName = sessionNames.read
val evalName = sessionNames.eval
val printName = sessionNames.print
val resultName = sessionNames.result
val packageName = FixedSessionNames.lineName + lineId
val readName = FixedSessionNames.readName
val evalName = FixedSessionNames.evalName
val printName = FixedSessionNames.printName
val resultName = FixedSessionNames.resultName

def bindError(t: Throwable) = {
if (!bindExceptions) // avoid looping if already binding
Expand Down