in PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-hdinsight-lib/src/main/java/com/microsoft/azure/hdinsight/spark/run/configuration/LivySparkBatchJobRunConfiguration.java [378:459]
public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment executionEnvironment)
throws ExecutionException {
Operation operation = executionEnvironment.getUserData(TelemetryKeys.OPERATION);
final String debugTarget = executionEnvironment.getUserData(SparkBatchJobDebuggerRunner.DEBUG_TARGET_KEY);
final boolean isExecutor = StringUtils.equals(debugTarget, SparkBatchJobDebuggerRunner.DEBUG_EXECUTOR);
RunProfileStateWithAppInsightsEvent state = null;
List<Artifact> ArtifactWithOutputPaths = ApplicationHelpersKt.runInReadAction(()->{
return ArtifactUtil.getArtifactWithOutputPaths(getProject());
});
final Artifact selectedArtifact = ArtifactWithOutputPaths.stream()
.filter(artifact -> artifact.getName().equals(getSubmitModel().getArtifactName()))
.findFirst()
.orElse(null);
if (executor instanceof SparkBatchJobDebugExecutor) {
final ISparkBatchJob remoteDebugBatch = sparkRemoteBatch;
if (!(remoteDebugBatch instanceof SparkBatchRemoteDebugJob)) {
throw new ExecutionException("Spark Batch Job is not prepared for " + executor.getId());
}
if (isExecutor) {
setRunMode(RunMode.REMOTE_DEBUG_EXECUTOR);
state = new SparkBatchRemoteDebugExecutorState(getModel().getSubmitModel(),
operation,
remoteDebugBatch);
} else {
if (selectedArtifact != null) {
BuildArtifactsBeforeRunTaskProvider.setBuildArtifactBeforeRun(getProject(), this, selectedArtifact);
}
setRunMode(RunMode.REMOTE);
state = new SparkBatchRemoteDebugState(getModel().getSubmitModel(), operation, sparkRemoteBatch);
}
} else if (executor instanceof SparkBatchJobRunExecutor) {
final ISparkBatchJob remoteBatch = sparkRemoteBatch;
if (remoteBatch == null) {
throw new ExecutionException("Spark Batch Job is not prepared for " + executor.getId());
}
if (selectedArtifact != null) {
BuildArtifactsBeforeRunTaskProvider.setBuildArtifactBeforeRun(getProject(), this, selectedArtifact);
}
setRunMode(RunMode.REMOTE);
state = new SparkBatchRemoteRunState(getModel().getSubmitModel(), operation, remoteBatch);
} else if (executor instanceof DefaultDebugExecutor) {
setRunMode(RunMode.LOCAL);
if (operation == null) {
operation = TelemetryManager.createOperation(TelemetryConstants.HDINSIGHT,
TelemetryConstants.DEBUG_LOCAL_SPARK_JOB);
operation.start();
}
state = new SparkBatchLocalDebugState(getProject(), getModel().getLocalRunConfigurableModel(), operation);
} else if (executor instanceof DefaultRunExecutor) {
setRunMode(RunMode.LOCAL);
if (operation == null) {
operation = TelemetryManager.createOperation(TelemetryConstants.HDINSIGHT,
TelemetryConstants.RUN_LOCAL_SPARK_JOB);
operation.start();
}
state = new SparkBatchLocalRunState(getProject(), getModel().getLocalRunConfigurableModel(), operation);
}
if (state != null) {
final Map<String, String> props = getActionProperties().entrySet().stream().collect(Collectors.toMap(
(Map.Entry<Object, Object> entry) -> entry.getKey() == null ? null : entry.getKey().toString(),
(Map.Entry<Object, Object> entry) -> entry.getValue() == null ? "" : entry.getValue().toString()));
final String configurationId =
Optional.ofNullable(executionEnvironment.getRunnerAndConfigurationSettings())
.map(settings -> settings.getType().getId())
.orElse("");
props.put("configurationId", configurationId);
state.createAppInsightEvent(executor, props);
EventUtil.logEvent(EventType.info, operation, props);
// Clear the action properties
getActionProperties().clear();
}
return state;
}