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);
}
}
Aggregations