Skip to content

Commit 3e7d0de

Browse files
committed
Put the auth type probing into background when linking a cluster
1 parent 532191d commit 3e7d0de

File tree

1 file changed

+19
-8
lines changed
  • PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/hdinsight/serverexplore/ui

1 file changed

+19
-8
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/hdinsight/serverexplore/ui/AddNewClusterForm.java

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
import com.intellij.ui.SimpleListCellRenderer;
3838
import org.apache.commons.lang3.StringUtils;
3939
import org.joda.time.DateTime;
40+
import rx.Observable;
41+
import rx.schedulers.Schedulers;
4042

4143
import com.microsoft.azure.hdinsight.common.ClusterManagerEx;
4244
import com.microsoft.azure.hdinsight.common.mvc.SettableControl;
@@ -64,10 +66,12 @@
6466
import java.awt.event.ActionEvent;
6567
import java.awt.event.FocusAdapter;
6668
import java.awt.event.FocusEvent;
67-
import java.io.IOException;
6869
import java.net.URI;
6970
import java.util.Arrays;
7071

72+
import static com.intellij.execution.ui.ConsoleViewContentType.LOG_DEBUG_OUTPUT;
73+
import static java.lang.String.format;
74+
7175
public class AddNewClusterForm extends DialogWrapper implements SettableControl<AddNewClusterModel> {
7276
private JPanel wholePanel;
7377
private JPanel clusterInfoPanel;
@@ -317,13 +321,20 @@ public void focusLost(FocusEvent e) {
317321
return;
318322
}
319323

320-
try {
321-
AuthType authType = SparkBatchSubmission.getInstance().probeAuthType(
322-
getClusterConnectionUrl(clusterNameOrUrl.trim()));
323-
324-
authComboBox.setSelectedItem(authType);
325-
} catch (IOException ignored) {
326-
}
324+
Observable.fromCallable(() -> SparkBatchSubmission.getInstance().probeAuthType(
325+
getClusterConnectionUrl(clusterNameOrUrl.trim())))
326+
.subscribeOn(Schedulers.io())
327+
.subscribe(
328+
authType -> {
329+
printLogLine(LOG_DEBUG_OUTPUT,
330+
format("The cluster %s authentication type is %s",
331+
clusterNameOrUrl, authType));
332+
333+
authComboBox.getModel().setSelectedItem(authType);
334+
},
335+
err -> printLogLine(LOG_DEBUG_OUTPUT,
336+
format("Can't probe cluster %s authentication type with error %s",
337+
clusterNameOrUrl, err.getMessage())));
327338
}
328339
});
329340
}

0 commit comments

Comments
 (0)