Search in sources :

Example 6 with ExecutionEnvironment

use of com.intellij.execution.runners.ExecutionEnvironment in project intellij-community by JetBrains.

the class HotSwapProgressImpl method notifyUser.

private void notifyUser(String title, String message, NotificationType type) {
    NotificationListener notificationListener = null;
    if (SoftReference.dereference(mySessionRef) != null) {
        notificationListener = (notification, event) -> {
            if (event.getEventType() != HyperlinkEvent.EventType.ACTIVATED) {
                return;
            }
            XDebugSession session = SoftReference.dereference(mySessionRef);
            if (session == null) {
                return;
            }
            notification.expire();
            switch(event.getDescription()) {
                case "stop":
                    session.stop();
                    break;
                case "restart":
                    ExecutionEnvironment environment = ((XDebugSessionImpl) session).getExecutionEnvironment();
                    if (environment != null) {
                        ExecutionUtil.restart(environment);
                    }
                    break;
            }
        };
    }
    NOTIFICATION_GROUP.createNotification(title, message, type, notificationListener).setImportant(false).notify(getProject());
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) NotificationListener(com.intellij.notification.NotificationListener) XDebugSessionImpl(com.intellij.xdebugger.impl.XDebugSessionImpl)

Example 7 with ExecutionEnvironment

use of com.intellij.execution.runners.ExecutionEnvironment 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);
    });
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) Arrays(java.util.Arrays) ExecutionException(com.intellij.execution.ExecutionException) Exceptions(rx.exceptions.Exceptions) URISyntaxException(java.net.URISyntaxException) HDInsightUtil(com.microsoft.azure.hdinsight.common.HDInsightUtil) RemoteDebugRunConfiguration(com.microsoft.azure.hdinsight.spark.run.configuration.RemoteDebugRunConfiguration) HashMap(java.util.HashMap) RunProfileState(com.intellij.execution.configurations.RunProfileState) Single(rx.Single) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) Map(java.util.Map) HDInsightBundle(com.microsoft.intellij.hdinsight.messages.HDInsightBundle) Schedulers(rx.schedulers.Schedulers) URI(java.net.URI) SimpleEntry(java.util.AbstractMap.SimpleEntry) IClusterDetail(com.microsoft.azure.hdinsight.sdk.cluster.IClusterDetail) ConfigurationInfoProvider(com.intellij.execution.configurations.ConfigurationInfoProvider) DefaultDebugExecutor(com.intellij.execution.executors.DefaultDebugExecutor) RemoteConnection(com.intellij.execution.configurations.RemoteConnection) RunProfile(com.intellij.execution.configurations.RunProfile) IOException(java.io.IOException) Executor(com.intellij.execution.Executor) Collectors(java.util.stream.Collectors) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) GenericDebuggerRunnerSettings(com.intellij.debugger.impl.GenericDebuggerRunnerSettings) AppInsightsClient(com.microsoft.azuretools.telemetry.AppInsightsClient) CompositeException(rx.exceptions.CompositeException) JSchException(com.jcraft.jsch.JSchException) NotNull(org.jetbrains.annotations.NotNull) com.microsoft.azure.hdinsight.spark.common(com.microsoft.azure.hdinsight.spark.common) GenericDebuggerRunner(com.intellij.debugger.impl.GenericDebuggerRunner) HashMap(java.util.HashMap) CompositeException(rx.exceptions.CompositeException) IOException(java.io.IOException) IClusterDetail(com.microsoft.azure.hdinsight.sdk.cluster.IClusterDetail) ExecutionException(com.intellij.execution.ExecutionException) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) CompositeException(rx.exceptions.CompositeException) JSchException(com.jcraft.jsch.JSchException)

Example 8 with ExecutionEnvironment

use of com.intellij.execution.runners.ExecutionEnvironment in project intellij-community by JetBrains.

the class ToggleAutoTestAction method setSelected.

