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