Search in sources :

Example 71 with Telemetry

use of com.sequenceiq.common.api.telemetry.model.Telemetry in project cloudbreak by hortonworks.

the class StackToStackV4ResponseConverter method convertTelemetryComponent.

private void convertTelemetryComponent(StackV4Response response, Stack source) {
    TelemetryResponse telemetryResponse = null;
    try {
        Telemetry telemetry = componentConfigProviderService.getTelemetry(source.getId());
        telemetryResponse = telemetryConverter.convert(telemetry);
    } catch (CloudbreakServiceException exc) {
        LOGGER.debug(exc.getMessage());
    }
    response.setTelemetry(telemetryResponse);
}
Also used : TelemetryResponse(com.sequenceiq.common.api.telemetry.response.TelemetryResponse) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry)

Example 72 with Telemetry

use of com.sequenceiq.common.api.telemetry.model.Telemetry in project cloudbreak by hortonworks.

the class ClusterService method cleanupCluster.

public void cleanupCluster(final Cluster cluster) {
    if (StringUtils.isEmpty(cluster.getClusterManagerIp())) {
        LOGGER.debug("Cluster server IP was not set before, cleanup cluster operation can be skipped.");
    } else {
        Stack stack = cluster.getStack();
        if (stack != null) {
            try {
                Telemetry telemetry = componentConfigProviderService.getTelemetry(stack.getId());
                clusterApiConnectors.getConnector(stack).clusterModificationService().cleanupCluster(telemetry);
                altusMachineUserService.clearFluentMachineUser(stack, telemetry);
            } catch (CloudbreakServiceException se) {
                LOGGER.error("Cluster specific cleanup failed during obtaining telemetry component.", se);
            } catch (CloudbreakException e) {
                LOGGER.error("Cluster specific cleanup failed.", e);
            }
        }
    }
}
Also used : CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 73 with Telemetry

use of com.sequenceiq.common.api.telemetry.model.Telemetry 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 74 with Telemetry

use of com.sequenceiq.common.api.telemetry.model.Telemetry 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)

Example 75 with Telemetry

use of com.sequenceiq.common.api.telemetry.model.Telemetry in project cloudbreak by hortonworks.

the class AltusMachineUserService method getOrCreateDataBusCredentialIfNeeded.

/**
 * Gather or create DataBus credential for a stack.
 * On creation it will generate aa new workload user with new access/private keys.
 * @param stackId id of the stack
 * @return databus credential holder
 */
public DataBusCredential getOrCreateDataBusCredentialIfNeeded(Long stackId) throws IOException {
    LOGGER.debug("Get or create databus credential for stack");
    Stack stack = stackService.get(stackId);
    Cluster cluster = clusterService.findOneByStackIdOrNotFoundError(stackId);
    cluster.getDatabusCredential();
    Telemetry telemetry = componentConfigProviderService.getTelemetry(stackId);
    if (cluster.getDatabusCredential() != null) {
        LOGGER.debug("Databus credential has been found for the stack");
        DataBusCredential dataBusCredential = new Json(cluster.getDatabusCredential()).get(DataBusCredential.class);
        if (isDataBusCredentialStillExist(telemetry, dataBusCredential, stack)) {
            LOGGER.debug("Databus credential exists both in the stack and on UMS side");
            return dataBusCredential;
        } else {
            LOGGER.debug("Databus credential exists on stack side but does not exists on UMS side, it will be updated ...");
        }
    } else {
        LOGGER.debug("Databus credential does not exist for the stack, it will be created ...");
    }
    Optional<AltusCredential> altusCredential = generateDatabusMachineUserForFluent(stack, telemetry, true);
    return storeDataBusCredential(altusCredential, stack);
}
Also used : AltusCredential(com.sequenceiq.cloudbreak.auth.altus.model.AltusCredential) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Json(com.sequenceiq.cloudbreak.common.json.Json) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) DataBusCredential(com.sequenceiq.common.api.telemetry.model.DataBusCredential) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Aggregations

Telemetry (com.sequenceiq.common.api.telemetry.model.Telemetry)109 Test (org.junit.Test)55 Test (org.junit.jupiter.api.Test)31 Logging (com.sequenceiq.common.api.telemetry.model.Logging)30 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)20 S3CloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters)16 TelemetryRequest (com.sequenceiq.common.api.telemetry.request.TelemetryRequest)15 BaseDiagnosticsCollectionRequest (com.sequenceiq.common.api.diagnostics.BaseDiagnosticsCollectionRequest)13 AdlsGen2CloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.AdlsGen2CloudStorageV1Parameters)12 Backup (com.sequenceiq.freeipa.api.model.Backup)12 HashMap (java.util.HashMap)12 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)11 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)10 Features (com.sequenceiq.common.api.telemetry.model.Features)10 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)8 SaltPillarProperties (com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties)8 ApiClient (com.cloudera.api.swagger.client.ApiClient)7 GcsCloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.GcsCloudStorageV1Parameters)7 WorkloadAnalytics (com.sequenceiq.common.api.telemetry.model.WorkloadAnalytics)6 TelemetryResponse (com.sequenceiq.common.api.telemetry.response.TelemetryResponse)6