Search in sources :

Example 6 with CmDiagnosticsCollectionEvent

use of com.sequenceiq.cloudbreak.core.flow2.cmdiagnostics.event.CmDiagnosticsCollectionEvent 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 7 with CmDiagnosticsCollectionEvent

use of com.sequenceiq.cloudbreak.core.flow2.cmdiagnostics.event.CmDiagnosticsCollectionEvent 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 8 with CmDiagnosticsCollectionEvent

use of com.sequenceiq.cloudbreak.core.flow2.cmdiagnostics.event.CmDiagnosticsCollectionEvent in project cloudbreak by hortonworks.

the class CmDiagnosticsCollectionHandler method accept.

@Override
public void accept(Event<CmDiagnosticsCollectionEvent> event) {
    CmDiagnosticsCollectionEvent data = event.getData();
    Long resourceId = data.getResourceId();
    String resourceCrn = data.getResourceCrn();
    CmDiagnosticsParameters parameters = data.getParameters();
    Map<String, Object> parameterMap = parameters.toMap();
    try {
        LOGGER.debug("CM based diagnostics collection started. resourceCrn: '{}', parameters: '{}'", resourceCrn, parameterMap);
        clusterDiagnosticsService.collectDiagnostics(resourceId, parameters);
        CmDiagnosticsCollectionEvent diagnosticsCollectionEvent = CmDiagnosticsCollectionEvent.builder().withResourceCrn(resourceCrn).withResourceId(resourceId).withSelector(START_CM_DIAGNOSTICS_UPLOAD_EVENT.selector()).withParameters(parameters).build();
        eventSender().sendEvent(diagnosticsCollectionEvent, event.getHeaders());
    } catch (Exception e) {
        LOGGER.debug("CM based diagnostics collection failed. resourceCrn: '{}', parameters: '{}'.", resourceCrn, parameterMap, e);
        CmDiagnosticsCollectionFailureEvent failureEvent = new CmDiagnosticsCollectionFailureEvent(resourceId, e, resourceCrn, parameters);
        eventBus.notify(failureEvent.selector(), new Event<>(event.getHeaders(), failureEvent));
    }
}
Also used : CmDiagnosticsCollectionFailureEvent(com.sequenceiq.cloudbreak.core.flow2.cmdiagnostics.event.CmDiagnosticsCollectionFailureEvent) CmDiagnosticsCollectionEvent(com.sequenceiq.cloudbreak.core.flow2.cmdiagnostics.event.CmDiagnosticsCollectionEvent) Event(reactor.bus.Event) CmDiagnosticsCollectionEvent(com.sequenceiq.cloudbreak.core.flow2.cmdiagnostics.event.CmDiagnosticsCollectionEvent) CmDiagnosticsParameters(com.sequenceiq.common.model.diagnostics.CmDiagnosticsParameters) CmDiagnosticsCollectionFailureEvent(com.sequenceiq.cloudbreak.core.flow2.cmdiagnostics.event.CmDiagnosticsCollectionFailureEvent)

Example 9 with CmDiagnosticsCollectionEvent

use of com.sequenceiq.cloudbreak.core.flow2.cmdiagnostics.event.CmDiagnosticsCollectionEvent in project cloudbreak by hortonworks.

the class CmDiagnosticsUploadHandler method accept.

