Search in sources :

Example 11 with CommonContext

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

the class CmDiagnosticsCollectionActions method failedAction.

@Bean(name = "CM_DIAGNOSTICS_COLLECTION_FAILED_STATE")
public Action<?, ?> failedAction() {
    return new CmDiagnosticsCollectionActions.AbstractCmDiagnosticsCollectionActions<>(CmDiagnosticsCollectionFailureEvent.class) {

        @Override
        protected void doExecute(CommonContext context, CmDiagnosticsCollectionFailureEvent payload, Map<Object, Object> variables) {
            Long resourceId = payload.getResourceId();
            String resourceCrn = payload.getResourceCrn();
            LOGGER.debug("Flow entered into CM_DIAGNOSTICS_COLLECTION_FAILED_STATE. resourceCrn: '{}'", resourceCrn);
            cloudbreakEventService.fireCloudbreakEvent(resourceId, UPDATE_FAILED.name(), ResourceEvent.STACK_CM_DIAGNOSTICS_COLLECTION_FAILED, List.of(payload.getException().getMessage()));
            InMemoryStateStore.deleteStack(resourceId);
            CmDiagnosticsCollectionEvent event = CmDiagnosticsCollectionEvent.builder().withResourceId(resourceId).withResourceCrn(payload.getResourceCrn()).withSelector(CmDiagnosticsCollectionStateSelectors.HANDLED_FAILED_CM_DIAGNOSTICS_COLLECTION_EVENT.selector()).withParameters(payload.getParameters()).build();
            sendEvent(context, event);
        }
    };
}
Also used : CommonContext(com.sequenceiq.flow.core.CommonContext) Map(java.util.Map) CmDiagnosticsCollectionEvent(com.sequenceiq.cloudbreak.core.flow2.cmdiagnostics.event.CmDiagnosticsCollectionEvent) CmDiagnosticsCollectionFailureEvent(com.sequenceiq.cloudbreak.core.flow2.cmdiagnostics.event.CmDiagnosticsCollectionFailureEvent) Bean(org.springframework.context.annotation.Bean)

Example 12 with CommonContext

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

the class CmDiagnosticsCollectionActions method diagnosticsCleanupAction.

@Bean(name = "CM_DIAGNOSTICS_CLEANUP_STATE")
public Action<?, ?> diagnosticsCleanupAction() {
    return new CmDiagnosticsCollectionActions.AbstractCmDiagnosticsCollectionActions<>(CmDiagnosticsCollectionEvent.class) {

        @Override
        protected void doExecute(CommonContext context, CmDiagnosticsCollectionEvent payload, Map<Object, Object> variables) {
            Long resourceId = payload.getResourceId();
            String resourceCrn = payload.getResourceCrn();
            LOGGER.debug("Flow entered into CM_DIAGNOSTICS_CLEANUP_STATE. resourceCrn: '{}'", resourceCrn);
            cloudbreakEventService.fireCloudbreakEvent(resourceId, UPDATE_IN_PROGRESS.name(), ResourceEvent.STACK_CM_DIAGNOSTICS_CLEANUP_RUNNING);
            CmDiagnosticsCollectionEvent event = CmDiagnosticsCollectionEvent.builder().withResourceId(resourceId).withResourceCrn(payload.getResourceCrn()).withSelector(CmDiagnosticsCollectionHandlerSelectors.CLEANUP_CM_DIAGNOSTICS_EVENT.selector()).withParameters(payload.getParameters()).build();
            sendEvent(context, event);
        }
    };
}
Also used : CommonContext(com.sequenceiq.flow.core.CommonContext) CmDiagnosticsCollectionEvent(com.sequenceiq.cloudbreak.core.flow2.cmdiagnostics.event.CmDiagnosticsCollectionEvent) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 13 with CommonContext

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

the class CmDiagnosticsCollectionActions method diagnosticsInitAction.

