Search in sources :

Example 11 with DatalakeBackupStatusResponse

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());
}
Also used : SdxBackupStatusResponse(com.sequenceiq.sdx.api.model.SdxBackupStatusResponse) DatalakeBackupStatusResponse(com.sequenceiq.cloudbreak.datalakedr.model.DatalakeBackupStatusResponse)

Example 12 with DatalakeBackupStatusResponse

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());
}
Also used : DatalakeBackupStatusResponse(com.sequenceiq.cloudbreak.datalakedr.model.DatalakeBackupStatusResponse) SdxRestoreStatusResponse(com.sequenceiq.sdx.api.model.SdxRestoreStatusResponse)

Example 13 with DatalakeBackupStatusResponse

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);
        }
    };
}
Also used : FlowParameters(com.sequenceiq.flow.core.FlowParameters) AbstractSdxAction(com.sequenceiq.datalake.service.AbstractSdxAction) Optional(java.util.Optional) DatalakeBackupStatusResponse(com.sequenceiq.cloudbreak.datalakedr.model.DatalakeBackupStatusResponse) StateContext(org.springframework.statemachine.StateContext) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) Map(java.util.Map) PollerStoppedException(com.dyngr.exception.PollerStoppedException) DatalakeTriggerBackupEvent(com.sequenceiq.datalake.flow.dr.backup.event.DatalakeTriggerBackupEvent) SdxContext(com.sequenceiq.datalake.flow.SdxContext) Bean(org.springframework.context.annotation.Bean)

Example 14 with DatalakeBackupStatusResponse

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();
}
Also used : DatalakeBackupStatusResponse(com.sequenceiq.cloudbreak.datalakedr.model.DatalakeBackupStatusResponse) Test(org.junit.Test)

Example 15 with DatalakeBackupStatusResponse

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();
}
Also used : DatalakeBackupStatusResponse(com.sequenceiq.cloudbreak.datalakedr.model.DatalakeBackupStatusResponse) Test(org.junit.Test)

Aggregations

DatalakeBackupStatusResponse (com.sequenceiq.cloudbreak.datalakedr.model.DatalakeBackupStatusResponse)17 Test (org.junit.Test)13 PollerStoppedException (com.dyngr.exception.PollerStoppedException)1 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)1 SdxContext (com.sequenceiq.datalake.flow.SdxContext)1 DatalakeTriggerBackupEvent (com.sequenceiq.datalake.flow.dr.backup.event.DatalakeTriggerBackupEvent)1 AbstractSdxAction (com.sequenceiq.datalake.service.AbstractSdxAction)1 FlowParameters (com.sequenceiq.flow.core.FlowParameters)1 SdxBackupStatusResponse (com.sequenceiq.sdx.api.model.SdxBackupStatusResponse)1 SdxRestoreStatusResponse (com.sequenceiq.sdx.api.model.SdxRestoreStatusResponse)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Test (org.junit.jupiter.api.Test)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 Bean (org.springframework.context.annotation.Bean)1 StateContext (org.springframework.statemachine.StateContext)1