Search in sources :

Example 1 with ClusterStatus

use of com.sequenceiq.cloudbreak.cluster.status.ClusterStatus in project cloudbreak by hortonworks.

the class ClusterStatusUpdater method updateClusterStatus.

private void updateClusterStatus(Stack stack, ClusterStatusResult clusterStatusResult) {
    Status statusInEvent = stack.getStatus();
    ClusterStatus clusterStatus = clusterStatusResult.getClusterStatus();
    String statusReason = clusterStatusResult.getStatusReason();
    if (isUpdateEnabled(clusterStatus)) {
        if (updateClusterStatus(stack, clusterStatus)) {
            statusInEvent = clusterStatus.getDetailedStackStatus().getStatus();
            statusReason = clusterStatus.getStatusReason();
        } else {
            statusReason = "The cluster's state is up to date.";
        }
    }
    cloudbreakEventService.fireCloudbreakEvent(stack.getId(), statusInEvent.name(), CLUSTER_AMBARI_CLUSTER_SYNCHRONIZED, Collections.singletonList(statusReason));
}
Also used : DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) Status(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status) ClusterStatus(com.sequenceiq.cloudbreak.cluster.status.ClusterStatus) ClusterStatus(com.sequenceiq.cloudbreak.cluster.status.ClusterStatus)

Example 2 with ClusterStatus

use of com.sequenceiq.cloudbreak.cluster.status.ClusterStatus in project cloudbreak by hortonworks.

the class ClusterStatusUpdater method updateClusterStatus.

private boolean updateClusterStatus(Stack stack, ClusterStatus clusterStatus) {
    boolean result = false;
    Cluster cluster = stack.getCluster();
    Status actualStatus = stack.getStatus();
    DetailedStackStatus newDetailedStackStatus = clusterStatus.getDetailedStackStatus();
    Status newStatus = newDetailedStackStatus.getStatus();
    if (actualStatus != newStatus) {
        if (!actualStatus.equals(Status.MAINTENANCE_MODE_ENABLED) || !newStatus.equals(Status.AVAILABLE)) {
            LOGGER.debug("Cluster {} status is updated from {} to {}/{}", cluster.getId(), actualStatus, newStatus, newDetailedStackStatus);
            clusterService.updateClusterStatusByStackId(stack.getId(), newDetailedStackStatus, clusterStatus.getStatusReason());
            result = true;
        }
    } else {
        LOGGER.debug("Cluster {} status hasn't changed: {}", cluster.getId(), actualStatus);
    }
    return result;
}
Also used : DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) Status(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status) ClusterStatus(com.sequenceiq.cloudbreak.cluster.status.ClusterStatus) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)

Aggregations

DetailedStackStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)2 Status (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status)2 ClusterStatus (com.sequenceiq.cloudbreak.cluster.status.ClusterStatus)2 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)1