Search in sources :

Example 36 with CommonContext

use of com.sequenceiq.flow.core.CommonContext in project cloudbreak by hortonworks.

the class EnvDeleteActions method s3GuardTableDeleteAction.

@Bean(name = "S3GUARD_TABLE_DELETE_STARTED_STATE")
public Action<?, ?> s3GuardTableDeleteAction() {
    return new AbstractEnvDeleteAction<>(EnvDeleteEvent.class) {

        @Override
        protected void doExecute(CommonContext context, EnvDeleteEvent payload, Map<Object, Object> variables) {
            EnvironmentDto envDto = environmentStatusUpdateService.updateEnvironmentStatusAndNotify(context, payload, EnvironmentStatus.S3GUARD_TABLE_DELETE_IN_PROGRESS, ResourceEvent.ENVIRONMENT_S3GUARD_TABLE_DELETION_STARTED, EnvDeleteState.S3GUARD_TABLE_DELETE_STARTED_STATE);
            EnvironmentDeletionDto environmentDeletionDto = EnvironmentDeletionDto.builder().withEnvironmentDto(envDto).withForceDelete(payload.isForceDelete()).withId(payload.getResourceId()).build();
            sendEvent(context, DELETE_S3GUARD_TABLE_EVENT.selector(), environmentDeletionDto);
        }
    };
}
Also used : EnvDeleteEvent(com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteEvent) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) CommonContext(com.sequenceiq.flow.core.CommonContext) Map(java.util.Map) EnvironmentDeletionDto(com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto) Bean(org.springframework.context.annotation.Bean)

Example 37 with CommonContext

use of com.sequenceiq.flow.core.CommonContext in project cloudbreak by hortonworks.

the class SleepFlow method sleepFailed.

@Bean("SLEEP_FAILED_STATE")
public Action<?, ?> sleepFailed() {
    return new AbstractAction<>(SleepFailedEvent.class) {

        @Override
        protected CommonContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, SleepFailedEvent payload) {
            return new CommonContext(flowParameters);
        }

        @Override
        protected void doExecute(CommonContext context, SleepFailedEvent payload, Map<Object, Object> variables) throws Exception {
            LOGGER.info("Sleep fail handled!");
            Flow flow = getFlow(context.getFlowId());
            flow.setFlowFailed(new Exception(payload.getReason()));
            sendEvent(context, SleepEvent.SLEEP_FAIL_HANDLED_EVENT.selector(), payload);
        }

        @Override
        protected Object getFailurePayload(SleepFailedEvent payload, Optional<CommonContext> flowContext, Exception ex) {
            return null;
        }
    };
}
Also used : FlowParameters(com.sequenceiq.flow.core.FlowParameters) Optional(java.util.Optional) SleepFailedEvent(com.sequenceiq.flow.component.sleep.event.SleepFailedEvent) CommonContext(com.sequenceiq.flow.core.CommonContext) StateContext(org.springframework.statemachine.StateContext) AbstractAction(com.sequenceiq.flow.core.AbstractAction) Map(java.util.Map) Flow(com.sequenceiq.flow.core.Flow) Bean(org.springframework.context.annotation.Bean)

Example 38 with CommonContext

use of com.sequenceiq.flow.core.CommonContext in project cloudbreak by hortonworks.

the class DiagnosticsCollectionActions method diagnosticsInitAction.

