Search in sources :

Example 1 with BackupV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.dr.BackupV4Response in project cloudbreak by hortonworks.

the class SdxBackupRestoreService method databaseBackup.

public void databaseBackup(SdxOperation drStatus, Long clusterId, SdxDatabaseBackupRequest backupRequest) {
    try {
        sdxOperationRepository.save(drStatus);
        sdxClusterRepository.findById(clusterId).ifPresentOrElse(sdxCluster -> {
            String initiatorUserCrn = ThreadBasedUserCrnProvider.getUserCrn();
            BackupV4Response backupV4Response = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> stackV4Endpoint.backupDatabaseByNameInternal(0L, sdxCluster.getClusterName(), backupRequest.getBackupId(), backupRequest.getBackupLocation(), backupRequest.getCloseConnections(), initiatorUserCrn));
            updateSuccessStatus(drStatus.getOperationId(), sdxCluster, backupV4Response.getFlowIdentifier(), SdxOperationStatus.TRIGGERRED);
        }, () -> {
            updateFailureStatus(drStatus.getOperationId(), clusterId, String.format("SDX cluster with Id [%d] not found", clusterId));
        });
    } catch (WebApplicationException e) {
        String errorMessage = webApplicationExceptionMessageExtractor.getErrorMessage(e);
        String message = String.format("Database backup failed for datalake-id: [%d]. Message: [%s]", clusterId, errorMessage);
        throw new CloudbreakApiException(message);
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) BackupV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.dr.BackupV4Response) CloudbreakApiException(com.sequenceiq.cloudbreak.exception.CloudbreakApiException)

Aggregations

BackupV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.dr.BackupV4Response)1 CloudbreakApiException (com.sequenceiq.cloudbreak.exception.CloudbreakApiException)1 WebApplicationException (javax.ws.rs.WebApplicationException)1