use of com.microsoft.azuretools.hdinsight.SparkSubmissionToolWindowView in project azure-tools-for-java by Microsoft.
the class SparkSubmitModel method tryToCreateBatchSparkJob.
private void tryToCreateBatchSparkJob(@NotNull final IClusterDetail selectedClusterDetail) throws HDIException, IOException {
SparkBatchSubmission.getInstance().setCredentialsProvider(selectedClusterDetail.getHttpUserName(), selectedClusterDetail.getHttpPassword());
HttpResponse response = SparkBatchSubmission.getInstance().createBatchSparkJob(SparkSubmitHelper.getLivyConnectionURL(selectedClusterDetail), submissionParameter);
if (response.getCode() == 201 || response.getCode() == 200) {
HDInsightUtil.showInfoOnSubmissionMessageWindow("Info : Submit to spark cluster successfully.");
postEventProperty.put("IsSubmitSucceed", "true");
String jobLink = String.format("%s/sparkhistory", selectedClusterDetail.getConnectionUrl());
HDInsightUtil.setHyperLinkWithText("See spark job view from ", jobLink, jobLink);
@SuppressWarnings("serial") final SparkSubmitResponse sparkSubmitResponse = new Gson().fromJson(response.getMessage(), new TypeToken<SparkSubmitResponse>() {
}.getType());
// Set submitted spark application id and http request info for stopping running application
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
SparkSubmissionToolWindowView view = HDInsightUtil.getSparkSubmissionToolWindowView();
view.setSparkApplicationStopInfo(selectedClusterDetail.getConnectionUrl(), sparkSubmitResponse.getId());
view.setStopButtonState(true);
view.getJobStatusManager().resetJobStateManager();
}
});
SparkSubmitHelper.getInstance().printRunningLogStreamingly(sparkSubmitResponse.getId(), selectedClusterDetail, postEventProperty);
} else {
HDInsightUtil.showErrorMessageOnSubmissionMessageWindow(String.format("Error : Failed to submit to spark cluster. error code : %d, reason : %s.", response.getCode(), response.getContent()));
postEventProperty.put("IsSubmitSucceed", "false");
postEventProperty.put("SubmitFailedReason", response.getContent());
AppInsightsClient.create(Messages.SparkSubmissionButtonClickEvent, null, postEventProperty);
}
}
Aggregations