use of com.sequenceiq.sdx.api.model.SdxDatabaseBackupResponse in project cloudbreak by hortonworks.
the class SdxBackupRestoreService method triggerDatalakeDatabaseBackupFlow.
private SdxDatabaseBackupResponse triggerDatalakeDatabaseBackupFlow(Long clusterId, SdxDatabaseBackupRequest backupRequest) {
String selector = DATALAKE_DATABASE_BACKUP_EVENT.event();
String userId = ThreadBasedUserCrnProvider.getUserCrn();
DatalakeDatabaseBackupStartEvent startEvent = new DatalakeDatabaseBackupStartEvent(selector, clusterId, userId, backupRequest);
FlowIdentifier flowIdentifier = sdxReactorFlowManager.triggerDatalakeDatabaseBackupFlow(startEvent);
return new SdxDatabaseBackupResponse(startEvent.getDrStatus().getOperationId(), flowIdentifier);
}
use of com.sequenceiq.sdx.api.model.SdxDatabaseBackupResponse in project cloudbreak by hortonworks.
the class SdxBackupRestoreServiceTest method triggerDatabaseBackupSuccess.
@Test
public void triggerDatabaseBackupSuccess() {
when(sdxReactorFlowManager.triggerDatalakeDatabaseBackupFlow(any(DatalakeDatabaseBackupStartEvent.class), anyString())).thenReturn(FLOW_IDENTIFIER);
SdxDatabaseBackupRequest backupRequest = new SdxDatabaseBackupRequest();
backupRequest.setBackupId(BACKUP_ID);
backupRequest.setBackupLocation(BACKUP_LOCATION);
backupRequest.setCloseConnections(true);
SdxDatabaseBackupResponse backupResponse = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> sdxBackupRestoreService.triggerDatabaseBackup(sdxCluster, backupRequest));
assertEquals(FLOW_IDENTIFIER, backupResponse.getFlowIdentifier());
ArgumentCaptor<DatalakeDatabaseBackupStartEvent> eventArgumentCaptor = ArgumentCaptor.forClass(DatalakeDatabaseBackupStartEvent.class);
verify(sdxReactorFlowManager, times(1)).triggerDatalakeDatabaseBackupFlow(eventArgumentCaptor.capture(), anyString());
assertEquals(BACKUP_ID, eventArgumentCaptor.getValue().getBackupRequest().getBackupId());
assertEquals(BACKUP_LOCATION, eventArgumentCaptor.getValue().getBackupRequest().getBackupLocation());
assertEquals(USER_CRN, eventArgumentCaptor.getValue().getUserId());
assertEquals(sdxCluster.getId(), eventArgumentCaptor.getValue().getResourceId());
assertTrue(isUUID(eventArgumentCaptor.getValue().getDrStatus().getOperationId()));
}
use of com.sequenceiq.sdx.api.model.SdxDatabaseBackupResponse 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.SdxDatabaseBackupResponse in project cloudbreak by hortonworks.
the class SdxBackupRestoreService method triggerDatalakeDatabaseBackupFlow.
private SdxDatabaseBackupResponse triggerDatalakeDatabaseBackupFlow(SdxCluster cluster, SdxDatabaseBackupRequest backupRequest) {
String selector = DATALAKE_DATABASE_BACKUP_EVENT.event();
String userId = ThreadBasedUserCrnProvider.getUserCrn();
DatalakeDatabaseBackupStartEvent startEvent = new DatalakeDatabaseBackupStartEvent(selector, cluster.getId(), userId, backupRequest);
FlowIdentifier flowIdentifier = sdxReactorFlowManager.triggerDatalakeDatabaseBackupFlow(startEvent, cluster.getClusterName());
return new SdxDatabaseBackupResponse(startEvent.getDrStatus().getOperationId(), flowIdentifier);
}
use of com.sequenceiq.sdx.api.model.SdxDatabaseBackupResponse 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);
}
}
Aggregations