[ZEPPELIN-6693] Drive NotebookServer heartbeat scheduler shutdown from ZeppelinServer lifecycle - #5499
Conversation
HwangRock
left a comment
There was a problem hiding this comment.
Thanks for working on my issue! I confirmed the feature works 👍
| } | ||
|
|
||
| @Test | ||
| void stopHeartbeatSchedulerAllowsRepeatedStartStopCycles() { |
There was a problem hiding this comment.
Tests look good!
Right now the tests all call stopHeartbeatScheduler directly,
so they'd still pass even if the ZeppelinServer#shutdown call got removed.
The actual fix is that shutdown drives the teardown, and that path isn't covered.
Might be worth adding one that goes through the real shutdown path. Spin up MiniZeppelinServer, open a connection to start the heartbeat, shut down and check the scheduler's gone.
There was a problem hiding this comment.
+1. The two new tests also pass against the previous shutdown-hook code, so they don't pin down what this PR changes. There's no need to open a connection: calling startHeartbeatScheduler() directly, then checking scheduler.isShutdown() after MiniZeppelinServer.shutDown(), is enough.
| * Stops the websocket heartbeat scheduler, if running. Called by ZeppelinServer#shutdown so | ||
| * the scheduler follows the server lifecycle, both on JVM shutdown and when the server is | ||
| * closed inside a running JVM (for example in tests). Safe to call multiple times and safe | ||
| * to call when the scheduler was never started; a later connection starts it again. |
There was a problem hiding this comment.
The caller and the reason for this change are in the commit message, so the javadoc could keep just this method's contract.
| * Stops the websocket heartbeat scheduler, if running. Called by ZeppelinServer#shutdown so | |
| * the scheduler follows the server lifecycle, both on JVM shutdown and when the server is | |
| * closed inside a running JVM (for example in tests). Safe to call multiple times and safe | |
| * to call when the scheduler was never started; a later connection starts it again. | |
| * Stops the websocket heartbeat scheduler, if running. Safe to call multiple times and safe | |
| * to call when the scheduler was never started; a later connection starts it again. |
| } | ||
|
|
||
| @Test | ||
| void stopHeartbeatSchedulerAllowsRepeatedStartStopCycles() { |
There was a problem hiding this comment.
+1. The two new tests also pass against the previous shutdown-hook code, so they don't pin down what this PR changes. There's no need to open a connection: calling startHeartbeatScheduler() directly, then checking scheduler.isShutdown() after MiniZeppelinServer.shutDown(), is enough.
…m ZeppelinServer lifecycle The heartbeat scheduler was stopped by its own JVM shutdown hook, which never ran when the server was closed inside a running JVM (e.g. in tests), so schedulers and hooks piled up across start/stop cycles. ZeppelinServer#shutdown now calls stopHeartbeatScheduler() after Jetty stops, covering both in-JVM close and JVM exit. The dedicated hook is removed. Add a test that checks the scheduler is stopped via MiniZeppelinServer.shutDown().
d9e9e30 to
3067fde
Compare
|
Thanks @HwangRock @tbonelee for the review! I've addressed the comments and amended them into the existing commit (force-pushed).
I also updated the PR description to reflect the new test. |
|
Merged into master |
What is this PR for?
ZEPPELIN-6092 added a websocket heartbeat scheduler to
NotebookServer, torn down by a dedicated JVM shutdown hook that the class registered for itself. That hook only covers the JVM-exit path:MiniZeppelinServer.shutDown()callingzepServer.close()), the hook never runs, so repeated start/stop cycles can leave a scheduler and a hook behind per instance.ZeppelinServer's own shutdown hook and this one run in parallel for the same event.This PR stops the scheduler from
ZeppelinServer#shutdown, which already covers both paths (the JVM shutdown hook andclose()), and removes the dedicated hook together with itsremoveShutdownHook/IllegalStateExceptionhandling and self-reference guard. The scheduler is stopped after Jetty, so no new connection can restart it.What type of PR is it?
Improvement
Todos
ZeppelinServer#shutdownNotebookServerZeppelinServer#shutdownpathWhat is the Jira issue?
ZEPPELIN-6693
How should this be tested?
NotebookServerHeartbeatTest#zeppelinServerShutdownStopsHeartbeatScheduler: starts aMiniZeppelinServer, starts the heartbeat scheduler, callsshutDown(), and checks the scheduler is shut down. Fails if thestopHeartbeatScheduler()call inZeppelinServer#shutdownis removed.NotebookServerHeartbeatTest#stopHeartbeatSchedulerAllowsRepeatedStartStopCycles: starts and stops the scheduler three times and checks that each scheduler is shut down and a new one can start.NotebookServerHeartbeatTest#stopHeartbeatSchedulerIsSafeWhenNeverStarted: stopping without a prior start, twice, does not throw.NotebookServerHeartbeatTestcases still pass.Questions: