Search in sources :

Example 6 with HDIException

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

the class SparkSubmitModel method tryToCreateBatchSparkDebugJob.

public SparkBatchRemoteDebugJob tryToCreateBatchSparkDebugJob(@NotNull final IClusterDetail selectedClusterDetail) throws HDIException, IOException {
    SparkBatchSubmission.getInstance().setCredentialsProvider(selectedClusterDetail.getHttpUserName(), selectedClusterDetail.getHttpPassword());
    try {
        SparkBatchRemoteDebugJob debugJob = SparkBatchRemoteDebugJob.factory(SparkSubmitHelper.getLivyConnectionURL(selectedClusterDetail), submissionParameter, SparkBatchSubmission.getInstance());
        debugJob.createBatchSparkJobWithDriverDebugging();
        return debugJob;
    } catch (URISyntaxException ex) {
        throw new HDIException("Bad Livy Connection URL " + SparkSubmitHelper.getLivyConnectionURL(selectedClusterDetail), ex);
    } catch (IOException ex) {
        HDInsightUtil.showErrorMessageOnSubmissionMessageWindow(project, String.format("Error : Failed to submit to spark cluster. error message : %s.", ex.getMessage()));
        throw ex;
    }
}
Also used : URISyntaxException(java.net.URISyntaxException) HDIException(com.microsoft.azure.hdinsight.sdk.common.HDIException) IOException(java.io.IOException)

Example 7 with HDIException

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

the class YarnHistoryTask method call.

@Override
public String call() throws Exception {
    WEB_CLIENT.setCredentialsProvider(credentialsProvider);
    HtmlPage htmlPage = WEB_CLIENT.getPage(path);
    // parse pre tag from html response
    // there's only one 'pre' in response
    DomNodeList<DomElement> preTagElements = htmlPage.getElementsByTagName("pre");
    if (preTagElements.size() == 0) {
        throw new HDIException("No logs here or logs not available");
    } else {
        return preTagElements.get(0).asText();
    }
}
Also used : DomElement(com.gargoylesoftware.htmlunit.html.DomElement) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) HDIException(com.microsoft.azure.hdinsight.sdk.common.HDIException)

Example 8 with HDIException

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

the class ClusterManager method getClusterDetails.

private List<IClusterDetail> getClusterDetails(List<SubscriptionDetail> subscriptions, final Object project) throws AggregatedException {
    ExecutorService taskExecutor = Executors.newFixedThreadPool(MAX_CONCURRENT);
    final List<IClusterDetail> cachedClusterList = new ArrayList<>();
    final List<Exception> aggregateExceptions = new ArrayList<>();
    for (SubscriptionDetail subscription : subscriptions) {
        taskExecutor.execute(new CommonRunnable<SubscriptionDetail, Exception>(subscription) {

            @Override
            public void runSpecificParameter(SubscriptionDetail parameter) throws IOException, HDIException, AzureCmdException {
                IClusterOperation clusterOperation = new ClusterOperationImpl(project);
                List<ClusterRawInfo> clusterRawInfoList = clusterOperation.listCluster(parameter);
                if (clusterRawInfoList != null) {
                    for (ClusterRawInfo item : clusterRawInfoList) {
                        IClusterDetail tempClusterDetail = new ClusterDetail(parameter, item);
                        synchronized (ClusterManager.class) {
                            cachedClusterList.add(tempClusterDetail);
                        }
                    }
                }
            }

            @Override
            public void exceptionHandle(Exception e) {
                synchronized (aggregateExceptions) {
                    aggregateExceptions.add(e);
                }
            }
        });
    }
    taskExecutor.shutdown();
    try {
        taskExecutor.awaitTermination(TIME_OUT, TimeUnit.SECONDS);
    } catch (InterruptedException exception) {
        aggregateExceptions.add(exception);
    }
    if (aggregateExceptions.size() > 0) {
        throw new AggregatedException(aggregateExceptions);
    }
    return cachedClusterList;
}
Also used : ArrayList(java.util.ArrayList) AggregatedException(com.microsoft.azure.hdinsight.sdk.common.AggregatedException) IOException(java.io.IOException) HDIException(com.microsoft.azure.hdinsight.sdk.common.HDIException) AggregatedException(com.microsoft.azure.hdinsight.sdk.common.AggregatedException) AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException) HDIException(com.microsoft.azure.hdinsight.sdk.common.HDIException) IOException(java.io.IOException) AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException) ExecutorService(java.util.concurrent.ExecutorService) SubscriptionDetail(com.microsoft.azuretools.authmanage.models.SubscriptionDetail) List(java.util.List) ArrayList(java.util.ArrayList)

