Search in sources :

Example 1 with Status

use of com.sequenceiq.redbeams.api.model.common.Status in project cloudbreak by hortonworks.

the class DBStackStatusSyncService method sync.

public void sync(DBStack dbStack) {
    DetailedDBStackStatus detailedDBStackStatus = getDetailedDBStackStatusFromProvider(dbStack);
    Status status = detailedDBStackStatus.getStatus();
    if (dbStack.getStatus() != status) {
        if (status == null) {
            LOGGER.warn(":::Auto sync::: Can not update DBStack status because 'ExternalDatabaseStatus.{}' is mapped to 'null'", detailedDBStackStatus);
        } else {
            LOGGER.debug(":::Auto sync::: Update DB Stack Status from '{}' to '{}'", dbStack.getStatus(), status);
            dbStackStatusUpdater.updateStatus(dbStack.getId(), detailedDBStackStatus);
        }
    }
    if (status != null && Status.getUnscheduleAutoSyncStatuses().contains(status)) {
        LOGGER.debug(":::Auto sync::: Unschedule DB Stack Status sync as the status is '{}'", status);
        dbStackJobService.unschedule(dbStack.getId(), dbStack.getName());
    }
}
Also used : DetailedDBStackStatus(com.sequenceiq.redbeams.api.model.common.DetailedDBStackStatus) ExternalDatabaseStatus(com.sequenceiq.cloudbreak.cloud.model.ExternalDatabaseStatus) Status(com.sequenceiq.redbeams.api.model.common.Status) DetailedDBStackStatus(com.sequenceiq.redbeams.api.model.common.DetailedDBStackStatus)

Example 2 with Status

use of com.sequenceiq.redbeams.api.model.common.Status in project cloudbreak by hortonworks.

the class DBStackStatusUpdater method updateStatus.

public Optional<DBStack> updateStatus(Long dbStackId, DetailedDBStackStatus detailedStatus, String statusReason) {
    return dbStackService.findById(dbStackId).map(dbStack -> {
        if (dbStack.getStatus() != Status.DELETE_COMPLETED) {
            Status status = detailedStatus.getStatus();
            DBStackStatus updatedStatus = new DBStackStatus(dbStack, status, statusReason, detailedStatus, clock.getCurrentTimeMillis());
            // The next line is a workaround to get the @OneToOne @MapsId relationship between DBStack and DBStackStatus working
            // see https://hibernate.atlassian.net/browse/HHH-12436
            // It might be removable once Spring Boot bumps up to Hibernate 5.4
            updatedStatus.setId(dbStackId);
            dbStack.setDBStackStatus(updatedStatus);
            dbStack = dbStackService.save(dbStack);
            redbeamsInMemoryStateStoreUpdaterService.update(dbStackId, updatedStatus.getStatus());
        }
        return dbStack;
    });
}
Also used : DetailedDBStackStatus(com.sequenceiq.redbeams.api.model.common.DetailedDBStackStatus) DBStackStatus(com.sequenceiq.redbeams.domain.stack.DBStackStatus) Status(com.sequenceiq.redbeams.api.model.common.Status) DetailedDBStackStatus(com.sequenceiq.redbeams.api.model.common.DetailedDBStackStatus) DBStackStatus(com.sequenceiq.redbeams.domain.stack.DBStackStatus)

Aggregations

DetailedDBStackStatus (com.sequenceiq.redbeams.api.model.common.DetailedDBStackStatus)2 Status (com.sequenceiq.redbeams.api.model.common.Status)2 ExternalDatabaseStatus (com.sequenceiq.cloudbreak.cloud.model.ExternalDatabaseStatus)1 DBStackStatus (com.sequenceiq.redbeams.domain.stack.DBStackStatus)1