Search in sources :

Example 6 with CmDiagnosticsParameters

use of com.sequenceiq.common.model.diagnostics.CmDiagnosticsParameters 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 7 with CmDiagnosticsParameters

use of com.sequenceiq.common.model.diagnostics.CmDiagnosticsParameters in project cloudbreak by hortonworks.

the class DiagnosticsService method startCmDiagnostics.

public FlowIdentifier startCmDiagnostics(BaseCmDiagnosticsCollectionRequest request, String stackCrn, String userCrn) {
    Stack stack = stackService.getByCrn(stackCrn);
    MDCBuilder.buildMdcContext(stack);
    LOGGER.debug("Starting CM based diagnostics collection for Stack. Crn: '{}'", stack.getResourceCrn());
    Telemetry telemetry = componentConfigProviderService.getTelemetry(stack.getId());
    diagnosticsCollectionValidator.validate(request, stack, telemetry);
    CmDiagnosticsParameters parameters = cmDiagnosticsDataToParameterConverter.convert(request, telemetry, stack.getName(), stack.getRegion());
    CmDiagnosticsCollectionEvent diagnosticsCollectionEvent = CmDiagnosticsCollectionEvent.builder().withAccepted(new Promise<>()).withResourceId(stack.getId()).withResourceCrn(stack.getResourceCrn()).withSelector(CmDiagnosticsCollectionStateSelectors.START_CM_DIAGNOSTICS_INIT_EVENT.selector()).withParameters(parameters).build();
    return reactorNotifier.notify(diagnosticsCollectionEvent, getFlowHeaders(userCrn));
}
Also used : Promise(reactor.rx.Promise) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) CmDiagnosticsParameters(com.sequenceiq.common.model.diagnostics.CmDiagnosticsParameters) CmDiagnosticsCollectionEvent(com.sequenceiq.cloudbreak.core.flow2.cmdiagnostics.event.CmDiagnosticsCollectionEvent) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Aggregations

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