[LIVY-239] Generate session IDs in SessionStore, not in SessionManager#103
[LIVY-239] Generate session IDs in SessionStore, not in SessionManager#103meisam wants to merge 7 commits into
Conversation
failed on one of the travis instances. Closing this PR and opening it again to rebuild. |
Codecov Report
@@ Coverage Diff @@
## master #103 +/- ##
============================================
- Coverage 68.79% 68.67% -0.12%
Complexity 905 905
============================================
Files 100 100
Lines 5650 5651 +1
Branches 846 845 -1
============================================
- Hits 3887 3881 -6
- Misses 1211 1219 +8
+ Partials 552 551 -1
Continue to review full report at Codecov.
|
vanzin
left a comment
There was a problem hiding this comment.
Looks reasonable from what I remember of this code.
| * | ||
| * @return incremented value | ||
| */ | ||
| def increment(key: String): Long |
There was a problem hiding this comment.
This method name is weird, since you're not incrementing the StateStore itself... maybe nextValue instead (or nextSessionId to follow the name in other parts of the code).
There was a problem hiding this comment.
How about incrementAndGet() to emphasize two things:
- It is an atomic operation.
- It is not solely for generating session IDs.
My second choice is nextValue. But nextSessionId is a high level operation. It is not a good fit for StateStore whose other operations are get, set, remove, and getChildren.
|
Can we add some migration code so user can seamlessly upgrade from older Livy? Thanks! |
- Rename `StateStore.increment()` to `StateStore.nextValue()` - Change the path for storing nextSessionId to - `$STORE_VERSION/$sessionType/nextSessionId`. Task-url: https://issues.apache.org/jira/projects/LIVY/issues/LIVY-555
- Remove unused and unnecessary imports. Task-url: https://issues.apache.org/jira/projects/LIVY/issues/LIVY-555
- Properly mock SessionStore in test cases. Task-url: https://issues.apache.org/jira/projects/LIVY/issues/LIVY-555
Should the migration code be part of Livy? Or should be a separate script that users run once? Also should we change the version in zookeeper path from |
In this case it seems simple enough to be a part of the startup code.
I think you are right, we should. |
| */ | ||
| class BlackholeStateStore(livyConf: LivyConf) extends StateStore(livyConf) { | ||
|
|
||
| private val atomicLong: AtomicLong = new AtomicLong(-1L) |
There was a problem hiding this comment.
Looks like this cannot guarantee the global uniqueness across many Livy services, right? As the atomicLong cannot be shared by processes.
| private def absPath(key: String): Path = new Path(fsUri.getPath(), key) | ||
|
|
||
| override def nextValue(key: String): Long = synchronized { | ||
| val incrementedValue = 1 + get[Long](key).getOrElse(-1L) |
There was a problem hiding this comment.
Is the get or set method atomic?
|
This pull request has been automatically marked as stale because it has had no activity for at least 3 months. If you are still working on this change or plan to move it forward, please leave a comment or push a new commit so we know to keep it open. Otherwise, this PR will be closed automatically in about one month. Thank you for your contribution to Apache Livy! |
What changes were proposed in this pull request?
Move the logic to create session IDs from SessionManager to SessionStore
Why this change is needed?
Generating session IDs at session stores that they are unique across all Livy instances that connect to a session store. Right now only one Livy instance connects to the session store, but to implement multimode HA, generating session IDs in session store prevents inconsistent/colliding values.
How was this patch tested?
JIRA ticket: https://issues.apache.org/jira/browse/LIVY-239