Skip to content

Commit e0a1d4d

Browse files
committed
Fix Spark remote debug regression caused by executor's job reference not set
1 parent f9c3522 commit e0a1d4d

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/hdinsight/spark/run/SparkBatchJobDebuggerRunner.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import com.intellij.execution.runners.ExecutionEnvironmentBuilder;
3636
import com.intellij.execution.ui.ConsoleViewContentType;
3737
import com.intellij.execution.ui.RunContentDescriptor;
38+
import com.intellij.openapi.application.ModalityState;
3839
import com.intellij.openapi.project.Project;
3940
import com.intellij.openapi.util.Key;
4041
import com.microsoft.azure.hdinsight.common.ClusterManagerEx;
@@ -55,7 +56,6 @@
5556
import org.jetbrains.concurrency.AsyncPromise;
5657
import org.jetbrains.concurrency.Promise;
5758
import rx.Observable;
58-
import rx.Observer;
5959
import rx.Subscription;
6060
import rx.schedulers.Schedulers;
6161
import rx.subjects.PublishSubject;
@@ -232,6 +232,18 @@ protected void execute(ExecutionEnvironment environment, Callback callback, RunP
232232
jdbReadyEvent.getRemoteHost().orElse("unknown"),
233233
jdbReadyEvent.isDriver());
234234

235+
final RunProfile runProfile = forkEnv.getRunProfile();
236+
if (!(runProfile instanceof LivySparkBatchJobRunConfiguration)) {
237+
ctrlSubject.onError(new UnsupportedOperationException(
238+
"Only supports LivySparkBatchJobRunConfiguration type, but got type"
239+
+ runProfile.getClass().getCanonicalName()));
240+
241+
return;
242+
}
243+
244+
// Reuse the driver's Spark batch job
245+
((LivySparkBatchJobRunConfiguration) runProfile).setSparkRemoteBatch(sparkDebugBatch);
246+
235247
SparkBatchRemoteDebugState forkState = jdbReadyEvent.isDriver() ?
236248
submissionState :
237249
(SparkBatchRemoteDebugState) forkEnv.getState();
@@ -325,7 +337,9 @@ public Promise<RunContentDescriptor> executeAsync(@NotNull RunProfileState state
325337

326338
return jobDriverEnvReady
327339
.then(forkEnv -> Observable.fromCallable(() -> doExecute(state, forkEnv))
328-
.subscribeOn(schedulers.dispatchUIThread()).toBlocking().singleOrDefault(null))
340+
.subscribeOn(schedulers.dispatchUIThread(ModalityState.defaultModalityState()))
341+
.toBlocking()
342+
.singleOrDefault(null))
329343
.then(descriptor -> {
330344
// Borrow BaseProgramRunner.postProcess() codes since it's only package public accessible.
331345
if (descriptor != null) {

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/hdinsight/spark/run/configuration/LivySparkBatchJobRunConfiguration.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,10 @@ private void checkLocalRunConfigurationBeforeRun() throws RuntimeConfigurationEx
336336
}
337337
}
338338

339+
public void setSparkRemoteBatch(ISparkBatchJob sparkRemoteBatch) {
340+
this.sparkRemoteBatch = sparkRemoteBatch;
341+
}
342+
339343
public void setRunMode(@NotNull RunMode mode) {
340344
this.mode = mode;
341345
}

0 commit comments

Comments
 (0)