Skip to content

Commit

Permalink
[FLINK-9765] [sql-client] Improve CLI responsiveness when cluster is …
Browse files Browse the repository at this point in the history
…not reachable

Moves the job cancellation into the final phase of the refresh thread in order to
keep the CLI responsive.

This closes apache#6265.
  • Loading branch information
twalthr committed Jul 24, 2018
1 parent b9a916a commit 6022225
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,7 @@ protected List<AttributedString> computeMainLines() {

@Override
protected void cleanUp() {
// stop retrieval
stopRetrieval();

// cancel table program
try {
client.getExecutor().cancelQuery(client.getContext(), resultDescriptor.getResultId());
} catch (SqlExecutionException e) {
// ignore further exceptions
}
}

// --------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -285,6 +277,15 @@ public void run() {
display();
}
}

// cancel table program
try {
// the cancellation happens in the refresh thread in order to keep the main thread
// responsive at all times; esp. if the cluster is not available
client.getExecutor().cancelQuery(client.getContext(), resultDescriptor.getResultId());
} catch (SqlExecutionException e) {
// ignore further exceptions
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public interface Executor {
List<Row> retrieveResultPage(String resultId, int page) throws SqlExecutionException;

/**
* Cancels a table program and stops the result retrieval.
* Cancels a table program and stops the result retrieval. Blocking until cancellation command has
* been sent to cluster.
*/
void cancelQuery(SessionContext session, String resultId) throws SqlExecutionException;

Expand Down

0 comments on commit 6022225

Please sign in to comment.