LIVY-246. Support multiple Spark environments in Livy #232
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR propose to add a
SparkEnvironment
to isolate Spark's related configurations and libraries, also extend it to support multipleSparkEnvironment
in LivyServer.Why
Current Livy Supports different Sparks with one build, user could configure different spark home to choose the right Spark to run, but this still requires stopping LivyServer, updating configuration and restarting it. To further extend the usability of Livy, it would be better to support different Sparks in runtime, when user create a session, user could specify which Spark they wanted and Livy will pick right Spark and start application.
How to use
To enable it, we extend the Livy configurations to support multiple Spark profiles, user could configure:
Internally Livy will create two Spark environments "test" and "product", when user issue a session creation request, he could specify
sparkEnv
with "test" in JSON body. Livy will pick the right Spark environment and start application.To be compatible with existing configuration and test, if user configured:
This is equal to:
Livy will treat these as "default" Spark environment. If user didn't specify
sparkEnv
in JSON body, then the default one will be picked.Implementation
To achieve this, I introduced a
SparkEnvironment
class, one LivyServer can have multipleSparkEnvironment
based on configuration. Also I refactored the code to move Spark related codes into this class.Limitation
Some configurations like spark master and deploy mode cannot be configured per Spark environment currently.
Works done and to be done
Please review and suggest, thanks a lot.