@Bean(name = "CM_DIAGNOSTICS_INIT_STATE")
public Action<?, ?> diagnosticsInitAction() {
    return new CmDiagnosticsCollectionActions.AbstractCmDiagnosticsCollectionActions<>(CmDiagnosticsCollectionEvent.class) {

        @Override
        protected void doExecute(CommonContext context, CmDiagnosticsCollectionEvent payload, Map<Object, Object> variables) {
            Long resourceId = payload.getResourceId();
            String resourceCrn = payload.getResourceCrn();
            LOGGER.debug("Flow entered into CM_DIAGNOSTICS_INIT_STATE. resourceCrn: '{}'", resourceCrn);
            InMemoryStateStore.putStack(resourceId, PollGroup.POLLABLE);
            cloudbreakEventService.fireCloudbreakEvent(resourceId, UPDATE_IN_PROGRESS.name(), ResourceEvent.STACK_CM_DIAGNOSTICS_INIT_RUNNING);
            CmDiagnosticsCollectionEvent event = CmDiagnosticsCollectionEvent.builder().withResourceId(resourceId).withResourceCrn(resourceCrn).withSelector(CmDiagnosticsCollectionHandlerSelectors.INIT_CM_DIAGNOSTICS_EVENT.selector()).withParameters(payload.getParameters()).build();
            sendEvent(context, event);
        }
    };
}
Also used : CommonContext(com.sequenceiq.flow.core.CommonContext) CmDiagnosticsCollectionEvent(com.sequenceiq.cloudbreak.core.flow2.cmdiagnostics.event.CmDiagnosticsCollectionEvent) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 14 with CommonContext

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

the class CmDiagnosticsCollectionActions method diagnosticsCollectionAction.

@Bean(name = "CM_DIAGNOSTICS_COLLECTION_STATE")
public Action<?, ?> diagnosticsCollectionAction() {
    return new CmDiagnosticsCollectionActions.AbstractCmDiagnosticsCollectionActions<>(CmDiagnosticsCollectionEvent.class) {

        @Override
        protected void doExecute(CommonContext context, CmDiagnosticsCollectionEvent payload, Map<Object, Object> variables) {
            Long resourceId = payload.getResourceId();
            String resourceCrn = payload.getResourceCrn();
            LOGGER.debug("Flow entered into CM_DIAGNOSTICS_COLLECTION_STATE. resourceCrn: '{}'", resourceCrn);
            cloudbreakEventService.fireCloudbreakEvent(resourceId, UPDATE_IN_PROGRESS.name(), ResourceEvent.STACK_CM_DIAGNOSTICS_COLLECTION_RUNNING, List.of(payload.getParameters().getDestination().toString()));
            CmDiagnosticsCollectionEvent event = CmDiagnosticsCollectionEvent.builder().withResourceId(resourceId).withResourceCrn(payload.getResourceCrn()).withSelector(CmDiagnosticsCollectionHandlerSelectors.COLLECT_CM_DIAGNOSTICS_EVENT.selector()).withParameters(payload.getParameters()).build();
            sendEvent(context, event);
        }
    };
}
Also used : CommonContext(com.sequenceiq.flow.core.CommonContext) CmDiagnosticsCollectionEvent(com.sequenceiq.cloudbreak.core.flow2.cmdiagnostics.event.CmDiagnosticsCollectionEvent) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 15 with CommonContext

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

the class EnvStopActions method finishedAction.

@Bean(name = "ENV_STOP_FINISHED_STATE")
public Action<?, ?> finishedAction() {
    return new AbstractEnvStopAction<>(ResourceCrnPayload.class) {

        @Override
        protected void doExecute(CommonContext context, ResourceCrnPayload payload, Map<Object, Object> variables) {
            EnvironmentDto environmentDto = environmentStatusUpdateService.updateEnvironmentStatusAndNotify(context, payload, EnvironmentStatus.ENV_STOPPED, ResourceEvent.ENVIRONMENT_STOPPED, EnvStopState.ENV_STOP_FINISHED_STATE);
            metricService.incrementMetricCounter(MetricType.ENV_STOP_FINISHED, environmentDto);
            LOGGER.info("Flow entered into ENV_STOP_FINISHED_STATE");
            sendEvent(context, FINALIZE_ENV_STOP_EVENT.event(), payload);
        }
    };
}
Also used : EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) CommonContext(com.sequenceiq.flow.core.CommonContext) ResourceCrnPayload(com.sequenceiq.cloudbreak.common.event.ResourceCrnPayload) 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