use of rx.exceptions.Exceptions in project azure-tools-for-java by Microsoft.
the class SparkBatchJobDebuggerRunner method execute.
@Override
protected void execute(@NotNull ExecutionEnvironment environment, @Nullable Callback callback, @NotNull RunProfileState state) throws ExecutionException {
SparkBatchJobSubmissionState submissionState = (SparkBatchJobSubmissionState) state;
SparkSubmitModel submitModel = submissionState.getSubmitModel();
SparkSubmissionParameter submissionParameter = submitModel.getSubmissionParameter();
IClusterDetail clusterDetail = submitModel.getSelectedClusterDetail();
Map<String, String> postEventProperty = new HashMap<>();
submitModel.buildArtifactObservable(submissionParameter.getArtifactName()).flatMap((artifact) -> submitModel.deployArtifactObservable(artifact, clusterDetail).subscribeOn(Schedulers.io())).map((selectedClusterDetail) -> {
// Create Batch Spark Debug Job
try {
return submitModel.tryToCreateBatchSparkDebugJob(selectedClusterDetail);
} catch (Exception e) {
HDInsightUtil.setJobRunningStatus(submitModel.getProject(), false);
throw Exceptions.propagate(e);
}
}).flatMap((remoteDebugJob) -> startDebuggerObservable(environment, callback, submissionState, remoteDebugJob).subscribeOn(Schedulers.computation()).zipWith(submitModel.jobLogObservable(remoteDebugJob.getBatchId(), clusterDetail).subscribeOn(Schedulers.computation()), (session, ignore) -> session).doOnError(err -> {
try {
HDInsightUtil.showErrorMessageOnSubmissionMessageWindow(submitModel.getProject(), "Error : Spark batch debugging job is killed, got exception " + err);
remoteDebugJob.killBatchJob();
HDInsightUtil.setJobRunningStatus(submitModel.getProject(), false);
} catch (IOException ignore) {
}
})).subscribe(sparkBatchDebugSession -> {
HDInsightUtil.showInfoOnSubmissionMessageWindow(submitModel.getProject(), "Info : Debugging Spark batch job in cluster is done.");
sparkBatchDebugSession.close();
HDInsightUtil.setJobRunningStatus(submitModel.getProject(), false);
postEventProperty.put("IsSubmitSucceed", "true");
AppInsightsClient.create(HDInsightBundle.message("SparkRunConfigDebugButtonClick"), null, postEventProperty);
}, (throwable) -> {
// set the running flag to false
HDInsightUtil.setJobRunningStatus(submitModel.getProject(), false);
String errorMessage;
if (throwable instanceof CompositeException) {
CompositeException exceptions = (CompositeException) throwable;
errorMessage = exceptions.getExceptions().stream().map(Throwable::getMessage).collect(Collectors.joining("; "));
} else {
errorMessage = throwable.getMessage();
}
HDInsightUtil.showErrorMessageOnSubmissionMessageWindow(submitModel.getProject(), "Error : Spark batch Job remote debug failed, got exception: " + errorMessage);
postEventProperty.put("IsSubmitSucceed", "false");
postEventProperty.put("SubmitFailedReason", errorMessage.substring(0, 50));
AppInsightsClient.create(HDInsightBundle.message("SparkRunConfigDebugButtonClick"), null, postEventProperty);
});
}
Aggregations