Search in sources :

Example 1 with ArcadiaWorkSpace

use of com.microsoft.azure.projectarcadia.common.ArcadiaWorkSpace in project azure-tools-for-java by Microsoft.

the class SparkBatchArcadiaSubmission method getJobDetailsWebUrl.

@NotNull
public URL getJobDetailsWebUrl(int livyId) {
    Matcher matcher = LIVY_URL_NO_WORKSPACE_IN_HOSTNAME_PATTERN.matcher(getLivyUri().toString());
    if (matcher.matches()) {
        try {
            ArcadiaWorkSpace workSpace = ArcadiaSparkComputeManager.getInstance().findWorkspace(getTenantId(), getWorkspaceName()).toBlocking().first();
            // Currently we just concatenate the string and show it as the Spark job detail page URL.
            // We don't check if the URL is valid or not because we have never met any exceptions when clicking the
            // link during test. If there are errors reported by user that URL is invalid in the future, we will
            // add more validation code here at that time.
            URI rootUri = URI.create(this.webUrl == null ? SYNAPSE_STUDIO_WEB_ROOT_URL : this.webUrl).resolve("/");
            return new URIBuilder(rootUri).setPath("/monitoring/sparkapplication/" + jobName).setParameters(Arrays.asList(new BasicNameValuePair("workspace", workSpace.getId()), new BasicNameValuePair("livyId", String.valueOf(livyId)), new BasicNameValuePair("sparkPoolName", matcher.group("pool")))).build().toURL();
        } catch (NoSuchElementException ex) {
            log().warn(String.format("Can't find workspace %s under tenant %s", getWorkspaceName(), getTenantId()), ex);
        } catch (MalformedURLException | URISyntaxException ex) {
            log().warn("Build Spark job detail web URL failed with error " + ex.getMessage(), ex);
            throw new IllegalArgumentException("Bad Spark job detail URL", ex);
        }
    }
    throw new IllegalArgumentException("Bad Synapse Livy URL: " + getLivyUri());
}
Also used : MalformedURLException(java.net.MalformedURLException) Matcher(java.util.regex.Matcher) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) URISyntaxException(java.net.URISyntaxException) ArcadiaWorkSpace(com.microsoft.azure.projectarcadia.common.ArcadiaWorkSpace) URI(java.net.URI) NoSuchElementException(java.util.NoSuchElementException) URIBuilder(org.apache.http.client.utils.URIBuilder) NotNull(com.microsoft.azuretools.azurecommons.helpers.NotNull)

Aggregations

ArcadiaWorkSpace (com.microsoft.azure.projectarcadia.common.ArcadiaWorkSpace)1 NotNull (com.microsoft.azuretools.azurecommons.helpers.NotNull)1 MalformedURLException (java.net.MalformedURLException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 NoSuchElementException (java.util.NoSuchElementException)1 Matcher (java.util.regex.Matcher)1 URIBuilder (org.apache.http.client.utils.URIBuilder)1 BasicNameValuePair (org.apache.http.message.BasicNameValuePair)1