Package org.apache.ambari.server.actionmanager

Examples of org.apache.ambari.server.actionmanager.HostRoleStatus


    int failedTaskCount = 0;
    int abortedTaskCount = 0;
    int timedOutTaskCount = 0;

    for (HostRoleCommand hostRoleCommand : commands) {
      HostRoleStatus status = hostRoleCommand.getStatus();
      if (status.isCompletedState()) {
        completedTaskCount++;

        switch (status) {
          case ABORTED:
            abortedTaskCount++;
            break;
          case FAILED:
            failedTaskCount++;
            break;
          case TIMEDOUT:
            timedOutTaskCount++;
            break;
        }
      } else if (status.equals(HostRoleStatus.QUEUED)) {
        queuedTaskCount++;
      } else if (status.equals(HostRoleStatus.PENDING)) {
        pendingTaskCount++;
      }
    }

    int inProgressTaskCount = taskCount - completedTaskCount - queuedTaskCount - pendingTaskCount;

    // determine request status
    HostRoleStatus requestStatus = failedTaskCount > 0 ? HostRoleStatus.FAILED :
        abortedTaskCount > 0 ? HostRoleStatus.ABORTED :
            timedOutTaskCount > 0 ? HostRoleStatus.TIMEDOUT :
                inProgressTaskCount > 0 ? HostRoleStatus.IN_PROGRESS :
                    completedTaskCount == taskCount ? HostRoleStatus.COMPLETED :
                        HostRoleStatus.PENDING;
    double progressPercent =
        ((queuedTaskCount * 0.09 + inProgressTaskCount * 0.35 + completedTaskCount) / (double) taskCount) * 100.0;

    setResourceProperty(resource, REQUEST_STATUS_PROPERTY_ID, requestStatus.toString(), requestedPropertyIds);
    setResourceProperty(resource, REQUEST_TASK_CNT_ID, taskCount, requestedPropertyIds);
    setResourceProperty(resource, REQUEST_FAILED_TASK_CNT_ID, failedTaskCount, requestedPropertyIds);
    setResourceProperty(resource, REQUEST_ABORTED_TASK_CNT_ID, abortedTaskCount, requestedPropertyIds);
    setResourceProperty(resource, REQUEST_TIMED_OUT_TASK_CNT_ID, timedOutTaskCount, requestedPropertyIds);
    setResourceProperty(resource, REQUEST_QUEUED_TASK_CNT_ID, queuedTaskCount, requestedPropertyIds);
View Full Code Here


    int failedTaskCount = 0;
    int abortedTaskCount = 0;
    int timedOutTaskCount = 0;

    for (HostRoleCommand hostRoleCommand : commands) {
      HostRoleStatus status = hostRoleCommand.getStatus();
      if (status.isCompletedState()) {
        completedTaskCount++;

        switch (status) {
          case ABORTED:
            abortedTaskCount++;
            break;
          case FAILED:
            failedTaskCount++;
            break;
          case TIMEDOUT:
            timedOutTaskCount++;
            break;
        }
      } else if (status.equals(HostRoleStatus.QUEUED)) {
        queuedTaskCount++;
      } else if (status.equals(HostRoleStatus.PENDING)) {
        pendingTaskCount++;
      }
    }

    int inProgressTaskCount = taskCount - completedTaskCount - queuedTaskCount - pendingTaskCount;

    // determine request status
    HostRoleStatus requestStatus = failedTaskCount > 0 ? HostRoleStatus.FAILED :
        abortedTaskCount > 0 ? HostRoleStatus.ABORTED :
            timedOutTaskCount > 0 ? HostRoleStatus.TIMEDOUT :
                inProgressTaskCount > 0 ? HostRoleStatus.IN_PROGRESS :
                    completedTaskCount == taskCount ? HostRoleStatus.COMPLETED :
                        HostRoleStatus.PENDING;
    double progressPercent =
        ((queuedTaskCount * 0.09 + inProgressTaskCount * 0.35 + completedTaskCount) / (double) taskCount) * 100.0;

    setResourceProperty(resource, REQUEST_STATUS_PROPERTY_ID, requestStatus.toString(), requestedPropertyIds);
    setResourceProperty(resource, REQUEST_TASK_CNT_ID, taskCount, requestedPropertyIds);
    setResourceProperty(resource, REQUEST_FAILED_TASK_CNT_ID, failedTaskCount, requestedPropertyIds);
    setResourceProperty(resource, REQUEST_ABORTED_TASK_CNT_ID, abortedTaskCount, requestedPropertyIds);
    setResourceProperty(resource, REQUEST_TIMED_OUT_TASK_CNT_ID, timedOutTaskCount, requestedPropertyIds);
    setResourceProperty(resource, REQUEST_QUEUED_TASK_CNT_ID, queuedTaskCount, requestedPropertyIds);
