use of com.sequenceiq.redbeams.api.model.common.DetailedDBStackStatus 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());
}
}
use of com.sequenceiq.redbeams.api.model.common.DetailedDBStackStatus in project cloudbreak by hortonworks.
the class DBStackStatusSyncService method getDetailedDBStackStatusFromProvider.
private DetailedDBStackStatus getDetailedDBStackStatusFromProvider(DBStack dbStack) {
Optional<ExternalDatabaseStatus> externalDatabaseStatus = getExternalDatabaseStatus(dbStack);
DetailedDBStackStatus detailedDBStackStatus = externalDatabaseStatus.map(this::convert).orElse(DetailedDBStackStatus.UNKNOWN);
LOGGER.debug(":::Auto sync::: ExternalDatabaseStatus.{} got converted to DetailedDBStackStatus.{}", externalDatabaseStatus, detailedDBStackStatus);
return detailedDBStackStatus;
}
use of com.sequenceiq.redbeams.api.model.common.DetailedDBStackStatus 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;
});
}
Aggregations