Search in sources :

Example 1 with RestoreV4Response

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

the class SdxBackupRestoreService method databaseRestore.

public void databaseRestore(SdxOperation drStatus, Long clusterId, String backupId, String backupLocation) {
    try {
        sdxOperationRepository.save(drStatus);
        sdxClusterRepository.findById(clusterId).ifPresentOrElse(sdxCluster -> {
            String initiatorUserCrn = ThreadBasedUserCrnProvider.getUserCrn();
            RestoreV4Response restoreV4Response = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> stackV4Endpoint.restoreDatabaseByNameInternal(0L, sdxCluster.getClusterName(), backupLocation, backupId, initiatorUserCrn));
            updateSuccessStatus(drStatus.getOperationId(), sdxCluster, restoreV4Response.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 restore failed for datalake-id: [%d]. Message: [%s]", clusterId, errorMessage);
        throw new CloudbreakApiException(message);
    }
}
Also used : RestoreV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.dr.RestoreV4Response) WebApplicationException(javax.ws.rs.WebApplicationException) CloudbreakApiException(com.sequenceiq.cloudbreak.exception.CloudbreakApiException)

Aggregations

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