Search in sources :

Example 1 with AttemptWithAppId

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

the class Application method getLastAttemptWithAppId.

public AttemptWithAppId getLastAttemptWithAppId(@NotNull String clusterName) {
    final int attemptTimes = attempts.size();
    Optional<Attempt> lastAttempt = attempts.stream().filter(attempt -> Integer.valueOf(attempt.getAttemptId()) == attemptTimes).findFirst();
    return lastAttempt.isPresent() ? new AttemptWithAppId(clusterName, getId(), lastAttempt.get()) : null;
}
Also used : List(java.util.List) NotNull(com.microsoft.azuretools.azurecommons.helpers.NotNull) Optional(java.util.Optional) IConvertible(com.microsoft.azure.hdinsight.sdk.rest.IConvertible) AttemptWithAppId(com.microsoft.azure.hdinsight.sdk.rest.AttemptWithAppId) JsonIgnoreProperties(com.fasterxml.jackson.annotation.JsonIgnoreProperties) AttemptWithAppId(com.microsoft.azure.hdinsight.sdk.rest.AttemptWithAppId)

Example 2 with AttemptWithAppId

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

the class SparkRestUtil method getSparkTasks.

public static List<Task> getSparkTasks(@NotNull ApplicationKey key, @NotNull int stage, int attemptId) throws IOException, ExecutionException, HDIException {
    AttemptWithAppId attemptWithAppId = getLastAttemptFromLocalCache(key);
    String url = String.format("/%s/%s/stages/%s/%s/taskList", attemptWithAppId.getAppId(), attemptWithAppId.getAttemptId(), stage, attemptId);
    HttpEntity entity = getSparkRestEntity(key.getClusterDetails(), url);
    Optional<List<Task>> tasks = ObjectConvertUtils.convertEntityToList(entity, Task.class);
    return tasks.orElse(RestUtil.getEmptyList(Task.class));
}
Also used : Task(com.microsoft.azure.hdinsight.sdk.rest.spark.task.Task) HttpEntity(org.apache.http.HttpEntity) AttemptWithAppId(com.microsoft.azure.hdinsight.sdk.rest.AttemptWithAppId)

Example 3 with AttemptWithAppId

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

the class SparkRestUtil method getAllExecutorFromApp.

public static List<Executor> getAllExecutorFromApp(@NotNull ApplicationKey key) throws IOException, HDIException, ExecutionException {
    final AttemptWithAppId attemptWithAppId = getLastAttemptFromLocalCache(key);
    final HttpEntity entity = getSparkRestEntity(key.getClusterDetails(), String.format("/%s/%s/executors", attemptWithAppId.getAppId(), attemptWithAppId.getAttemptId()));
    Optional<List<Executor>> executors = ObjectConvertUtils.convertEntityToList(entity, Executor.class);
    return executors.orElse(RestUtil.getEmptyList(Executor.class));
}
Also used : Executor(com.microsoft.azure.hdinsight.sdk.rest.spark.executor.Executor) HttpEntity(org.apache.http.HttpEntity) AttemptWithAppId(com.microsoft.azure.hdinsight.sdk.rest.AttemptWithAppId)

Example 4 with AttemptWithAppId

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

the class SparkRestUtil method getAllStageFromApp.

public static List<Stage> getAllStageFromApp(@NotNull ApplicationKey key) throws IOException, HDIException, ExecutionException {
    final AttemptWithAppId attemptWithAppId = getLastAttemptFromLocalCache(key);
    final HttpEntity entity = getSparkRestEntity(key.getClusterDetails(), String.format("/%s/%s/stages", attemptWithAppId.getAppId(), attemptWithAppId.getAttemptId()));
    final Optional<List<Stage>> stages = ObjectConvertUtils.convertEntityToList(entity, Stage.class);
    return stages.orElse(RestUtil.getEmptyList(Stage.class));
}
Also used : HttpEntity(org.apache.http.HttpEntity) AttemptWithAppId(com.microsoft.azure.hdinsight.sdk.rest.AttemptWithAppId) Stage(com.microsoft.azure.hdinsight.sdk.rest.spark.stage.Stage)

Aggregations

AttemptWithAppId (com.microsoft.azure.hdinsight.sdk.rest.AttemptWithAppId)4 HttpEntity (org.apache.http.HttpEntity)3 JsonIgnoreProperties (com.fasterxml.jackson.annotation.JsonIgnoreProperties)1 IConvertible (com.microsoft.azure.hdinsight.sdk.rest.IConvertible)1 Executor (com.microsoft.azure.hdinsight.sdk.rest.spark.executor.Executor)1 Stage (com.microsoft.azure.hdinsight.sdk.rest.spark.stage.Stage)1 Task (com.microsoft.azure.hdinsight.sdk.rest.spark.task.Task)1 NotNull (com.microsoft.azuretools.azurecommons.helpers.NotNull)1 List (java.util.List)1 Optional (java.util.Optional)1