Example 9 with HDIException

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

the class AddHDInsightAdditionalClusterImpl method getMessageByAmbari.

private static String getMessageByAmbari(String clusterName, String userName, String passwd) throws HDIException {
    String linuxClusterConfigureFileUrl = String.format(clusterConfigureFileUrl, clusterName, clusterName);
    CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
    credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(userName.trim(), passwd));
    CloseableHttpClient httpClient = HttpClients.custom().setDefaultCredentialsProvider(credentialsProvider).build();
    CloseableHttpResponse response = null;
    int responseCode = -1;
    try {
        response = tryGetHttpResponse(httpClient, linuxClusterConfigureFileUrl);
    } catch (UnknownHostException e1) {
        throw new HDIException("Invalid Cluster Name");
    } catch (Exception e3) {
        throw new HDIException("Something wrong with the cluster! Please try again later");
    }
    responseCode = response.getStatusLine().getStatusCode();
    if (responseCode == 200) {
        try {
            return StreamUtil.getResultFromHttpResponse(response).getMessage();
        } catch (IOException e) {
            throw new HDIException("Not support cluster");
        }
    } else if (responseCode == 401 || responseCode == 403) {
        throw new HDIException("Invalid Cluster Name or Password");
    } else {
        throw new HDIException("Something wrong with the cluster! Please try again later");
    }
}
Also used : CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) BasicCredentialsProvider(org.apache.http.impl.client.BasicCredentialsProvider) UnknownHostException(java.net.UnknownHostException) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) BasicCredentialsProvider(org.apache.http.impl.client.BasicCredentialsProvider) CredentialsProvider(org.apache.http.client.CredentialsProvider) HDIException(com.microsoft.azure.hdinsight.sdk.common.HDIException) IOException(java.io.IOException) HDIException(com.microsoft.azure.hdinsight.sdk.common.HDIException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException) UsernamePasswordCredentials(org.apache.http.auth.UsernamePasswordCredentials)

Example 10 with HDIException

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

the class SparkSubmitModel method deployArtifactObservable.

public Single<IClusterDetail> deployArtifactObservable(Artifact artifact, IClusterDetail clusterDetail) {
    return Single.create(em -> {
        IClusterDetail selectedClusterDetail = getClusterConfiguration(clusterDetail, true);
        if (selectedClusterDetail == null) {
            String errorMessage = "Selected Cluster can not found. Please login in first in HDInsight Explorer and try submit job again";
            HDInsightUtil.showErrorMessageOnSubmissionMessageWindow(project, errorMessage);
            em.onError(new HDIException(errorMessage));
            return;
        }
        try {
            uploadFileToCluster(selectedClusterDetail, artifact.getName());
            em.onSuccess(selectedClusterDetail);
        } catch (Exception exception) {
            showFailedSubmitErrorMessage(exception);
            em.onError(exception);
        }
    });
}
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) HDIException(com.microsoft.azure.hdinsight.sdk.common.HDIException) IOException(java.io.IOException)

Aggregations

HDIException (com.microsoft.azure.hdinsight.sdk.common.HDIException)10 IOException (java.io.IOException)4 AzureCmdException (com.microsoft.azuretools.azurecommons.helpers.AzureCmdException)3 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)3 HttpGet (org.apache.http.client.methods.HttpGet)3 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)3 URISyntaxException (java.net.URISyntaxException)2 ArrayList (java.util.ArrayList)2 UsernamePasswordCredentials (org.apache.http.auth.UsernamePasswordCredentials)2 DomElement (com.gargoylesoftware.htmlunit.html.DomElement)1 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)1 ADLException (com.microsoft.azure.datalake.store.ADLException)1 ADLStoreClient (com.microsoft.azure.datalake.store.ADLStoreClient)1 HttpResponseWithoutHeader (com.microsoft.azure.hdinsight.common.HttpResponseWithoutHeader)1 IClusterDetail (com.microsoft.azure.hdinsight.sdk.cluster.IClusterDetail)1 AggregatedException (com.microsoft.azure.hdinsight.sdk.common.AggregatedException)1 AuthenticationException (com.microsoft.azure.hdinsight.sdk.common.AuthenticationException)1 HDStorageAccount (com.microsoft.azure.hdinsight.sdk.storage.HDStorageAccount)1 SubscriptionDetail (com.microsoft.azuretools.authmanage.models.SubscriptionDetail)1 AzureManager (com.microsoft.azuretools.sdkmanage.AzureManager)1