use of com.sequenceiq.cloudbreak.datalakedr.model.DatalakeRestoreStatusResponse in project cloudbreak by hortonworks.
the class DatalakeRestoreActions method triggerDatalakeRestore.
@Bean(name = "DATALAKE_TRIGGERING_RESTORE_STATE")
public Action<?, ?> triggerDatalakeRestore() {
return new AbstractSdxAction<>(DatalakeTriggerRestoreEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, DatalakeTriggerRestoreEvent payload) {
// When SDX is created as part of re-size flow chain, SDX in payload will not have the correct ID.
Optional<FlowLog> lastFlowLog = flowLogService.getLastFlowLog(flowParameters.getFlowId());
if (lastFlowLog.isPresent()) {
SdxContext sdxContext;
Optional<FlowChainLog> flowChainLog = flowChainLogService.findFirstByFlowChainIdOrderByCreatedDesc(lastFlowLog.get().getFlowChainId());
if (flowChainLog.isPresent() && flowChainLog.get().getFlowChainType().equals(DatalakeResizeFlowEventChainFactory.class.getSimpleName())) {
SdxCluster sdxCluster = sdxService.getByNameInAccount(payload.getUserId(), payload.getSdxName());
LOGGER.info("Updating the Sdx-id in context from {} to {}", payload.getResourceId(), sdxCluster.getId());
payload.getDrStatus().setSdxClusterId(sdxCluster.getId());
sdxContext = SdxContext.from(flowParameters, payload);
sdxContext.setSdxId(sdxCluster.getId());
return sdxContext;
}
}
return SdxContext.from(flowParameters, payload);
}
@Override
protected void prepareExecution(DatalakeTriggerRestoreEvent payload, Map<Object, Object> variables) {
super.prepareExecution(payload, variables);
}
@Override
protected void doExecute(SdxContext context, DatalakeTriggerRestoreEvent payload, Map<Object, Object> variables) {
DatalakeRestoreStatusResponse restoreStatusResponse = sdxBackupRestoreService.triggerDatalakeRestore(context.getSdxId(), payload.getBackupId(), payload.getBackupLocationOverride(), payload.getUserId());
variables.put(RESTORE_ID, restoreStatusResponse.getRestoreId());
variables.put(BACKUP_ID, restoreStatusResponse.getBackupId());
variables.put(OPERATION_ID, restoreStatusResponse.getRestoreId());
payload.getDrStatus().setOperationId(restoreStatusResponse.getRestoreId());
if (!restoreStatusResponse.failed()) {
sendEvent(context, DatalakeDatabaseRestoreStartEvent.from(payload, context.getSdxId(), restoreStatusResponse.getBackupId(), restoreStatusResponse.getRestoreId()));
} else {
LOGGER.error("Datalake restore has failed for {} ", context.getSdxId());
sendEvent(context, DATALAKE_RESTORE_FAILED_EVENT.event(), payload);
}
}
@Override
protected Object getFailurePayload(DatalakeTriggerRestoreEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return DatalakeRestoreFailedEvent.from(flowContext, payload, ex);
}
};
}
use of com.sequenceiq.cloudbreak.datalakedr.model.DatalakeRestoreStatusResponse in project cloudbreak by hortonworks.
the class DatalakeRestoreActionsTest method testGetNewSdxIdForResizeDoExecute.
@Test
public void testGetNewSdxIdForResizeDoExecute() throws Exception {
when(sdxBackupRestoreService.triggerDatalakeRestore(eq(NEW_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(), NEW_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(NEW_SDX_ID, captorValue.getResourceId());
}
use of com.sequenceiq.cloudbreak.datalakedr.model.DatalakeRestoreStatusResponse in project cloudbreak by hortonworks.
the class GrpcStatusResponseToDatalakeBackupStatusResponseConverterTest method testFailedSolrRestoreSameFailureReasonWithDeleteDifferentReasons.
@Test
public void testFailedSolrRestoreSameFailureReasonWithDeleteDifferentReasons() {
datalakeDRProto.SolrBackupRestoreState.Builder solrBuilder = datalakeDRProto.SolrBackupRestoreState.newBuilder().setEdgeIndexCollection(createStatus(FAILED_STATE, FAILURE_REASON)).setFulltextIndexCollection(createStatus(FAILED_STATE, FAILURE_REASON2)).setRangerAuditsCollection(createStatus(FAILED_STATE, FAILURE_REASON)).setVertexIndexCollection(createStatus(FAILED_STATE, FAILURE_REASON2)).setEdgeIndexCollectionDelete(createStatus(FAILED_STATE, FAILURE_REASON2)).setFulltextIndexCollectionDelete(createStatus(FAILED_STATE, FAILURE_REASON)).setRangerAuditsCollectionDelete(createStatus(FAILED_STATE, FAILURE_REASON2)).setVertexIndexCollectionDelete(createStatus(FAILED_STATE, FAILURE_REASON));
datalakeDRProto.InternalBackupRestoreState.Builder stateBuilder = datalakeDRProto.InternalBackupRestoreState.newBuilder().setSolr(solrBuilder);
datalakeDRProto.RestoreDatalakeStatusResponse.Builder builder = datalakeDRProto.RestoreDatalakeStatusResponse.newBuilder().setOverallState(FAILED_STATE).setOperationStates(stateBuilder);
String expectedFailure = getFailureString(OperationEnum.SOLR_EDGE_INDEX.description(), FAILURE_REASON) + ", " + getFailureString(OperationEnum.SOLR_FULLTEXT_INDEX.description(), FAILURE_REASON2) + ", " + getFailureString(OperationEnum.SOLR_RANGER_AUDITS.description(), FAILURE_REASON) + ", " + getFailureString(OperationEnum.SOLR_VERTEX_INDEX.description(), FAILURE_REASON2) + ", " + getFailureString(OperationEnum.SOLR_EDGE_INDEX_DELETE.description(), FAILURE_REASON2) + ", " + getFailureString(OperationEnum.SOLR_FULLTEXT_INDEX_DELETE.description(), FAILURE_REASON) + ", " + getFailureString(OperationEnum.SOLR_RANGER_AUDITS_DELETE.description(), FAILURE_REASON2) + ", " + getFailureString(OperationEnum.SOLR_VERTEX_INDEX_DELETE.description(), FAILURE_REASON);
DatalakeRestoreStatusResponse response = underTest.convert(builder.build());
assertEquals(DatalakeRestoreStatusResponse.State.FAILED, response.getState());
assertEquals(expectedFailure, response.getFailureReason());
assert response.isComplete();
}
use of com.sequenceiq.cloudbreak.datalakedr.model.DatalakeRestoreStatusResponse in project cloudbreak by hortonworks.
the class GrpcStatusResponseToDatalakeBackupStatusResponseConverterTest method testFailedSolrRestoreSameFailureReason.
@Test
public void testFailedSolrRestoreSameFailureReason() {
datalakeDRProto.SolrBackupRestoreState.Builder solrBuilder = datalakeDRProto.SolrBackupRestoreState.newBuilder().setEdgeIndexCollection(createStatus(FAILED_STATE, FAILURE_REASON)).setFulltextIndexCollection(createStatus(FAILED_STATE, FAILURE_REASON)).setRangerAuditsCollection(createStatus(FAILED_STATE, FAILURE_REASON)).setVertexIndexCollection(createStatus(FAILED_STATE, FAILURE_REASON));
datalakeDRProto.InternalBackupRestoreState.Builder stateBuilder = datalakeDRProto.InternalBackupRestoreState.newBuilder().setSolr(solrBuilder);
datalakeDRProto.RestoreDatalakeStatusResponse.Builder builder = datalakeDRProto.RestoreDatalakeStatusResponse.newBuilder().setOverallState(FAILED_STATE).setOperationStates(stateBuilder);
String expectedFailure = getFailureString(OperationEnum.SOLR.description(), FAILURE_REASON);
DatalakeRestoreStatusResponse response = underTest.convert(builder.build());
assertEquals(DatalakeRestoreStatusResponse.State.FAILED, response.getState());
assertEquals(expectedFailure, response.getFailureReason());
assert response.isComplete();
}
use of com.sequenceiq.cloudbreak.datalakedr.model.DatalakeRestoreStatusResponse in project cloudbreak by hortonworks.
the class GrpcStatusResponseToDatalakeBackupStatusResponseConverterTest method testFailedDatabaseRestore.
@Test
public void testFailedDatabaseRestore() {
datalakeDRProto.DatabaseBackupRestoreState.Builder databaseBuilder = datalakeDRProto.DatabaseBackupRestoreState.newBuilder().setDatabase(createStatus(FAILED_STATE, FAILURE_REASON));
datalakeDRProto.InternalBackupRestoreState.Builder stateBuilder = datalakeDRProto.InternalBackupRestoreState.newBuilder().setDatabase(databaseBuilder);
datalakeDRProto.RestoreDatalakeStatusResponse.Builder builder = datalakeDRProto.RestoreDatalakeStatusResponse.newBuilder().setOverallState(FAILED_STATE).setOperationStates(stateBuilder);
String expectedFailure = getFailureString(OperationEnum.DATABASE.description(), FAILURE_REASON);
DatalakeRestoreStatusResponse response = underTest.convert(builder.build());
assertEquals(DatalakeRestoreStatusResponse.State.FAILED, response.getState());
assertEquals(expectedFailure, response.getFailureReason());
assert response.isComplete();
}
Aggregations