[ 
https://issues.apache.org/jira/browse/LIVY-41?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16186290#comment-16186290
 ] 

ASF GitHub Bot commented on LIVY-41:
------------------------------------

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

    https://github.com/apache/incubator-livy/pull/48#discussion_r141951874
  
    --- Diff: 
server/src/main/scala/org/apache/livy/server/batch/BatchSessionServlet.scala ---
    @@ -43,8 +44,23 @@ class BatchSessionServlet(
       override protected def createSession(req: HttpServletRequest): 
BatchSession = {
         val createRequest = bodyAs[CreateBatchRequest](req)
         val proxyUser = checkImpersonation(createRequest.proxyUser, req)
    +    val sessionId = sessionManager.nextId()
    +    val sessionName: String = createRequest.name match {
    +      case Some(name) if sessionManager.get(name).isEmpty =>
    +        name
    +      case Some(name) =>
    +        // this does NOT guarantee that by the time this session is ready 
to be registered in
    +        // sessionManager, another with the same name is not registered. 
But in most cases,
    +        // it prevents Livy from submitting applications to Spark.
    +        val msg = s"Session $name already exists! " +
    +          s"Choose a different name or delete the existing session."
    +        throw new IllegalArgumentException(msg)
    --- End diff --
    
    One case that we should keep in mind about returning an error code. 
    Assume the existing session `s` with name `daily-job`.
    If the owner `s` is requesting a new session with name `daily-job`, we will 
reach this point and the user gets a http 400 bad request.
    But if a different user is requesting a session `s2` with name `daily-job`, 
the user gets a 403 Forbidden before reaching this point, because he/she does 
not have access to `/sessions/daily-job/`.



> Need a way to submit codes through Named Session instead of Session ID numbers
> ------------------------------------------------------------------------------
>
>                 Key: LIVY-41
>                 URL: https://issues.apache.org/jira/browse/LIVY-41
>             Project: Livy
>          Issue Type: New Feature
>          Components: Core
>    Affects Versions: 0.1
>            Reporter: Prabhu Kasinathan
>            Priority: Minor
>          Time Spent: 2h 50m
>  Remaining Estimate: 0h
>
> Currently, we are creating new pyspark session and submitting codes through 
> newly created session id as below
> curl -X POST --data '
> {"kind": "pyspark", "queue": "spark", "name": "Livy_Example"}
> ' -H "Content-Type: application/json" localhost:8998/sessions
> curl localhost:8998/sessions/1/statements -X POST -H 'Content-Type: 
> application/json' -d '
> {"code":"1 + 1"}
> '
> But, it would be nice if we have a way to submit the codes through session 
> name instead of session id. That way, we need not to maintain a lookup table 
> for session-id to session-name. Users will be able to submit their codes 
> easily as below through session names instead of worrying about session id.
> curl -X POST --data '
> {"kind": "pyspark", "queue": "spark", "name": "mkt_risk_batch"}
> ' -H "Content-Type: application/json" localhost:8998/sessions
> curl localhost:8998/sessions/mkt_risk_batch/statements -X POST -H 
> 'Content-Type: application/json' -d '
> {"code":"1 + 1"}
> '



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to