Search in sources :

Example 1 with NotSupportExecption

use of com.microsoft.azure.hdinsight.sdk.common.NotSupportExecption in project azure-tools-for-java by Microsoft.

the class SparkSubmitModel method buildArtifactObservable.

public Single<Artifact> buildArtifactObservable(@NotNull String artifactName) {
    Optional<JobStatusManager> jsmOpt = Optional.ofNullable(HDInsightUtil.getJobStatusManager(project));
    return Single.fromEmitter(em -> {
        jsmOpt.ifPresent((jsm) -> jsm.setJobRunningState(true));
        postEventAction();
        if (isLocalArtifact()) {
            em.onError(new NotSupportExecption());
            return;
        }
        final Artifact artifact = artifactHashMap.get(artifactName);
        final List<Artifact> artifacts = Collections.singletonList(artifact);
        ArtifactsWorkspaceSettings.getInstance(project).setArtifactsToBuild(artifacts);
        ApplicationManager.getApplication().invokeAndWait(() -> {
            final CompileScope scope = ArtifactCompileScope.createArtifactsScope(project, artifacts, true);
            CompilerManager.getInstance(project).make(scope, (aborted, errors, warnings, compileContext) -> {
                if (aborted || errors != 0) {
                    showCompilerErrorMessage(compileContext);
                    jsmOpt.ifPresent((jsm) -> jsm.setJobRunningState(false));
                    String errorMessage = StringUtils.join(compileContext.getMessages(CompilerMessageCategory.ERROR), "\\n");
                    postEventProperty.put("IsSubmitSucceed", "false");
                    postEventProperty.put("SubmitFailedReason", errorMessage.substring(0, 50));
                    AppInsightsClient.create(HDInsightBundle.message("SparkProjectDebugCompileFailed"), null, postEventProperty);
                    em.onError(new CompilationException(errorMessage));
                } else {
                    postEventProperty.put("IsSubmitSucceed", "true");
                    postEventProperty.put("SubmitFailedReason", "CompileSuccess");
                    AppInsightsClient.create(HDInsightBundle.message("SparkProjectDebugCompileSuccess"), null, postEventProperty);
                    HDInsightUtil.showInfoOnSubmissionMessageWindow(project, String.format("Info : Build %s successfully.", artifact.getOutputFile()));
                    em.onSuccess(artifact);
                }
            });
        }, ModalityState.defaultModalityState());
    });
}
Also used : JobStatusManager(com.microsoft.azure.hdinsight.common.JobStatusManager) ArtifactCompileScope(com.intellij.packaging.impl.compiler.ArtifactCompileScope) NotSupportExecption(com.microsoft.azure.hdinsight.sdk.common.NotSupportExecption) Artifact(com.intellij.packaging.artifacts.Artifact)

Aggregations

Artifact (com.intellij.packaging.artifacts.Artifact)1 ArtifactCompileScope (com.intellij.packaging.impl.compiler.ArtifactCompileScope)1 JobStatusManager (com.microsoft.azure.hdinsight.common.JobStatusManager)1 NotSupportExecption (com.microsoft.azure.hdinsight.sdk.common.NotSupportExecption)1