@Bean(name = "DIAGNOSTICS_INIT_STATE")
public Action<?, ?> diagnosticsInitAction() {
    return new AbstractDiagnosticsCollectionActions<>(DiagnosticsCollectionEvent.class) {

        @Override
        protected void doExecute(CommonContext context, DiagnosticsCollectionEvent payload, Map<Object, Object> variables) {
            String resourceCrn = payload.getResourceCrn();
            LOGGER.debug("Flow entered into DIAGNOSTICS_INIT_STATE. resourceCrn: '{}'", resourceCrn);
            DiagnosticsCollectionEvent event = DiagnosticsCollectionEvent.builder().withResourceId(payload.getResourceId()).withResourceCrn(resourceCrn).withSelector(DiagnosticsCollectionHandlerSelectors.INIT_DIAGNOSTICS_EVENT.selector()).withParameters(payload.getParameters()).build();
            sendEvent(context, event);
        }
    };
}
Also used : CommonContext(com.sequenceiq.flow.core.CommonContext) DiagnosticsCollectionEvent(com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 39 with CommonContext

use of com.sequenceiq.flow.core.CommonContext in project cloudbreak by hortonworks.

the class DiagnosticsCollectionActions method diagnosticsUploadAction.

@Bean(name = "DIAGNOSTICS_UPLOAD_STATE")
public Action<?, ?> diagnosticsUploadAction() {
    return new AbstractDiagnosticsCollectionActions<>(DiagnosticsCollectionEvent.class) {

        @Override
        protected void doExecute(CommonContext context, DiagnosticsCollectionEvent payload, Map<Object, Object> variables) {
            String resourceCrn = payload.getResourceCrn();
            LOGGER.debug("Flow entered into DIAGNOSTICS_UPLOAD_STATE. resourceCrn: '{}'", resourceCrn);
            DiagnosticsCollectionEvent event = DiagnosticsCollectionEvent.builder().withResourceId(payload.getResourceId()).withResourceCrn(payload.getResourceCrn()).withSelector(DiagnosticsCollectionHandlerSelectors.UPLOAD_DIAGNOSTICS_EVENT.selector()).withParameters(payload.getParameters()).build();
            sendEvent(context, event);
        }
    };
}
Also used : CommonContext(com.sequenceiq.flow.core.CommonContext) DiagnosticsCollectionEvent(com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 40 with CommonContext

use of com.sequenceiq.flow.core.CommonContext in project cloudbreak by hortonworks.

the class DiagnosticsCollectionActions method diagnosticsCreateMachineUserAction.

@Bean(name = "DIAGNOSTICS_ENSURE_MACHINE_USER_STATE")
public Action<?, ?> diagnosticsCreateMachineUserAction() {
    return new AbstractDiagnosticsCollectionActions<>(DiagnosticsCollectionEvent.class) {

        @Override
        protected void doExecute(CommonContext context, DiagnosticsCollectionEvent payload, Map<Object, Object> variables) {
            String resourceCrn = payload.getResourceCrn();
            LOGGER.debug("Flow entered into ENSURE_MACHINE_USER_EVENT. resourceCrn: '{}'", resourceCrn);
            DiagnosticsCollectionEvent event = DiagnosticsCollectionEvent.builder().withResourceId(payload.getResourceId()).withResourceCrn(payload.getResourceCrn()).withSelector(DiagnosticsCollectionHandlerSelectors.ENSURE_MACHINE_USER_EVENT.selector()).withParameters(payload.getParameters()).build();
            sendEvent(context, event);
        }
    };
}
Also used : CommonContext(com.sequenceiq.flow.core.CommonContext) DiagnosticsCollectionEvent(com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Aggregations

CommonContext (com.sequenceiq.flow.core.CommonContext)84 Map (java.util.Map)83 Bean (org.springframework.context.annotation.Bean)83 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)46 DiagnosticsCollectionEvent (com.sequenceiq.cloudbreak.core.flow2.diagnostics.event.DiagnosticsCollectionEvent)13 DiagnosticsCollectionEvent (com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent)13 EnvironmentStatus (com.sequenceiq.environment.environment.EnvironmentStatus)12 EnvironmentDeletionDto (com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto)12 EnvDeleteEvent (com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteEvent)12 ResourceEvent (com.sequenceiq.cloudbreak.event.ResourceEvent)11 EnvCreationEvent (com.sequenceiq.environment.environment.flow.creation.event.EnvCreationEvent)7 EnvCreationFailureEvent (com.sequenceiq.environment.environment.flow.creation.event.EnvCreationFailureEvent)7 CmDiagnosticsCollectionEvent (com.sequenceiq.cloudbreak.core.flow2.cmdiagnostics.event.CmDiagnosticsCollectionEvent)6 UpgradeCcmEvent (com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent)6 ResourceCrnPayload (com.sequenceiq.cloudbreak.common.event.ResourceCrnPayload)5 Environment (com.sequenceiq.environment.environment.domain.Environment)4 EnvironmentStartDto (com.sequenceiq.environment.environment.dto.EnvironmentStartDto)4 EnvStartEvent (com.sequenceiq.environment.environment.flow.start.event.EnvStartEvent)4 DiagnosticParameters (com.sequenceiq.common.model.diagnostics.DiagnosticParameters)3 EnvStopEvent (com.sequenceiq.environment.environment.flow.stop.event.EnvStopEvent)3