View Full Code Here

    Stage stage2 = createNiceMock(Stage.class);
    HostRoleCommand command1 = createNiceMock(HostRoleCommand.class);
    Role role = createNiceMock(Role.class);
    List<Stage> stages = new ArrayList<Stage>();
    RoleCommand roleCommand = RoleCommand.INSTALL;
    HostRoleStatus status = HostRoleStatus.IN_PROGRESS;
    stages.add(stage1);
    stages.add(stage2);
    List<HostRoleCommand> hostRoleCommands = new ArrayList<HostRoleCommand>();
    hostRoleCommands.add(command1);

    expect(actionManager.getRequestTasks(100)).andReturn(hostRoleCommands);
    expect(actionManager.getRequestContext(100)).andReturn("test");
    expect(command1.getTaskId()).andReturn(1L);
    expect(command1.getRoleCommand()).andReturn(roleCommand);
    expect(command1.getRole()).andReturn(role);
    expect(command1.getStatus()).andReturn(status);

    replay(actionManager, stage1, stage2, command1, role);

    RequestStageContainer requestStages = new RequestStageContainer(100L, stages, null, actionManager);
    RequestStatusResponse response = requestStages.getRequestStatusResponse();

    assertEquals(100, response.getRequestId());
    List<ShortTaskStatus> tasks = response.getTasks();
    assertEquals(1, tasks.size());
    ShortTaskStatus task = tasks.get(0);
    assertEquals(1, task.getTaskId());
    assertEquals(roleCommand.toString(), task.getCommand());
    assertEquals(status.toString(), task.getStatus());

    assertEquals("test", response.getRequestContext());

    verify(actionManager, stage1, stage2, command1, role);
  }
View Full Code Here

    int failedTaskCount = 0;
    int abortedTaskCount = 0;
    int timedOutTaskCount = 0;

    for (HostRoleCommand hostRoleCommand : commands) {
      HostRoleStatus status = hostRoleCommand.getStatus();
      if (status.isCompletedState()) {
        completedTaskCount++;

        switch (status) {
          case ABORTED:
            abortedTaskCount++;
            break;
          case FAILED:
            failedTaskCount++;
            break;
          case TIMEDOUT:
            timedOutTaskCount++;
            break;
        }
      } else if (status.equals(HostRoleStatus.QUEUED)) {
        queuedTaskCount++;
      } else if (status.equals(HostRoleStatus.PENDING)) {
        pendingTaskCount++;
      }
    }

    int inProgressTaskCount = taskCount - completedTaskCount - queuedTaskCount - pendingTaskCount;

    LOG.debug("taskCount={}, inProgressTaskCount={}, completedTaskCount={}, queuedTaskCount={}, " +
      "pendingTaskCount={}, failedTaskCount={}, abortedTaskCount={}, timedOutTaskCount={}",
      taskCount, inProgressTaskCount, completedTaskCount, queuedTaskCount, pendingTaskCount,
      failedTaskCount, abortedTaskCount, timedOutTaskCount);

    // determine request status
    HostRoleStatus requestStatus = failedTaskCount > 0 ? HostRoleStatus.FAILED :
        abortedTaskCount > 0 ? HostRoleStatus.ABORTED :
            timedOutTaskCount > 0 ? HostRoleStatus.TIMEDOUT :
                inProgressTaskCount > 0 ? HostRoleStatus.IN_PROGRESS :
                    completedTaskCount == taskCount ? HostRoleStatus.COMPLETED :
                        HostRoleStatus.PENDING;
    double progressPercent =
        ((queuedTaskCount * 0.09 + inProgressTaskCount * 0.35 + completedTaskCount) / (double) taskCount) * 100.0;

    setResourceProperty(resource, REQUEST_STATUS_PROPERTY_ID, requestStatus.toString(), requestedPropertyIds);
    setResourceProperty(resource, REQUEST_TASK_CNT_ID, taskCount, requestedPropertyIds);
    setResourceProperty(resource, REQUEST_FAILED_TASK_CNT_ID, failedTaskCount, requestedPropertyIds);
    setResourceProperty(resource, REQUEST_ABORTED_TASK_CNT_ID, abortedTaskCount, requestedPropertyIds);
    setResourceProperty(resource, REQUEST_TIMED_OUT_TASK_CNT_ID, timedOutTaskCount, requestedPropertyIds);
    setResourceProperty(resource, REQUEST_QUEUED_TASK_CNT_ID, queuedTaskCount, requestedPropertyIds);
