use of com.sequenceiq.sdx.api.model.SdxDatabaseBackupStatusResponse in project cloudbreak by hortonworks.
the class DatalakeBackupActions method datalakeFullBackupInProgress.
@Bean(name = "DATALAKE_FULL_BACKUP_IN_PROGRESS_STATE")
public Action<?, ?> datalakeFullBackupInProgress() {
return new AbstractSdxAction<>(SdxEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, SdxEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, SdxEvent payload, Map<Object, Object> variables) {
LOGGER.info("Full datalake backup is in progress for {} ", payload.getResourceId());
String operationId = (String) variables.get(OPERATION_ID);
String backupId = (String) variables.get(BACKUP_ID);
SdxCluster sdxCluster = sdxService.getById(payload.getResourceId());
eventSenderService.sendEventAndNotification(sdxCluster, ThreadBasedUserCrnProvider.getUserCrn(), DATALAKE_DATABASE_BACKUP_FINISHED);
SdxDatabaseBackupStatusResponse backupStatusResponse = sdxBackupRestoreService.getDatabaseBackupStatus(sdxCluster, operationId);
if (backupStatusResponse.getStatus().equals(DatalakeDatabaseDrStatus.INPROGRESS)) {
sdxBackupRestoreService.updateDatabaseStatusEntry(operationId, SdxOperationStatus.SUCCEEDED, null);
}
sendEvent(context, DatalakeFullBackupWaitRequest.from(context, backupId));
}
@Override
protected Object getFailurePayload(SdxEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return DatalakeBackupFailedEvent.from(payload, ex);
}
};
}
use of com.sequenceiq.sdx.api.model.SdxDatabaseBackupStatusResponse in project cloudbreak by hortonworks.
the class SdxBackupController method backupDatabaseByNameInternal.
@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.BACKUP_DATALAKE)
public SdxDatabaseBackupResponse backupDatabaseByNameInternal(@ResourceName String name, SdxDatabaseBackupRequest backupRequest) {
SdxCluster sdxCluster = getSdxClusterByName(name);
String backupId = backupRequest.getBackupId();
try {
SdxDatabaseBackupStatusResponse response = sdxBackupRestoreService.getDatabaseBackupStatus(sdxCluster, backupId);
SdxDatabaseBackupResponse sdxDatabaseBackupResponse = new SdxDatabaseBackupResponse();
sdxDatabaseBackupResponse.setOperationId(backupId);
return sdxDatabaseBackupResponse;
} catch (NotFoundException notFoundException) {
return sdxBackupRestoreService.triggerDatabaseBackup(sdxCluster, backupRequest);
}
}
use of com.sequenceiq.sdx.api.model.SdxDatabaseBackupStatusResponse 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.sdx.api.model.SdxDatabaseBackupStatusResponse in project cloudbreak by hortonworks.
the class SdxBackupController method backupDatabaseByName.
@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.BACKUP_DATALAKE)
public SdxDatabaseBackupResponse backupDatabaseByName(@ResourceName String name, String backupId, String backupLocation) {
SdxCluster sdxCluster = getSdxClusterByName(name);
try {
SdxDatabaseBackupStatusResponse response = sdxBackupRestoreService.getDatabaseBackupStatus(sdxCluster, backupId);
SdxDatabaseBackupResponse sdxDatabaseBackupResponse = new SdxDatabaseBackupResponse();
sdxDatabaseBackupResponse.setOperationId(backupId);
return sdxDatabaseBackupResponse;
} catch (NotFoundException notFoundException) {
SdxDatabaseBackupRequest backupRequest = new SdxDatabaseBackupRequest();
backupRequest.setBackupId(backupId);
backupRequest.setBackupLocation(backupLocation);
backupRequest.setCloseConnections(true);
return sdxBackupRestoreService.triggerDatabaseBackup(sdxCluster, backupRequest);
}
}
use of com.sequenceiq.sdx.api.model.SdxDatabaseBackupStatusResponse in project cloudbreak by hortonworks.
the class SdxBackupControllerTest method testBackupDatabaseByName.
@Test
public void testBackupDatabaseByName() {
SdxCluster sdxCluster = getValidSdxCluster();
when(sdxService.getByNameInAccount(any(), anyString())).thenReturn(sdxCluster);
String backupId = UUID.randomUUID().toString();
when(sdxBackupRestoreService.getDatabaseBackupStatus(sdxCluster, backupId)).thenThrow(new NotFoundException("Status entry not found"));
sdxBackupController.backupDatabaseByName(sdxCluster.getClusterName(), backupId, "");
verify(sdxBackupRestoreService, times(1)).triggerDatabaseBackup(any(), any());
reset(sdxBackupRestoreService);
when(sdxBackupRestoreService.getDatabaseBackupStatus(sdxCluster, backupId)).thenReturn(new SdxDatabaseBackupStatusResponse(DatalakeDatabaseDrStatus.SUCCEEDED, null));
sdxBackupController.backupDatabaseByName(sdxCluster.getClusterName(), backupId, "");
verify(sdxBackupRestoreService, times(0)).triggerDatabaseBackup(any(), any());
}
Aggregations