jerryshao commented on a change in pull request #220: [LIVY-654] Ability to 
validate string before creating state/kind of session/statement
URL: https://github.com/apache/incubator-livy/pull/220#discussion_r319831295
 
 

 ##########
 File path: core/src/main/scala/org/apache/livy/sessions/SessionState.scala
 ##########
 @@ -30,33 +30,33 @@ class FinishedSessionState(
 object SessionState {
 
   def apply(s: String): SessionState = s match {
-    case "not_started" => NotStarted
-    case "starting" => Starting
-    case "recovering" => Recovering
-    case "idle" => Idle
-    case "running" => Running
-    case "busy" => Busy
-    case "shutting_down" => ShuttingDown
+    case "not_started" => NotStarted()
+    case "starting" => Starting()
+    case "recovering" => Recovering()
+    case "idle" => Idle()
+    case "running" => Running()
+    case "busy" => Busy()
+    case "shutting_down" => ShuttingDown()
     case "error" => Error()
     case "dead" => Dead()
     case "killed" => Killed()
     case "success" => Success()
     case _ => throw new IllegalArgumentException(s"Illegal session state: $s")
   }
 
-  object NotStarted extends SessionState("not_started", true)
+  case class NotStarted() extends SessionState("not_started", true)
 
-  object Starting extends SessionState("starting", true)
+  case class Starting() extends SessionState("starting", true)
 
-  object Recovering extends SessionState("recovering", true)
+  case class Recovering() extends SessionState("recovering", true)
 
-  object Idle extends SessionState("idle", true)
+  case class Idle() extends SessionState("idle", true)
 
-  object Running extends SessionState("running", true)
+  case class Running() extends SessionState("running", true)
 
-  object Busy extends SessionState("busy", true)
+  case class Busy() extends SessionState("busy", true)
 
-  object ShuttingDown extends SessionState("shutting_down", false)
+  case class ShuttingDown() extends SessionState("shutting_down", false)
 
 Review comment:
   The changes here will create many small `SessionState` objects, which is 
unnecessary and can be replaced by singleton.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to