NIFI-6175 Spark Livy - Improving Livy#3511
Conversation
77ee45e to
e351af3
Compare
not-for-me
left a comment
There was a problem hiding this comment.
@patricker, I just left some comments as a one of suggestion.
Please consisder about them.
| String APPLICATION_JSON = "application/json"; | ||
| String USER = "nifi"; | ||
|
|
||
| LivyBatch getBatchSession(Integer batchid) throws SessionManagerException; |
There was a problem hiding this comment.
How about renaming batchid as a camelCase?
| appendValue(payload, "className", className); | ||
|
|
||
| try { | ||
| if (codeArgs != null) { |
There was a problem hiding this comment.
I'm curious why you didn't use appendValue method in this try-catch block
There was a problem hiding this comment.
Because they aren't values, they are arrays. Note the use of splitCollect instead.
| } | ||
| } | ||
|
|
||
| private String splitCollect(String arg) throws IOException { |
There was a problem hiding this comment.
It would be nicer to rename transformCsvToJsonArrayStr.
Because It does two actions: split and, converting.
There was a problem hiding this comment.
Thanks for the feedback, but it is supposed to do two things :)
In the UI, NiFi users provide a comma delimited list of values. In the code, we accept that comma delimited string and need to convert it to JSON. This method handles that.
| // Two scenarios: we have no elastic pool sizing, in which case definitely look for candidates | ||
| // Or, we do have elastic pool sizing, in which case we need to make sure we are above our max | ||
| // pool size | ||
| if(idleSessions > 0 && numSessions > sessionPoolSize && (!elasticSessionPool || numSessions > maxSessionPoolSize)) { |
There was a problem hiding this comment.
How about use idleSessionInfo.size() instead of idleSessions int value?
int idleSessions = idleSessionInfo.size();
if(idleSessions > 0 && numSessions > sessionPoolSize && (!elasticSessionPool || numSessions > maxSessionPoolSize)) {
int sessionID = idleSessionInfo.keySet().stream().findFirst().get();
...There was a problem hiding this comment.
Yes, the variable serves no purpose anymore. It's just leftover from the original code.
| // Two scenarios: we have no elastic pool sizing, in which case definitely look for candidates | ||
| // Or, we do have elastic pool sizing, in which case we need to make sure we are above our max | ||
| // pool size | ||
| if(idleSessions > 0 && numSessions > sessionPoolSize && (!elasticSessionPool || numSessions > maxSessionPoolSize)) { |
There was a problem hiding this comment.
I'm not sure Is this conditional statement satisfies all possible cases...
e.g.) idleSessions=2, numSessions=6, elasticSessionPool=true maxSessionPoolSize=4
=> we have to delete two idle sessions, but it only picks randomly one idle session and deletes it.
There was a problem hiding this comment.
It only stops 1 idle session at a time, that is true, but on the next run through, which happens every few seconds, it will stop the next one, and the next one, until it is back to where it is supposed to be.
There was a problem hiding this comment.
Thanks for your elaborate explanation.
I got your point.
|
HI, @patricker , @mattyb149 |
|
Rebased against 1.12-SNAPSHOT master. @not-for-me I don't have any control when this will get merged. When a technology is not widely used, such as Livy, or in my case MS SQL Server CDC (another PR I've had in progress since late 2017), it can take a really long time before a team member comes along who is comfortable with testing and merging the code. |
|
@patricker if this goes fine in travis and you're confident it doesn't break backward compatibility and the L&N is covered ping me and I'll merge. For new stuff being included we should keep the high bar. For improving things already in the kit we should be faster. Especially when it is a committer/PMC member doing it! |
|
Thanks @joewitt. There are no changes to the pom, no new dependencies, so we are good on L&N with no changes. Let me think about the, "confident it doesn't break backwards compatibility". I'm 95% sure, but I will review the code again, as it's been a while since I looked at the code currently in |
|
@patricker Can the contents in this PR be used to build the livy session controller and sparkinteractive processor? I have a use case to submit pyspark jobs from nifi. But the controllerservice and processor that comes along with nifi has limitations. |
|
@naru014 Yes, it can. It also includes Batch processing controller service/processor. The one that comes with NiFi currently has severe limitations. I keep forgetting to get this one merged. I just need to update it for the latest version of NiFI. |
@patricker Thank you. We have got this built and included in the nifi. But when using a livy session controller service per nifi flow, the flows in some cases dont use the session created by the controller for that flow, but any other available session. Is this expected? So currently instead of creating a livy session controller per flow, I have created one livy session controller on the parent nifi-flow and it is inherited by all the child flows. By doing that, the nifi cluster has say min 2 sessions available and is used by any running flow based on its availability. |
|
@naru014 Yes, this is expected. This is somewhat a limitation of Livy 0.5.0. Livy will not let you find sessions by name until v0.6.0. This version is available, but I don't have it in my environment. There are two work arounds I've used.
If you have Livy 0.6.0 you could update the code to work with session names. This would easily work around your issue, each session in a session controller could be named Note: Livy never updated the documentation when they added this feature (apache/livy#48). But it looks like you just replace the sessionId with the name when making calls. |
@patricker Thank you. |
|
We're marking this PR as stale due to lack of updates in the past few months. If after another couple of weeks the stale label has not been removed this PR will be closed. This stale marker and eventual auto close does not indicate a judgement of the PR just lack of reviewer bandwidth and helps us keep the PR queue more manageable. If you would like this PR re-opened you can do so and a committer can remove the stale tag. Or you can open a new PR. Try to help review other PRs to increase PR review bandwidth which in turn helps yours. |
|
@patricker - any chance you can rebase this against main/latest? |
|
We're marking this PR as stale due to lack of updates in the past few months. If after another couple of weeks the stale label has not been removed this PR will be closed. This stale marker and eventual auto close does not indicate a judgement of the PR just lack of reviewer bandwidth and helps us keep the PR queue more manageable. If you would like this PR re-opened you can do so and a committer can remove the stale tag. Or you can open a new PR. Try to help review other PRs to increase PR review bandwidth which in turn helps yours. |
|
@patricker - I know this PR has been automatically closed but I'm currently playing with NiFi and Livy and if you want to re-open it and rebase it, happy to review/test this one. |
|
Hey @pvillard31. I've got some bad news, I changed companies and I don't have access to a Hadoop environment, and even less a Livy environment :(. I'd still love to see this PR get rebased and merged, but I don't think I'm the one to do it anymore. |
|
Thanks for the feedback @patricker - will try to have a look if I get the chance. |
|
Closing in favor of #5601 as it incorporates these changes and continues forward |
Description of PR
The Livy Session Controller is missing many of the options available, and many of them I feel are critical for this service to be useful (queue? conf? num of executors?)
Add in functionality to shutdown open sessions when service is disabled.
For all changes:
Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
Does your PR title start with NIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
Has your PR been rebased against the latest commit within the target branch (typically
master)?Is your initial contribution a single, squashed commit? Additional commits in response to PR reviewer feedback should be made on this branch and pushed to allow change tracking. Do not
squashor use--forcewhen pushing to allow for clean monitoring of changes.For code changes:
mvn -Pcontrib-check clean installat the rootnififolder?LICENSEfile, including the mainLICENSEfile undernifi-assembly?NOTICEfile, including the mainNOTICEfile found undernifi-assembly?.displayNamein addition to .name (programmatic access) for each of the new properties?For documentation related changes:
Note:
Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.