use of com.sequenceiq.sdx.api.model.SdxDatabaseRestoreResponse in project cloudbreak by hortonworks.
the class SdxBackupRestoreServiceTest method triggerDatabaseRestoreSuccess.
@Test
public void triggerDatabaseRestoreSuccess() {
when(sdxReactorFlowManager.triggerDatalakeDatabaseRestoreFlow(any(DatalakeDatabaseRestoreStartEvent.class), anyString())).thenReturn(FLOW_IDENTIFIER);
SdxDatabaseRestoreResponse restoreResponse = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> sdxBackupRestoreService.triggerDatabaseRestore(sdxCluster, BACKUP_ID, RESTORE_ID, BACKUP_LOCATION));
assertEquals(FLOW_IDENTIFIER, restoreResponse.getFlowIdentifier());
ArgumentCaptor<DatalakeDatabaseRestoreStartEvent> eventArgumentCaptor = ArgumentCaptor.forClass(DatalakeDatabaseRestoreStartEvent.class);
verify(sdxReactorFlowManager, times(1)).triggerDatalakeDatabaseRestoreFlow(eventArgumentCaptor.capture(), anyString());
assertEquals(BACKUP_ID, eventArgumentCaptor.getValue().getBackupId());
assertEquals(RESTORE_ID, eventArgumentCaptor.getValue().getRestoreId());
assertEquals(BACKUP_LOCATION, eventArgumentCaptor.getValue().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.SdxDatabaseRestoreResponse in project cloudbreak by hortonworks.
the class SdxRestoreController method restoreDatabaseByName.
@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.RESTORE_DATALAKE)
public SdxDatabaseRestoreResponse restoreDatabaseByName(@ResourceName String name, String backupId, String restoreId, String backupLocation) {
SdxCluster sdxCluster = getSdxClusterByName(name);
try {
sdxBackupRestoreService.getDatabaseRestoreStatus(sdxCluster, restoreId);
SdxDatabaseRestoreResponse sdxDatabaseRestoreResponse = new SdxDatabaseRestoreResponse();
sdxDatabaseRestoreResponse.setOperationId(restoreId);
return sdxDatabaseRestoreResponse;
} catch (NotFoundException notFoundException) {
return sdxBackupRestoreService.triggerDatabaseRestore(sdxCluster, backupId, restoreId, backupLocation);
}
}
use of com.sequenceiq.sdx.api.model.SdxDatabaseRestoreResponse in project cloudbreak by hortonworks.
the class SdxBackupRestoreService method triggerDatalakeDatabaseRestoreFlow.
private SdxDatabaseRestoreResponse triggerDatalakeDatabaseRestoreFlow(SdxCluster cluster, String backupId, String restoreId, String backupLocation) {
String selector = DATALAKE_DATABASE_RESTORE_EVENT.event();
String userId = ThreadBasedUserCrnProvider.getUserCrn();
DatalakeDatabaseRestoreStartEvent startEvent = new DatalakeDatabaseRestoreStartEvent(selector, cluster.getId(), userId, backupId, restoreId, backupLocation);
FlowIdentifier flowIdentifier = sdxReactorFlowManager.triggerDatalakeDatabaseRestoreFlow(startEvent, cluster.getClusterName());
return new SdxDatabaseRestoreResponse(startEvent.getDrStatus().getOperationId(), flowIdentifier);
}
use of com.sequenceiq.sdx.api.model.SdxDatabaseRestoreResponse in project cloudbreak by hortonworks.
the class SdxBackupRestoreService method triggerDatalakeDatabaseRestoreFlow.
private SdxDatabaseRestoreResponse triggerDatalakeDatabaseRestoreFlow(Long clusterId, String backupId, String restoreId, String backupLocation) {
String selector = DATALAKE_DATABASE_RESTORE_EVENT.event();
String userId = ThreadBasedUserCrnProvider.getUserCrn();
DatalakeDatabaseRestoreStartEvent startEvent = new DatalakeDatabaseRestoreStartEvent(selector, clusterId, userId, backupId, restoreId, backupLocation);
FlowIdentifier flowIdentifier = sdxReactorFlowManager.triggerDatalakeDatabaseRestoreFlow(startEvent);
return new SdxDatabaseRestoreResponse(startEvent.getDrStatus().getOperationId(), flowIdentifier);
}
Aggregations