Explorar el Código

[livy] Rename batch dead state to success

Erick Tryzelaar hace 10 años
padre
commit
1fcc41e3fd

+ 1 - 1
apps/spark/java/livy-server/src/main/scala/com/cloudera/hue/livy/server/batch/BatchProcess.scala

@@ -69,7 +69,7 @@ private class BatchProcess(val id: Int,
       destroyProcess()
     }
 
-    Dead()
+    Success()
   }
 
   override def lines: IndexedSeq[String] = process.stdoutLines

+ 5 - 5
apps/spark/java/livy-server/src/main/scala/com/cloudera/hue/livy/server/batch/BatchYarn.scala

@@ -26,7 +26,7 @@ import com.cloudera.hue.livy.yarn._
 
 import scala.annotation.tailrec
 import scala.concurrent.{ExecutionContextExecutor, ExecutionContext, Future}
-import scala.util.{Failure, Success}
+import scala.util
 
 object BatchYarn {
 
@@ -69,8 +69,8 @@ private class BatchYarn(val id: Int, jobFuture: Future[Job]) extends Batch {
   private var _jobThread: Thread = _
 
   jobFuture.onComplete {
-    case Failure(_) => _state = Error()
-    case Success(job) =>
+    case util.Failure(_) => _state = Error()
+    case util.Success(job) =>
       _state = Running()
 
       _jobThread = new Thread {
@@ -81,7 +81,7 @@ private class BatchYarn(val id: Int, jobFuture: Future[Job]) extends Batch {
               Thread.sleep(5000)
               job.getStatus match {
                 case Client.SuccessfulFinish() =>
-                  _state = Dead()
+                  _state = Success()
                 case Client.UnsuccessfulFinish() =>
                   _state = Error()
                 case _ => aux()
@@ -101,7 +101,7 @@ private class BatchYarn(val id: Int, jobFuture: Future[Job]) extends Batch {
   override def stop(): Future[Unit] = {
     jobFuture.map { job =>
       job.stop()
-      _state = Dead()
+      _state = Success()
       ()
     }
   }

+ 2 - 2
apps/spark/java/livy-server/src/main/scala/com/cloudera/hue/livy/server/batch/State.scala

@@ -32,6 +32,6 @@ case class Error() extends State {
   override def toString = "error"
 }
 
-case class Dead() extends State {
-  override def toString = "dead"
+case class Success() extends State {
+  override def toString = "success"
 }

+ 2 - 2
apps/spark/java/livy-server/src/test/scala/com/cloudera/hue/livy/server/batches/BatchProcessSpec.scala

@@ -23,7 +23,7 @@ import java.nio.file.{Files, Path}
 import java.util.concurrent.TimeUnit
 
 import com.cloudera.hue.livy.Utils
-import com.cloudera.hue.livy.server.batch.{Dead, CreateBatchRequest, BatchProcess}
+import com.cloudera.hue.livy.server.batch.{Success, CreateBatchRequest, BatchProcess}
 import org.scalatest.{ShouldMatchers, BeforeAndAfterAll, FunSpec}
 
 import scala.concurrent.duration.Duration
@@ -56,7 +56,7 @@ class BatchProcessSpec
       val batch = BatchProcess(0, req)
 
       Utils.waitUntil({ () =>
-        batch.state == Dead()
+        batch.state == Success()
       }, Duration(10, TimeUnit.SECONDS))
 
       batch.lines should contain("hello world")

+ 2 - 2
apps/spark/java/livy-server/src/test/scala/com/cloudera/hue/livy/server/batches/BatchServletSpec.scala

@@ -90,7 +90,7 @@ class BatchServletSpec extends ScalatraSuite with FunSpecLike with BeforeAndAfte
       {
         val batch: Batch = batchManager.getBatch(0).get
         Utils.waitUntil({ () =>
-          batch.state == Dead()
+          batch.state == Success()
         }, Duration(10, TimeUnit.SECONDS))
       }
 
@@ -99,7 +99,7 @@ class BatchServletSpec extends ScalatraSuite with FunSpecLike with BeforeAndAfte
         header("Content-Type") should include("application/json")
         val parsedBody = parse(body)
         parsedBody \ "id" should equal (JInt(0))
-        parsedBody \ "state" should equal (JString("dead"))
+        parsedBody \ "state" should equal (JString("success"))
         parsedBody \ "lines" should equal (JArray(List(
           JString("hello world")
         )))