Search in sources :

Example 16 with IClusterDetail

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

the class SparkBatchJobDebuggerRunner method getSparkJobUrl.

private String getSparkJobUrl(@NotNull final SparkSubmitModel submitModel) throws ExecutionException, IOException {
    final String clusterName = submitModel.getSubmissionParameter().getClusterName();
    final IClusterDetail clusterDetail = ClusterManagerEx.getInstance().getClusterDetailByName(clusterName).orElseThrow(() -> new ExecutionException("No cluster name matched selection: " + clusterName));
    final String sparkJobUrl = clusterDetail instanceof LivyCluster ? ((LivyCluster) clusterDetail).getLivyBatchUrl() : null;
    if (sparkJobUrl == null) {
        throw new IOException("Can't get livy connection URL. Cluster: " + clusterName);
    }
    return sparkJobUrl;
}
Also used : LivyCluster(com.microsoft.azure.hdinsight.sdk.cluster.LivyCluster) IOException(java.io.IOException) ExecutionException(com.intellij.execution.ExecutionException) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) IClusterDetail(com.microsoft.azure.hdinsight.sdk.cluster.IClusterDetail)

Example 17 with IClusterDetail

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

the class HDInsightHelperImpl method openJobViewEditor.

public void openJobViewEditor(final Object projectObject, final String uuid) {
    final IClusterDetail clusterDetail = JobViewManager.getCluster(uuid);
    final Project project = (Project) projectObject;
    final VirtualFile openedFile = getOpenedItem(project);
    // TODO: Fix the issue of clusterDetail may be null
    if (openedFile == null || isNeedReopen(openedFile, clusterDetail)) {
        openItem(project, clusterDetail, uuid, openedFile);
    } else {
        openItem(project, openedFile, null);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) Project(com.intellij.openapi.project.Project) IClusterDetail(com.microsoft.azure.hdinsight.sdk.cluster.IClusterDetail)

Example 18 with IClusterDetail

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

the class SparkBatchJobRunner method buildSparkBatchJob.

@Override
@NotNull
public Observable<ISparkBatchJob> buildSparkBatchJob(@NotNull SparkSubmitModel submitModel) {
    return Observable.fromCallable(() -> {
        final String clusterName = submitModel.getSubmissionParameter().getClusterName();
        updateCurrentBackgroundableTaskIndicator(progressIndicator -> {
            progressIndicator.setFraction(0.2f);
            progressIndicator.setText("Get Spark cluster [" + clusterName + "] information from subscriptions");
        });
        final IClusterDetail clusterDetail = ClusterManagerEx.getInstance().getClusterDetailByName(clusterName).orElseThrow(() -> new ExecutionException("Can't find cluster named " + clusterName));
        updateCurrentBackgroundableTaskIndicator(progressIndicator -> {
            progressIndicator.setFraction(0.7f);
            progressIndicator.setText("Get the storage configuration for artifacts deployment");
        });
        final Deployable jobDeploy = SparkBatchJobDeployFactory.getInstance().buildSparkBatchJobDeploy(submitModel, clusterDetail);
        final SparkSubmissionParameter submissionParameter = updateStorageConfigForSubmissionParameter(submitModel);
        updateCurrentBackgroundableTaskIndicator(progressIndicator -> {
            progressIndicator.setFraction(1.0f);
            progressIndicator.setText("All checks are passed.");
        });
        return new SparkBatchJob(clusterDetail, submissionParameter, getClusterSubmission(clusterDetail), jobDeploy);
    });
}
Also used : ExecutionException(com.intellij.execution.ExecutionException) IClusterDetail(com.microsoft.azure.hdinsight.sdk.cluster.IClusterDetail) NotNull(com.microsoft.azuretools.azurecommons.helpers.NotNull)

Example 19 with IClusterDetail

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

the class HDInsightHelperImpl method openJobViewEditor.

public void openJobViewEditor(Object projectObject, @NotNull String clusterName) {
    try {
        loadHDInsightPlugin();
    } catch (BundleException bundleException) {
        Activator.getDefault().log("Error loading plugin " + HDINSIHGT_BUNDLE_ID, bundleException);
    }
    IClusterDetail clusterDetail = JobViewManager.getCluster(clusterName);
    IWorkbench workbench = PlatformUI.getWorkbench();
    IEditorDescriptor editorDescriptor = workbench.getEditorRegistry().findEditor("com.microsoft.azure.hdinsight.jobview");
    try {
        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        IEditorPart newEditor = page.openEditor(new JobViewInput(clusterDetail), editorDescriptor.getId());
    } catch (PartInitException e2) {
        Activator.getDefault().log("Error opening " + clusterDetail.getName(), e2);
    }
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IEditorDescriptor(org.eclipse.ui.IEditorDescriptor) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) BundleException(org.osgi.framework.BundleException) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException) IClusterDetail(com.microsoft.azure.hdinsight.sdk.cluster.IClusterDetail) JobViewInput(com.microsoft.azuretools.azureexplorer.editors.JobViewInput)

