use of com.sequenceiq.cloudbreak.datalakedr.model.DatalakeBackupStatusResponse in project cloudbreak by hortonworks.
the class SdxBackupRestoreService method getDatalakeBackupStatus.
public SdxBackupStatusResponse getDatalakeBackupStatus(String datalakeName, String backupId, String backupName, String userCrn) {
LOGGER.info("Requesting datalake backup status for datalake: '{}'", datalakeName);
DatalakeBackupStatusResponse datalakeBackupStatusResponse = datalakeDrClient.getBackupStatus(datalakeName, backupId, backupName, userCrn);
return new SdxBackupStatusResponse(datalakeBackupStatusResponse.getBackupId(), datalakeBackupStatusResponse.getState().name(), datalakeBackupStatusResponse.getFailureReason());
}
use of com.sequenceiq.cloudbreak.datalakedr.model.DatalakeBackupStatusResponse in project cloudbreak by hortonworks.
the class SdxBackupRestoreService method getDatalakeRestoreStatus.
public SdxRestoreStatusResponse getDatalakeRestoreStatus(String datalakeName, String restoreId, String backupName, String userCrn) {
LOGGER.info("Requesting datalake restore status for datalake: '{}' with restoreId '{}'", datalakeName, restoreId);
DatalakeBackupStatusResponse datalakeBackupStatusResponse = datalakeDrClient.getRestoreStatus(datalakeName, restoreId, backupName, userCrn);
return new SdxRestoreStatusResponse(datalakeBackupStatusResponse.getBackupId(), datalakeBackupStatusResponse.getState().name(), datalakeBackupStatusResponse.getFailureReason());
}
use of com.sequenceiq.cloudbreak.datalakedr.model.DatalakeBackupStatusResponse in project cloudbreak by hortonworks.
the class DatalakeBackupActions method triggerDatalakeBackup.
@Bean(name = "DATALAKE_TRIGGERING_BACKUP_STATE")
public Action<?, ?> triggerDatalakeBackup() {
return new AbstractSdxAction<>(DatalakeTriggerBackupEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, DatalakeTriggerBackupEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void prepareExecution(DatalakeTriggerBackupEvent payload, Map<Object, Object> variables) {
variables.put(OPERATION_ID, payload.getDrStatus().getOperationId());
variables.put(REASON, payload.getReason().name());
super.prepareExecution(payload, variables);
}
@Override
protected void doExecute(SdxContext context, DatalakeTriggerBackupEvent payload, Map<Object, Object> variables) {
LOGGER.info("Triggering data lake backup for {}", payload.getResourceId());
SdxCluster sdxCluster = sdxService.getById(payload.getResourceId());
eventSenderService.sendEventAndNotification(sdxCluster, context.getFlowTriggerUserCrn(), ResourceEvent.DATALAKE_BACKUP_IN_PROGRESS);
DatalakeBackupStatusResponse backupStatusResponse = sdxBackupRestoreService.triggerDatalakeBackup(payload.getResourceId(), payload.getBackupLocation(), payload.getBackupName(), payload.getUserId());
variables.put(BACKUP_ID, backupStatusResponse.getBackupId());
variables.put(OPERATION_ID, backupStatusResponse.getBackupId());
payload.getDrStatus().setOperationId(backupStatusResponse.getBackupId());
if (!backupStatusResponse.failed()) {
sendEvent(context, DatalakeDatabaseBackupStartEvent.from(payload, backupStatusResponse.getBackupId()));
} else {
sendEvent(context, DATALAKE_BACKUP_FAILED_EVENT.event(), payload);
}
}
@Override
protected Object getFailurePayload(DatalakeTriggerBackupEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return DatalakeBackupFailedEvent.from(payload, ex);
}
};
}
use of com.sequenceiq.cloudbreak.datalakedr.model.DatalakeBackupStatusResponse in project cloudbreak by hortonworks.
the class GrpcStatusResponseToDatalakeBackupStatusResponseConverterTest method testInProgressBackup.
@Test
public void testInProgressBackup() {
datalakeDRProto.BackupDatalakeStatusResponse.Builder builder = datalakeDRProto.BackupDatalakeStatusResponse.newBuilder().setOverallState("IN_PROGRESS");
DatalakeBackupStatusResponse response = underTest.convert(builder.build());
assertEquals(DatalakeBackupStatusResponse.State.IN_PROGRESS, response.getState());
assert !response.isComplete();
}
use of com.sequenceiq.cloudbreak.datalakedr.model.DatalakeBackupStatusResponse in project cloudbreak by hortonworks.
the class GrpcStatusResponseToDatalakeBackupStatusResponseConverterTest method testBackupLegacyFailureReason.
@Test
public void testBackupLegacyFailureReason() {
datalakeDRProto.BackupDatalakeStatusResponse.Builder builder = datalakeDRProto.BackupDatalakeStatusResponse.newBuilder().setOverallState(FAILED_STATE).setFailureReason(FAILURE_REASON);
DatalakeBackupStatusResponse response = underTest.convert(builder.build());
assertEquals(DatalakeBackupStatusResponse.State.FAILED, response.getState());
assertEquals(FAILURE_REASON, response.getFailureReason());
assert response.isComplete();
}
Aggregations