Skip to content

Commit

Permalink
Uses temporary directory as Thrift server PID directory
Browse files Browse the repository at this point in the history
  • Loading branch information
liancheng committed Feb 27, 2015
1 parent 1b3d1e3 commit 252fa0f
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import org.scalatest.{BeforeAndAfterAll, FunSuite}
import org.apache.spark.Logging
import org.apache.spark.sql.catalyst.util
import org.apache.spark.sql.hive.HiveShim
import org.apache.spark.util.Utils

object TestData {
def getTestDataFilePath(name: String) = {
Expand Down Expand Up @@ -273,6 +274,7 @@ abstract class HiveThriftServer2Test extends FunSuite with BeforeAndAfterAll wit
private var metastorePath: File = _
private def metastoreJdbcUri = s"jdbc:derby:;databaseName=$metastorePath;create=true"

private val pidDir: File = Utils.createTempDir("thriftserver-pid")
private var logPath: File = _
private var logTailingProcess: Process = _
private var diagnosisBuffer: ArrayBuffer[String] = ArrayBuffer.empty[String]
Expand Down Expand Up @@ -320,7 +322,7 @@ abstract class HiveThriftServer2Test extends FunSuite with BeforeAndAfterAll wit
"SPARK_TESTING" -> "0",
// Points SPARK_PID_DIR to SPARK_HOME, otherwise only 1 Thrift server instance can be started
// at a time, which is not Jenkins friendly.
"SPARK_PID_DIR" -> "../../")
"SPARK_PID_DIR" -> pidDir.getCanonicalPath)

logPath = Process(command, None, env: _*).lines.collectFirst {
case line if line.contains(LOG_FILE_MARK) => new File(line.drop(LOG_FILE_MARK.length))
Expand Down Expand Up @@ -353,7 +355,7 @@ abstract class HiveThriftServer2Test extends FunSuite with BeforeAndAfterAll wit

private def stopThriftServer(): Unit = {
// The `spark-daemon.sh' script uses kill, which is not synchronous, have to wait for a while.
Process(stopScript, None, "SPARK_PID_DIR" -> "../../").run().exitValue()
Process(stopScript, None, "SPARK_PID_DIR" -> pidDir.getCanonicalPath).run().exitValue()
Thread.sleep(3.seconds.toMillis)

warehousePath.delete()
Expand Down

0 comments on commit 252fa0f

Please sign in to comment.