[
https://issues.apache.org/jira/browse/LIVY-41?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16183734#comment-16183734
]
ASF GitHub Bot commented on LIVY-41:
------------------------------------
Github user jerryshao commented on a diff in the pull request:
https://github.com/apache/incubator-livy/pull/48#discussion_r141534310
--- Diff:
server/src/main/scala/org/apache/livy/sessions/SessionManager.scala ---
@@ -92,13 +94,29 @@ class SessionManager[S <: Session, R <:
RecoveryMetadata : ClassTag](
def register(session: S): S = {
info(s"Registering new session ${session.id}")
synchronized {
- sessions.put(session.id, session)
+ // in InteractiveSessionServlet.createSession() and
BatchSessionServlet.createSession(),
+ // Livy checks to make sure another session with the same name does
not exist already.
+ // This case should not happen rarely.
+ // already exists. But looking up a session name and adding it to
the set of existing sessions
+ // should happen atomically.
+ if (sessionsByName.contains(session.name)) {
+ val msg = s"Session ${session.name} already exists!"
+ error(msg)
+ delete(session)
--- End diff --
I think fail the request and return user the specific bad http code would
be better then choosing another name for user. Because user want to create a
session with name "A" for example, if Livy cannot satisfy user's requirement,
then user should choose another name. It is better to let user to decide than
letting Livy to handle it.
> 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)