Example 20 with IClusterDetail

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

the class JobUtils method deployArtifact.

public static Single<SimpleImmutableEntry<IClusterDetail, String>> deployArtifact(@NotNull String artifactLocalPath, @NotNull String clusterName, @NotNull Observer<SparkLogLine> logSubject) {
    return Single.create(ob -> {
        try {
            final IClusterDetail clusterDetail = ClusterManagerEx.getInstance().getClusterDetailByName(clusterName).orElseThrow(() -> new HDIException("No cluster name matched selection: " + clusterName));
            final String jobArtifactUri = JobUtils.uploadFileToCluster(clusterDetail, artifactLocalPath, logSubject);
            ob.onSuccess(new SimpleImmutableEntry<>(clusterDetail, jobArtifactUri));
        } catch (final Exception e) {
            ob.onError(e);
        }
    });
}
Also used : HDIException(com.microsoft.azure.hdinsight.sdk.common.HDIException) IClusterDetail(com.microsoft.azure.hdinsight.sdk.cluster.IClusterDetail) URISyntaxException(java.net.URISyntaxException) AuthenticationException(com.microsoft.azure.hdinsight.sdk.common.AuthenticationException) FailingHttpStatusCodeException(com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException) UnknownServiceException(java.net.UnknownServiceException) HDIException(com.microsoft.azure.hdinsight.sdk.common.HDIException) ExecutionException(java.util.concurrent.ExecutionException) AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException)

Aggregations

IClusterDetail (com.microsoft.azure.hdinsight.sdk.cluster.IClusterDetail)22 IOException (java.io.IOException)8 ExecutionException (com.intellij.execution.ExecutionException)6 HDIException (com.microsoft.azure.hdinsight.sdk.common.HDIException)5 NotNull (com.microsoft.azuretools.azurecommons.helpers.NotNull)5 URISyntaxException (java.net.URISyntaxException)4 Collectors (java.util.stream.Collectors)4 UncheckedExecutionException (com.google.common.util.concurrent.UncheckedExecutionException)2 RemoteConnection (com.intellij.execution.configurations.RemoteConnection)2 Project (com.intellij.openapi.project.Project)2 JSchException (com.jcraft.jsch.JSchException)2 ClusterDetail (com.microsoft.azure.hdinsight.sdk.cluster.ClusterDetail)2 AuthenticationException (com.microsoft.azure.hdinsight.sdk.common.AuthenticationException)2 ObjectConvertUtils (com.microsoft.azure.hdinsight.sdk.rest.ObjectConvertUtils)2 App (com.microsoft.azure.hdinsight.sdk.rest.yarn.rm.App)2 SparkSubmissionParameter (com.microsoft.azure.hdinsight.spark.common.SparkSubmissionParameter)2 File (java.io.File)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2