Search in sources :

Example 1 with SdxCmDiagnosticsCollectionEvent

use of com.sequenceiq.datalake.flow.diagnostics.event.SdxCmDiagnosticsCollectionEvent in project cloudbreak by hortonworks.

the class DiagnosticsService method collectCmDiagnostics.

public FlowIdentifier collectCmDiagnostics(CmDiagnosticsCollectionRequest request) {
    String userId = ThreadBasedUserCrnProvider.getUserCrn();
    SdxCluster cluster = sdxService.getByCrn(userId, request.getStackCrn());
    StackV4Response stackV4Response = sdxService.getDetail(cluster.getClusterName(), new HashSet<>(), cluster.getAccountId());
    diagnosticsCollectionValidator.validate(request, stackV4Response);
    Map<String, Object> properties = diagnosticsParamsConverter.convertFromCmRequest(request);
    SdxCmDiagnosticsCollectionEvent event = new SdxCmDiagnosticsCollectionEvent(cluster.getId(), userId, properties, null);
    FlowIdentifier flowIdentifier = sdxReactorFlowManager.triggerCmDiagnosticsCollection(event, cluster.getClusterName());
    LOGGER.debug("Start CM based diagnostics collection with flow pollable identifier: {}", flowIdentifier.getPollableId());
    return flowIdentifier;
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) SdxCmDiagnosticsCollectionEvent(com.sequenceiq.datalake.flow.diagnostics.event.SdxCmDiagnosticsCollectionEvent) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier)

Example 2 with SdxCmDiagnosticsCollectionEvent

use of com.sequenceiq.datalake.flow.diagnostics.event.SdxCmDiagnosticsCollectionEvent in project cloudbreak by hortonworks.

the class SdxCmDiagnosticsActions method startCmDiagnosticsCollection.

@Bean(name = "CM_DIAGNOSTICS_COLLECTION_START_STATE")
public Action<?, ?> startCmDiagnosticsCollection() {
    return new AbstractSdxAction<>(SdxCmDiagnosticsCollectionEvent.class) {

        @Override
        protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, SdxCmDiagnosticsCollectionEvent payload) {
            return SdxContext.from(flowParameters, payload);
        }

        @Override
        protected void doExecute(SdxContext context, SdxCmDiagnosticsCollectionEvent payload, Map<Object, Object> variables) {
            LOGGER.debug("Start CM based diagnostics collection for sdx cluster with id: {}", context.getSdxId());
            FlowIdentifier flowIdentifier = diagnosticsFlowService.startCmDiagnosticsCollection(payload.getProperties());
            SdxCmDiagnosticsCollectionEvent event = new SdxCmDiagnosticsCollectionEvent(payload.getResourceId(), payload.getUserId(), payload.getProperties(), flowIdentifier);
            sendEvent(context, SDX_CM_DIAGNOSTICS_COLLECTION_IN_PROGRESS_EVENT.event(), event);
        }

        @Override
        protected Object getFailurePayload(SdxCmDiagnosticsCollectionEvent payload, Optional<SdxContext> flowContext, Exception ex) {
            return SdxCmDiagnosticsFailedEvent.from(payload, ex);
        }
    };
}
Also used : FlowParameters(com.sequenceiq.flow.core.FlowParameters) AbstractSdxAction(com.sequenceiq.datalake.service.AbstractSdxAction) Optional(java.util.Optional) SdxCmDiagnosticsCollectionEvent(com.sequenceiq.datalake.flow.diagnostics.event.SdxCmDiagnosticsCollectionEvent) StateContext(org.springframework.statemachine.StateContext) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) Map(java.util.Map) SdxContext(com.sequenceiq.datalake.flow.SdxContext) Bean(org.springframework.context.annotation.Bean)

Aggregations

SdxCmDiagnosticsCollectionEvent (com.sequenceiq.datalake.flow.diagnostics.event.SdxCmDiagnosticsCollectionEvent)2 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)2 StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)1 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)1 SdxContext (com.sequenceiq.datalake.flow.SdxContext)1 AbstractSdxAction (com.sequenceiq.datalake.service.AbstractSdxAction)1 FlowParameters (com.sequenceiq.flow.core.FlowParameters)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Bean (org.springframework.context.annotation.Bean)1 StateContext (org.springframework.statemachine.StateContext)1