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