Search in sources :

Example 6 with DatalakeTriggerRestoreEvent

use of com.sequenceiq.datalake.flow.dr.restore.event.DatalakeTriggerRestoreEvent in project cloudbreak by hortonworks.

the class DatalakeRestoreActionsTest method testRestoreWithNoFlowChain.

@Test
public void testRestoreWithNoFlowChain() throws Exception {
    when(sdxBackupRestoreService.triggerDatalakeRestore(eq(OLD_SDX_ID), any(), any(), eq(USER_CRN))).thenReturn(new DatalakeRestoreStatusResponse(BACKUP_ID, RESTORE_ID, State.STARTED, Optional.empty()));
    DatalakeTriggerRestoreEvent event = new DatalakeTriggerRestoreEvent(DATALAKE_TRIGGER_RESTORE_EVENT.event(), OLD_SDX_ID, DATALAKE_NAME, USER_CRN, null, BACKUP_LOCATION, null, DatalakeRestoreFailureReason.RESTORE_ON_RESIZE);
    AbstractAction action = (AbstractAction) underTest.triggerDatalakeRestore();
    initActionPrivateFields(action);
    AbstractActionTestSupport testSupport = new AbstractActionTestSupport(action);
    SdxContext context = SdxContext.from(new FlowParameters(FLOW_ID, FLOW_ID, null), event);
    testSupport.doExecute(context, event, new HashMap());
    ArgumentCaptor<DatalakeDatabaseRestoreStartEvent> captor = ArgumentCaptor.forClass(DatalakeDatabaseRestoreStartEvent.class);
    verify(reactorEventFactory, times(1)).createEvent(any(), captor.capture());
    DatalakeDatabaseRestoreStartEvent captorValue = captor.getValue();
    Assertions.assertEquals(OLD_SDX_ID, captorValue.getResourceId());
}
Also used : FlowParameters(com.sequenceiq.flow.core.FlowParameters) DatalakeTriggerRestoreEvent(com.sequenceiq.datalake.flow.dr.restore.event.DatalakeTriggerRestoreEvent) HashMap(java.util.HashMap) AbstractActionTestSupport(com.sequenceiq.flow.core.AbstractActionTestSupport) DatalakeDatabaseRestoreStartEvent(com.sequenceiq.datalake.flow.dr.restore.event.DatalakeDatabaseRestoreStartEvent) AbstractAction(com.sequenceiq.flow.core.AbstractAction) DatalakeRestoreStatusResponse(com.sequenceiq.cloudbreak.datalakedr.model.DatalakeRestoreStatusResponse) SdxContext(com.sequenceiq.datalake.flow.SdxContext) Test(org.junit.jupiter.api.Test)

Example 7 with DatalakeTriggerRestoreEvent

use of com.sequenceiq.datalake.flow.dr.restore.event.DatalakeTriggerRestoreEvent in project cloudbreak by hortonworks.

the class SdxBackupRestoreService method triggerDatalakeRestoreFlow.

private SdxRestoreResponse triggerDatalakeRestoreFlow(Long clusterId, String backupId, String backupLocation, String backupLocationOverride) {
    String selector = DATALAKE_TRIGGER_RESTORE_EVENT.event();
    String userId = ThreadBasedUserCrnProvider.getUserCrn();
    DatalakeTriggerRestoreEvent startEvent = new DatalakeTriggerRestoreEvent(selector, clusterId, null, userId, backupId, backupLocation, backupLocationOverride, DatalakeRestoreFailureReason.USER_TRIGGERED);
    FlowIdentifier flowIdentifier = sdxReactorFlowManager.triggerDatalakeRestoreFlow(startEvent);
    return new SdxRestoreResponse(startEvent.getDrStatus().getOperationId(), flowIdentifier);
}
Also used : SdxRestoreResponse(com.sequenceiq.sdx.api.model.SdxRestoreResponse) DatalakeTriggerRestoreEvent(com.sequenceiq.datalake.flow.dr.restore.event.DatalakeTriggerRestoreEvent) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier)

Aggregations

DatalakeTriggerRestoreEvent (com.sequenceiq.datalake.flow.dr.restore.event.DatalakeTriggerRestoreEvent)7 SdxContext (com.sequenceiq.datalake.flow.SdxContext)4 FlowParameters (com.sequenceiq.flow.core.FlowParameters)4 DatalakeRestoreStatusResponse (com.sequenceiq.cloudbreak.datalakedr.model.DatalakeRestoreStatusResponse)3 AbstractAction (com.sequenceiq.flow.core.AbstractAction)3 AbstractActionTestSupport (com.sequenceiq.flow.core.AbstractActionTestSupport)3 Test (org.junit.jupiter.api.Test)3 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)2 DatalakeDatabaseRestoreStartEvent (com.sequenceiq.datalake.flow.dr.restore.event.DatalakeDatabaseRestoreStartEvent)2 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)2 FlowChainLog (com.sequenceiq.flow.domain.FlowChainLog)2 FlowLog (com.sequenceiq.flow.domain.FlowLog)2 SdxRestoreResponse (com.sequenceiq.sdx.api.model.SdxRestoreResponse)2 HashMap (java.util.HashMap)2 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 SdxEvent (com.sequenceiq.datalake.flow.SdxEvent)1 DatalakeResizeFlowEventChainFactory (com.sequenceiq.datalake.flow.chain.DatalakeResizeFlowEventChainFactory)1 DatalakeUpgradeFlowEventChainFactory (com.sequenceiq.datalake.flow.chain.DatalakeUpgradeFlowEventChainFactory)1 SdxDeleteStartEvent (com.sequenceiq.datalake.flow.delete.event.SdxDeleteStartEvent)1