Github user liancheng commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2671#discussion_r18459115
  
    --- Diff: 
sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2Suite.scala
 ---
    @@ -70,37 +73,39 @@ class HiveThriftServer2Suite extends FunSuite with 
Logging {
     
         val serverStarted = Promise[Unit]()
         val buffer = new ArrayBuffer[String]()
    +    val startString =
    +      "starting org.apache.spark.sql.hive.thriftserver.HiveThriftServer2, 
logging to "
    +    val maxTries = 30
     
         def captureOutput(source: String)(line: String) {
           buffer += s"$source> $line"
    -      if (line.contains("ThriftBinaryCLIService listening on")) {
    -        serverStarted.success(())
    +      if (line.contains(startString)) {
    +        val logFile = new File(line.substring(startString.length))
    +        var tryNum = 0
    +        // This is a hack to wait logFile ready
    +        Thread.sleep(5000)
    +        // logFile may have not finished, try every second
    +        while (!logFile.exists() || (!fileToString(logFile).contains(
    +          "ThriftBinaryCLIService listening on") && tryNum < maxTries)) {
    +          Thread.sleep(1000)
    +        }
    +        if (fileToString(logFile).contains("ThriftBinaryCLIService 
listening on")) {
    +          serverStarted.success(())
    +        } else {
    +          throw new TimeoutException()
    +        }
           }
         }
    -
         val process = Process(command).run(
           ProcessLogger(captureOutput("stdout"), captureOutput("stderr")))
     
         Future {
           val exitValue = process.exitValue()
    -      logInfo(s"Spark SQL Thrift server process exit value: $exitValue")
    +      logInfo(s"Start Spark SQL Thrift server process exit value: 
$exitValue")
    --- End diff --
    
    Why "Start" here? When this line is executed, the server process has 
already ended.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to