Search in sources :

Example 61 with DiagnosticsCollectionEvent

use of com.sequenceiq.cloudbreak.core.flow2.diagnostics.event.DiagnosticsCollectionEvent in project cloudbreak by hortonworks.

the class DiagnosticsCollectionHandler method executeOperation.

@Override
public Selectable executeOperation(HandlerEvent<DiagnosticsCollectionEvent> event) throws Exception {
    DiagnosticsCollectionEvent data = event.getData();
    Long resourceId = data.getResourceId();
    String resourceCrn = data.getResourceCrn();
    DiagnosticParameters parameters = data.getParameters();
    Map<String, Object> parameterMap = parameters.toMap();
    LOGGER.debug("Diagnostics collection started. resourceCrn: '{}', parameters: '{}'", resourceCrn, parameterMap);
    diagnosticsOperationsService.collect(resourceId, parameters);
    return DiagnosticsCollectionEvent.builder().withResourceCrn(resourceCrn).withResourceId(resourceId).withSelector(START_DIAGNOSTICS_UPLOAD_EVENT.selector()).withParameters(parameters).withHosts(data.getHosts()).withHostGroups(data.getHostGroups()).withExcludeHosts(data.getExcludeHosts()).build();
}
Also used : DiagnosticParameters(com.sequenceiq.common.model.diagnostics.DiagnosticParameters) DiagnosticsCollectionEvent(com.sequenceiq.cloudbreak.core.flow2.diagnostics.event.DiagnosticsCollectionEvent)

Example 62 with DiagnosticsCollectionEvent

use of com.sequenceiq.cloudbreak.core.flow2.diagnostics.event.DiagnosticsCollectionEvent 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)

Example 63 with DiagnosticsCollectionEvent

use of com.sequenceiq.cloudbreak.core.flow2.diagnostics.event.DiagnosticsCollectionEvent in project cloudbreak by hortonworks.

the class DiagnosticsService method startDiagnosticsCollection.

public FlowIdentifier startDiagnosticsCollection(BaseDiagnosticsCollectionRequest request, String stackCrn, String userCrn, String uuid) {
    Stack stack = stackService.getByCrn(stackCrn);
    MDCBuilder.buildMdcContext(stack);
    LOGGER.debug("Starting diagnostics collection for Stack. Crn: '{}'", stack.getResourceCrn());
    Telemetry telemetry = componentConfigProviderService.getTelemetry(stack.getId());
    diagnosticsCollectionValidator.validate(request, stack, telemetry);
    String clusterVersion = version;
    if (stack.getCluster() != null && stack.getCluster().getBlueprint() != null && StringUtils.isNotBlank(stack.getCluster().getBlueprint().getStackVersion())) {
        clusterVersion = stack.getCluster().getBlueprint().getStackVersion();
    }
    String accountId = Crn.fromString(stack.getResourceCrn()).getAccountId();
    boolean useDbusCnameEndpoint = entitlementService.useDataBusCNameEndpointEnabled(accountId);
    String databusEndpoint = dataBusEndpointProvider.getDataBusEndpoint(telemetry.getDatabusEndpoint(), useDbusCnameEndpoint);
    DiagnosticParameters parameters = diagnosticsDataToParameterConverter.convert(request, telemetry, StringUtils.upperCase(stack.getType().getResourceType()), clusterVersion, accountId, stack.getRegion(), databusEndpoint);
    // TODO: use DiagnosticParameters builder for UUID + decrease parameters in the converter above
    parameters.setUuid(uuid);
    DiagnosticsCollectionEvent diagnosticsCollectionEvent = DiagnosticsCollectionEvent.builder().withAccepted(new Promise<>()).withResourceId(stack.getId()).withResourceCrn(stack.getResourceCrn()).withSelector(DiagnosticsCollectionStateSelectors.START_DIAGNOSTICS_SALT_VALIDATION_EVENT.selector()).withParameters(parameters).withHosts(parameters.getHosts()).withHostGroups(parameters.getHostGroups()).withExcludeHosts(parameters.getExcludeHosts()).build();
    return reactorNotifier.notify(diagnosticsCollectionEvent, getFlowHeaders(userCrn));
}
Also used : DiagnosticParameters(com.sequenceiq.common.model.diagnostics.DiagnosticParameters) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) CmDiagnosticsCollectionEvent(com.sequenceiq.cloudbreak.core.flow2.cmdiagnostics.event.CmDiagnosticsCollectionEvent) DiagnosticsCollectionEvent(com.sequenceiq.cloudbreak.core.flow2.diagnostics.event.DiagnosticsCollectionEvent) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Aggregations

DiagnosticsCollectionEvent (com.sequenceiq.cloudbreak.core.flow2.diagnostics.event.DiagnosticsCollectionEvent)58 DiagnosticParameters (com.sequenceiq.common.model.diagnostics.DiagnosticParameters)47 Test (org.junit.jupiter.api.Test)33 HandlerEvent (com.sequenceiq.flow.reactor.api.handler.HandlerEvent)22 Event (reactor.bus.Event)15 CommonContext (com.sequenceiq.flow.core.CommonContext)13 Map (java.util.Map)13 Bean (org.springframework.context.annotation.Bean)13 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)11 DiagnosticsFlowException (com.sequenceiq.cloudbreak.core.flow2.diagnostics.DiagnosticsFlowException)11 CloudbreakOrchestratorFailedException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException)9 CmDiagnosticsCollectionEvent (com.sequenceiq.cloudbreak.core.flow2.cmdiagnostics.event.CmDiagnosticsCollectionEvent)6 CmDiagnosticsParameters (com.sequenceiq.common.model.diagnostics.CmDiagnosticsParameters)5 CmDiagnosticsCollectionFailureEvent (com.sequenceiq.cloudbreak.core.flow2.cmdiagnostics.event.CmDiagnosticsCollectionFailureEvent)4 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)2 DataBusCredential (com.sequenceiq.common.api.telemetry.model.DataBusCredential)2 Telemetry (com.sequenceiq.common.api.telemetry.model.Telemetry)2 AwsDiagnosticParameters (com.sequenceiq.common.model.diagnostics.AwsDiagnosticParameters)2 AzureDiagnosticParameters (com.sequenceiq.common.model.diagnostics.AzureDiagnosticParameters)2 DiagnosticsCollectionFailureEvent (com.sequenceiq.cloudbreak.core.flow2.diagnostics.event.DiagnosticsCollectionFailureEvent)1