View Full Code Here

    Long requestId = executionScheduleManager.executeBatchRequest
      (executionId, batchId, clusterName);

    if (requestId != null) {
      HostRoleStatus status;
      BatchRequestResponse batchRequestResponse;
      do {
        batchRequestResponse = executionScheduleManager
          .getBatchRequestResponse(requestId, clusterName);

        status = HostRoleStatus.valueOf(batchRequestResponse.getStatus());

        executionScheduleManager.updateBatchRequest(executionId, batchId,
          clusterName, batchRequestResponse, true);

        try {
          Thread.sleep(statusCheckInterval);
        } catch (InterruptedException e) {
          String message = "Job Thread interrupted";
          LOG.error(message, e);
          throw new AmbariException(message, e);
        }
      } while (!status.isCompletedState());

      // Store aggregated task status counts in the DataMap
      Map<String, Integer> aggregateCounts = addTaskCountToProperties
        (properties, taskCounts, batchRequestResponse);
View Full Code Here

    int failedTaskCount = 0;
    int abortedTaskCount = 0;
    int timedOutTaskCount = 0;

    for (HostRoleCommand hostRoleCommand : commands) {
      HostRoleStatus status = hostRoleCommand.getStatus();
      if (status.isCompletedState()) {
        completedTaskCount++;

        switch (status) {
          case ABORTED:
            abortedTaskCount++;
            break;
          case FAILED:
            failedTaskCount++;
            break;
          case TIMEDOUT:
            timedOutTaskCount++;
            break;
        }
      } else if (status.equals(HostRoleStatus.QUEUED)) {
        queuedTaskCount++;
      } else if (status.equals(HostRoleStatus.PENDING)) {
        pendingTaskCount++;
      }
    }

    int inProgressTaskCount = taskCount - completedTaskCount - queuedTaskCount - pendingTaskCount;

    // determine request status
    HostRoleStatus requestStatus = failedTaskCount > 0 ? HostRoleStatus.FAILED :
        abortedTaskCount > 0 ? HostRoleStatus.ABORTED :
            timedOutTaskCount > 0 ? HostRoleStatus.TIMEDOUT :
                inProgressTaskCount > 0 ? HostRoleStatus.IN_PROGRESS :
                    completedTaskCount == taskCount ? HostRoleStatus.COMPLETED :
                        HostRoleStatus.PENDING;
    double progressPercent =
        ((queuedTaskCount * 0.09 + inProgressTaskCount * 0.35 + completedTaskCount) / (double) taskCount) * 100.0;

    setResourceProperty(resource, REQUEST_STATUS_PROPERTY_ID, requestStatus.toString(), requestedPropertyIds);
    setResourceProperty(resource, REQUEST_TASK_CNT_ID, taskCount, requestedPropertyIds);
    setResourceProperty(resource, REQUEST_FAILED_TASK_CNT_ID, failedTaskCount, requestedPropertyIds);
    setResourceProperty(resource, REQUEST_ABORTED_TASK_CNT_ID, abortedTaskCount, requestedPropertyIds);
    setResourceProperty(resource, REQUEST_TIMED_OUT_TASK_CNT_ID, timedOutTaskCount, requestedPropertyIds);
    setResourceProperty(resource, REQUEST_QUEUED_TASK_CNT_ID, queuedTaskCount, requestedPropertyIds);
View Full Code Here

    int failedTaskCount = 0;
    int abortedTaskCount = 0;
    int timedOutTaskCount = 0;

    for (HostRoleCommand hostRoleCommand : commands) {
      HostRoleStatus status = hostRoleCommand.getStatus();
      if (status.isCompletedState()) {
        completedTaskCount++;

        switch (status) {
          case ABORTED:
            abortedTaskCount++;
            break;
          case FAILED:
            failedTaskCount++;
            break;
          case TIMEDOUT:
            timedOutTaskCount++;
            break;
        }
      } else if (status.equals(HostRoleStatus.QUEUED)) {
        queuedTaskCount++;
      } else if (status.equals(HostRoleStatus.PENDING)) {
        pendingTaskCount++;
      }
    }

    int inProgressTaskCount = taskCount - completedTaskCount - queuedTaskCount - pendingTaskCount;

    // determine request status
    HostRoleStatus requestStatus = failedTaskCount > 0 ? HostRoleStatus.FAILED :
        abortedTaskCount > 0 ? HostRoleStatus.ABORTED :
            timedOutTaskCount > 0 ? HostRoleStatus.TIMEDOUT :
                inProgressTaskCount > 0 ? HostRoleStatus.IN_PROGRESS :
                    completedTaskCount == taskCount ? HostRoleStatus.COMPLETED :
                        HostRoleStatus.PENDING;
    double progressPercent =
        ((queuedTaskCount * 0.09 + inProgressTaskCount * 0.35 + completedTaskCount) / (double) taskCount) * 100.0;

    setResourceProperty(resource, REQUEST_STATUS_PROPERTY_ID, requestStatus.toString(), requestedPropertyIds);
    setResourceProperty(resource, REQUEST_TASK_CNT_ID, taskCount, requestedPropertyIds);
    setResourceProperty(resource, REQUEST_FAILED_TASK_CNT_ID, failedTaskCount, requestedPropertyIds);
    setResourceProperty(resource, REQUEST_ABORTED_TASK_CNT_ID, abortedTaskCount, requestedPropertyIds);
    setResourceProperty(resource, REQUEST_TIMED_OUT_TASK_CNT_ID, timedOutTaskCount, requestedPropertyIds);
    setResourceProperty(resource, REQUEST_QUEUED_TASK_CNT_ID, queuedTaskCount, requestedPropertyIds);
View Full Code Here

    int failedTaskCount = 0;
    int abortedTaskCount = 0;
    int timedOutTaskCount = 0;

    for (HostRoleCommand hostRoleCommand : commands) {
      HostRoleStatus status = hostRoleCommand.getStatus();
      if (status.isCompletedState()) {
        completedTaskCount++;

        switch (status) {
          case ABORTED:
            abortedTaskCount++;
            break;
          case FAILED:
            failedTaskCount++;
            break;
          case TIMEDOUT:
            timedOutTaskCount++;
            break;
        }
      } else if (status.equals(HostRoleStatus.QUEUED)) {
        queuedTaskCount++;
      } else if (status.equals(HostRoleStatus.PENDING)) {
        pendingTaskCount++;
      }
    }

    int inProgressTaskCount = taskCount - completedTaskCount - queuedTaskCount - pendingTaskCount;

    // determine request status
    HostRoleStatus requestStatus = failedTaskCount > 0 ? HostRoleStatus.FAILED :
        abortedTaskCount > 0 ? HostRoleStatus.ABORTED :
            timedOutTaskCount > 0 ? HostRoleStatus.TIMEDOUT :
                inProgressTaskCount > 0 ? HostRoleStatus.IN_PROGRESS :
                    completedTaskCount == taskCount ? HostRoleStatus.COMPLETED :
                        HostRoleStatus.PENDING;
    double progressPercent =
        ((queuedTaskCount * 0.09 + inProgressTaskCount * 0.35 + completedTaskCount) / (double) taskCount) * 100.0;

    setResourceProperty(resource, REQUEST_STATUS_PROPERTY_ID, requestStatus.toString(), requestedPropertyIds);
    setResourceProperty(resource, REQUEST_TASK_CNT_ID, taskCount, requestedPropertyIds);
    setResourceProperty(resource, REQUEST_FAILED_TASK_CNT_ID, failedTaskCount, requestedPropertyIds);
    setResourceProperty(resource, REQUEST_ABORTED_TASK_CNT_ID, abortedTaskCount, requestedPropertyIds);
    setResourceProperty(resource, REQUEST_TIMED_OUT_TASK_CNT_ID, timedOutTaskCount, requestedPropertyIds);
    setResourceProperty(resource, REQUEST_QUEUED_TASK_CNT_ID, queuedTaskCount, requestedPropertyIds);
View Full Code Here

TOP

Related Classes of org.apache.ambari.server.actionmanager.HostRoleStatus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.