Search in sources :

Example 1 with SdxOperation

use of com.sequenceiq.datalake.entity.operation.SdxOperation in project cloudbreak by hortonworks.

the class SdxBackupRestoreService method getDatabaseBackupStatus.

public SdxDatabaseBackupStatusResponse getDatabaseBackupStatus(SdxCluster sdxCluster, String operationId) {
    MDCBuilder.buildMdcContext(sdxCluster);
    SdxOperation drStatus = getDatabaseDrStatus(sdxCluster, operationId, SdxOperationType.BACKUP);
    return new SdxDatabaseBackupStatusResponse(convertSdxDatabaseDrStatus(drStatus.getStatus()), drStatus.getStatusReason());
}
Also used : SdxDatabaseBackupStatusResponse(com.sequenceiq.sdx.api.model.SdxDatabaseBackupStatusResponse) SdxOperation(com.sequenceiq.datalake.entity.operation.SdxOperation)

Example 2 with SdxOperation

use of com.sequenceiq.datalake.entity.operation.SdxOperation in project cloudbreak by hortonworks.

the class SdxBackupRestoreService method getDatabaseRestoreStatus.

public SdxDatabaseRestoreStatusResponse getDatabaseRestoreStatus(SdxCluster sdxCluster, String operationId) {
    MDCBuilder.buildMdcContext(sdxCluster);
    SdxOperation drStatus = getDatabaseDrStatus(sdxCluster, operationId, SdxOperationType.RESTORE);
    return new SdxDatabaseRestoreStatusResponse(convertSdxDatabaseDrStatus(drStatus.getStatus()), drStatus.getStatusReason());
}
Also used : SdxOperation(com.sequenceiq.datalake.entity.operation.SdxOperation) SdxDatabaseRestoreStatusResponse(com.sequenceiq.sdx.api.model.SdxDatabaseRestoreStatusResponse)

Example 3 with SdxOperation

use of com.sequenceiq.datalake.entity.operation.SdxOperation in project cloudbreak by hortonworks.

the class SdxBackupRestoreServiceTest method testgetDatabaseBackupStatus.

@Test
public void testgetDatabaseBackupStatus() {
    when(sdxOperationRepository.findSdxOperationByOperationId(Mockito.anyString())).thenReturn(null);
    try {
        sdxBackupRestoreService.getDatabaseBackupStatus(sdxCluster, BACKUP_ID);
        fail("Exception should have been thrown");
    } catch (NotFoundException notFoundException) {
        String exceptedMessage = String.format("Status with id: [%s] not found", BACKUP_ID);
        assertEquals(exceptedMessage, notFoundException.getLocalizedMessage());
    }
    reset(sdxOperationRepository);
    SdxOperation sdxOperation = new SdxOperation();
    sdxOperation.setOperationType(SdxOperationType.RESTORE);
    sdxOperation.setSdxClusterId(sdxCluster.getId());
    sdxOperation.setOperationId(BACKUP_ID);
    when(sdxOperationRepository.findSdxOperationByOperationId(Mockito.anyString())).thenReturn(sdxOperation);
    try {
        sdxBackupRestoreService.getDatabaseBackupStatus(sdxCluster, BACKUP_ID);
        fail("Exception should have been thrown");
    } catch (CloudbreakApiException cloudbreakApiException) {
        String exceptedMessage = String.format("Invalid operation-id: [%s]. provided", BACKUP_ID);
        assertEquals(exceptedMessage, cloudbreakApiException.getLocalizedMessage());
    }
}
Also used : SdxOperation(com.sequenceiq.datalake.entity.operation.SdxOperation) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CloudbreakApiException(com.sequenceiq.cloudbreak.exception.CloudbreakApiException) Test(org.junit.jupiter.api.Test)

Example 4 with SdxOperation

use of com.sequenceiq.datalake.entity.operation.SdxOperation in project cloudbreak by hortonworks.

the class SdxBackupRestoreService method updateDatabaseStatusEntry.

public void updateDatabaseStatusEntry(String operationId, SdxOperationStatus status, String failedReason) {
    if (Strings.isNullOrEmpty(operationId)) {
        LOGGER.error("Operation-id is empty. Database Dr status will not be updated properly");
        return;
    }
    SdxOperation drStatus = sdxOperationRepository.findSdxOperationByOperationId(operationId);
    drStatus.setStatus(status);
    if (!Strings.isNullOrEmpty(failedReason)) {
        drStatus.setStatusReason(failedReason.substring(0, Math.min(failedReason.length(), MAX_SIZE_OF_FAILURE_REASON)));
    }
    sdxOperationRepository.save(drStatus);
}
Also used : SdxOperation(com.sequenceiq.datalake.entity.operation.SdxOperation)

Aggregations

SdxOperation (com.sequenceiq.datalake.entity.operation.SdxOperation)4 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)1 CloudbreakApiException (com.sequenceiq.cloudbreak.exception.CloudbreakApiException)1 SdxDatabaseBackupStatusResponse (com.sequenceiq.sdx.api.model.SdxDatabaseBackupStatusResponse)1 SdxDatabaseRestoreStatusResponse (com.sequenceiq.sdx.api.model.SdxDatabaseRestoreStatusResponse)1 Test (org.junit.jupiter.api.Test)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1