use of com.microsoft.azure.hdinsight.sdk.common.HttpResponse in project azure-tools-for-java by Microsoft.
the class SparkSubmitHelper method printoutJobLog.
private int printoutJobLog(Project project, int id, int from_index, IClusterDetail clusterDetail) throws IOException {
HttpResponse httpResponse = SparkBatchSubmission.getInstance().getBatchJobFullLog(getLivyConnectionURL(clusterDetail), id);
sparkJobLog = new Gson().fromJson(httpResponse.getMessage(), new TypeToken<SparkJobLog>() {
}.getType());
if (!HDInsightUtil.getSparkSubmissionToolWindowManager(project).getJobStatusManager().isApplicationGenerated()) {
String sparkLogs = Joiner.on("").join(sparkJobLog.getLog());
String applicationId = getApplicationIdFromYarnLog(sparkLogs);
if (applicationId != null) {
HDInsightUtil.getSparkSubmissionToolWindowManager(project).setBrowserButtonState(true);
HDInsightUtil.getSparkSubmissionToolWindowManager(project).getJobStatusManager().setApplicationIdGenerated();
HDInsightUtil.getSparkSubmissionToolWindowManager(project).getJobStatusManager().setApplicationId(applicationId);
}
}
int counter = 0;
if (sparkJobLog.getLog().size() > 0) {
for (String line : sparkJobLog.getLog()) {
if (counter >= from_index && !StringHelper.isNullOrWhiteSpace(line)) {
HDInsightUtil.getSparkSubmissionToolWindowManager(project).setInfo(line, true);
}
counter++;
}
}
return sparkJobLog.getTotal();
}
use of com.microsoft.azure.hdinsight.sdk.common.HttpResponse 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(project, "Info : Submit to spark cluster successfully.");
postEventProperty.put("IsSubmitSucceed", "true");
String jobLink = selectedClusterDetail.isEmulator() ? ((EmulatorClusterDetail) selectedClusterDetail).getSparkHistoryEndpoint() : String.format("%s/sparkhistory", selectedClusterDetail.getConnectionUrl());
HDInsightUtil.getSparkSubmissionToolWindowManager(project).setHyperLinkWithText("See spark job view from ", jobLink, jobLink);
SparkSubmitResponse sparkSubmitResponse = new Gson().fromJson(response.getMessage(), new TypeToken<SparkSubmitResponse>() {
}.getType());
// Set submitted spark application id and http request info for stopping running application
HDInsightUtil.getSparkSubmissionToolWindowManager(project).setSparkApplicationStopInfo(selectedClusterDetail, sparkSubmitResponse.getId());
HDInsightUtil.getSparkSubmissionToolWindowManager(project).setStopButtonState(true);
HDInsightUtil.getSparkSubmissionToolWindowManager(project).getJobStatusManager().resetJobStateManager();
SparkSubmitHelper.getInstance().printRunningLogStreamingly(project, sparkSubmitResponse.getId(), selectedClusterDetail, postEventProperty);
} else {
HDInsightUtil.showErrorMessageOnSubmissionMessageWindow(project, 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(HDInsightBundle.message("SparkSubmissionButtonClickEvent"), null, postEventProperty);
}
}
use of com.microsoft.azure.hdinsight.sdk.common.HttpResponse in project azure-tools-for-java by Microsoft.
the class SparkSubmitHelper method printoutJobLog.
private int printoutJobLog(/*Project project,*/
int id, int from_index, IClusterDetail clusterDetail) throws IOException {
HttpResponse httpResponse = SparkBatchSubmission.getInstance().getBatchJobFullLog(clusterDetail.getConnectionUrl() + "/livy/batches", id);
sparkJobLog = new Gson().fromJson(httpResponse.getMessage(), new TypeToken<SparkJobLog>() {
}.getType());
if (!HDInsightUtil.getSparkSubmissionToolWindowView().getJobStatusManager().isApplicationGenerated()) {
String sparkLogs = Joiner.on("").join(sparkJobLog.getLog());
String applicationId = getApplicationIdFromYarnLog(sparkLogs);
if (applicationId != null) {
HDInsightUtil.getSparkSubmissionToolWindowView().setBrowserButtonState(true);
HDInsightUtil.getSparkSubmissionToolWindowView().getJobStatusManager().setApplicationIdGenerated();
HDInsightUtil.getSparkSubmissionToolWindowView().getJobStatusManager().setApplicationId(applicationId);
}
}
int counter = 0;
if (sparkJobLog.getLog().size() > 0) {
for (String line : sparkJobLog.getLog()) {
if (counter >= from_index && !StringHelper.isNullOrWhiteSpace(line)) {
HDInsightUtil.getSparkSubmissionToolWindowView().setInfo(line, true);
}
counter++;
}
}
return sparkJobLog.getTotal();
}
use of com.microsoft.azure.hdinsight.sdk.common.HttpResponse in project azure-tools-for-java by Microsoft.
the class AddNewEmulatorForm method checkAmbariEndpoint.
private boolean checkAmbariEndpoint() {
SparkBatchSubmission.getInstance().setCredentialsProvider("admin", "admin");
HttpResponse httpResponse = null;
try {
httpResponse = SparkBatchSubmission.getInstance().getHttpResponseViaGet(ambariEndpoint);
} catch (Exception e) {
return false;
}
return httpResponse.getCode() == 201 || httpResponse.getCode() == 200;
}
use of com.microsoft.azure.hdinsight.sdk.common.HttpResponse in project azure-tools-for-java by Microsoft.
the class AddNewEmulatorForm method checkLivyEndpoint.
private boolean checkLivyEndpoint() {
SparkBatchSubmission.getInstance().setCredentialsProvider(userName, password);
HttpResponse httpResponse = null;
try {
httpResponse = SparkBatchSubmission.getInstance().getAllBatchesSparkJobs(livyEndpoint + "/batches");
} catch (Exception e) {
return false;
}
return httpResponse.getCode() == 201 || httpResponse.getCode() == 200;
}
Aggregations