Skip to content

Commit

Permalink
LIYV-289. Fix NPE in ContextLauncher when Driver is not successfully …
Browse files Browse the repository at this point in the history
…started and expose the state of RSCClient (cloudera#268)

Change-Id: Iae8b04393c4c52d87e87bd451916d6191007db08
  • Loading branch information
jerryshao authored and zjffdu committed Jan 4, 2017
1 parent 6077628 commit f5dea60
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 9 additions & 5 deletions rsc/src/main/java/com/cloudera/livy/rsc/ContextLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ private ContextLauncher(RSCClientFactory factory, RSCConf conf) throws IOExcepti
@Override
public void onFailure(Throwable error) throws Exception {
// If promise is cancelled or failed, make sure spark-submit is not leaked.
child.kill();
if (child != null) {
child.kill();
}
}
});

Expand Down Expand Up @@ -137,10 +139,12 @@ private void connectTimeout(RegistrationHandler handler) {
private void dispose(boolean forceKill) {
factory.getServer().unregisterClient(clientId);
try {
if (forceKill) {
child.kill();
} else {
child.detach();
if (child != null) {
if (forceKill) {
child.kill();
} else {
child.detach();
}
}
} finally {
factory.unref();
Expand Down
4 changes: 4 additions & 0 deletions rsc/src/main/java/com/cloudera/livy/rsc/RSCClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ public void onFailure(Throwable error) {
isAlive = true;
}

public boolean isAlive() {
return isAlive;
}

private synchronized void connectToContext(final ContextInfo info) throws Exception {
this.contextInfo = info;

Expand Down

0 comments on commit f5dea60

Please sign in to comment.