@Override
public void accept(Event<CmDiagnosticsCollectionEvent> event) {
    CmDiagnosticsCollectionEvent data = event.getData();
    Long resourceId = data.getResourceId();
    String resourceCrn = data.getResourceCrn();
    CmDiagnosticsParameters parameters = data.getParameters();
    Map<String, Object> parameterMap = parameters.toMap();
    try {
        LOGGER.debug("CM based diagnostics upload started. resourceCrn: '{}', parameters: '{}'", resourceCrn, parameterMap);
        if (DiagnosticsDestination.SUPPORT.equals(parameters.getDestination())) {
            LOGGER.debug("CM based diagnostics uses SUPPORT destination, no support specific upload step yet.");
        } else {
            cmDiagnosticsFlowService.upload(resourceId, parameterMap, new HashSet<>());
        }
        CmDiagnosticsCollectionEvent diagnosticsCollectionEvent = CmDiagnosticsCollectionEvent.builder().withResourceCrn(resourceCrn).withResourceId(resourceId).withSelector(START_CM_DIAGNOSTICS_CLEANUP_EVENT.selector()).withParameters(parameters).build();
        eventSender().sendEvent(diagnosticsCollectionEvent, event.getHeaders());
    } catch (Exception e) {
        LOGGER.debug("CM based diagnostics upload failed. resourceCrn: '{}', parameters: '{}'.", resourceCrn, parameterMap, e);
        CmDiagnosticsCollectionFailureEvent failureEvent = new CmDiagnosticsCollectionFailureEvent(resourceId, e, resourceCrn, parameters);
        eventBus.notify(failureEvent.selector(), new Event<>(event.getHeaders(), failureEvent));
    }
}
Also used : CmDiagnosticsCollectionFailureEvent(com.sequenceiq.cloudbreak.core.flow2.cmdiagnostics.event.CmDiagnosticsCollectionFailureEvent) CmDiagnosticsCollectionEvent(com.sequenceiq.cloudbreak.core.flow2.cmdiagnostics.event.CmDiagnosticsCollectionEvent) Event(reactor.bus.Event) CmDiagnosticsCollectionEvent(com.sequenceiq.cloudbreak.core.flow2.cmdiagnostics.event.CmDiagnosticsCollectionEvent) CmDiagnosticsParameters(com.sequenceiq.common.model.diagnostics.CmDiagnosticsParameters) CmDiagnosticsCollectionFailureEvent(com.sequenceiq.cloudbreak.core.flow2.cmdiagnostics.event.CmDiagnosticsCollectionFailureEvent)

Example 10 with CmDiagnosticsCollectionEvent

use of com.sequenceiq.cloudbreak.core.flow2.cmdiagnostics.event.CmDiagnosticsCollectionEvent in project cloudbreak by hortonworks.

the class CmDiagnosticsCollectionActions method diagnosticsCollectionFinishedAction.

@Bean(name = "CM_DIAGNOSTICS_COLLECTION_FINISHED_STATE")
public Action<?, ?> diagnosticsCollectionFinishedAction() {
    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_FINISHED_STATE. resourceCrn: '{}'", resourceCrn);
            cloudbreakEventService.fireCloudbreakEvent(resourceId, AVAILABLE.name(), ResourceEvent.STACK_CM_DIAGNOSTICS_COLLECTION_FINISHED);
            InMemoryStateStore.deleteStack(resourceId);
            CmDiagnosticsCollectionEvent event = CmDiagnosticsCollectionEvent.builder().withResourceId(resourceId).withResourceCrn(payload.getResourceCrn()).withSelector(CmDiagnosticsCollectionStateSelectors.FINALIZE_CM_DIAGNOSTICS_COLLECTION_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)

Aggregations

CmDiagnosticsCollectionEvent (com.sequenceiq.cloudbreak.core.flow2.cmdiagnostics.event.CmDiagnosticsCollectionEvent)11 CmDiagnosticsParameters (com.sequenceiq.common.model.diagnostics.CmDiagnosticsParameters)6 CommonContext (com.sequenceiq.flow.core.CommonContext)6 Map (java.util.Map)6 Bean (org.springframework.context.annotation.Bean)6 CmDiagnosticsCollectionFailureEvent (com.sequenceiq.cloudbreak.core.flow2.cmdiagnostics.event.CmDiagnosticsCollectionFailureEvent)5 Event (reactor.bus.Event)4 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 Telemetry (com.sequenceiq.common.api.telemetry.model.Telemetry)1 Promise (reactor.rx.Promise)1