@Override
public void setSelected(AnActionEvent e, boolean state) {
    Project project = e.getData(CommonDataKeys.PROJECT);
    RunContentDescriptor descriptor = e.getData(LangDataKeys.RUN_CONTENT_DESCRIPTOR);
    ExecutionEnvironment environment = e.getData(LangDataKeys.EXECUTION_ENVIRONMENT);
    if (project != null && descriptor != null && environment != null) {
        getAutoTestManager(project).setAutoTestEnabled(descriptor, environment, state);
    }
}
Also used : Project(com.intellij.openapi.project.Project) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor)

Example 9 with ExecutionEnvironment

use of com.intellij.execution.runners.ExecutionEnvironment in project intellij-community by JetBrains.

the class ExternalSystemBeforeRunTaskProvider method executeTask.

@Override
public boolean executeTask(DataContext context, RunConfiguration configuration, ExecutionEnvironment env, ExternalSystemBeforeRunTask beforeRunTask) {
    final ExternalSystemTaskExecutionSettings executionSettings = beforeRunTask.getTaskExecutionSettings();
    final List<ExternalTaskPojo> tasks = ContainerUtilRt.newArrayList();
    for (String taskName : executionSettings.getTaskNames()) {
        tasks.add(new ExternalTaskPojo(taskName, executionSettings.getExternalProjectPath(), null));
    }
    if (tasks.isEmpty())
        return true;
    ExecutionEnvironment environment = ExternalSystemUtil.createExecutionEnvironment(myProject, mySystemId, executionSettings, DefaultRunExecutor.EXECUTOR_ID);
    if (environment == null)
        return false;
    final ProgramRunner runner = environment.getRunner();
    environment.setExecutionId(env.getExecutionId());
    return RunConfigurationBeforeRunProvider.doRunTask(DefaultRunExecutor.getRunExecutorInstance().getId(), environment, runner);
}
Also used : ExternalTaskPojo(com.intellij.openapi.externalSystem.model.execution.ExternalTaskPojo) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) ProgramRunner(com.intellij.execution.runners.ProgramRunner) ExternalSystemTaskExecutionSettings(com.intellij.openapi.externalSystem.model.execution.ExternalSystemTaskExecutionSettings)

Example 10 with ExecutionEnvironment

use of com.intellij.execution.runners.ExecutionEnvironment in project intellij-community by JetBrains.

the class XDebuggerTree method isUnderRemoteDebug.

public boolean isUnderRemoteDebug() {
    DataContext context = DataManager.getInstance().getDataContext(this);
    ExecutionEnvironment env = LangDataKeys.EXECUTION_ENVIRONMENT.getData(context);
    if (env != null && env.getRunProfile() instanceof RemoteRunProfile) {
        return true;
    }
    return false;
}
Also used : ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) RemoteRunProfile(com.intellij.execution.configurations.RemoteRunProfile)

Aggregations

ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)50 ProcessHandler (com.intellij.execution.process.ProcessHandler)13 ProcessEvent (com.intellij.execution.process.ProcessEvent)12 NotNull (org.jetbrains.annotations.NotNull)12 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)11 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)11 Project (com.intellij.openapi.project.Project)11 Nullable (org.jetbrains.annotations.Nullable)11 ExecutionException (com.intellij.execution.ExecutionException)10 ProgramRunner (com.intellij.execution.runners.ProgramRunner)10 Executor (com.intellij.execution.Executor)8 DefaultRunExecutor (com.intellij.execution.executors.DefaultRunExecutor)8 ExecutionEnvironmentBuilder (com.intellij.execution.runners.ExecutionEnvironmentBuilder)8 Key (com.intellij.openapi.util.Key)8 RunProfile (com.intellij.execution.configurations.RunProfile)7 DefaultDebugExecutor (com.intellij.execution.executors.DefaultDebugExecutor)7 Ref (com.intellij.openapi.util.Ref)7 Module (com.intellij.openapi.module.Module)6 IOException (java.io.IOException)5 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)4