Search in sources :

Example 6 with EnvironmentFeatures

use of com.sequenceiq.environment.environment.dto.telemetry.EnvironmentFeatures in project cloudbreak by hortonworks.

the class EnvironmentModificationService method changeTelemetryFeatures.

private EnvironmentDto changeTelemetryFeatures(EnvironmentFeatures features, Environment environment) {
    EnvironmentTelemetry telemetry = environment.getTelemetry();
    if (telemetry != null) {
        EnvironmentFeatures actualFeatures = telemetry.getFeatures();
        if (actualFeatures != null) {
            if (features.getClusterLogsCollection() != null) {
                actualFeatures.setClusterLogsCollection(features.getClusterLogsCollection());
                LOGGER.debug("Updating cluster log collection (environment telemetry feature): {}.", features.getClusterLogsCollection().isEnabled());
            }
            if (features.getWorkloadAnalytics() != null) {
                actualFeatures.setWorkloadAnalytics(features.getWorkloadAnalytics());
                LOGGER.debug("Updating workload analytics (environment telemetry feature): {}.", features.getWorkloadAnalytics().isEnabled());
            }
            if (features.getCloudStorageLogging() != null) {
                actualFeatures.setCloudStorageLogging(features.getCloudStorageLogging());
                LOGGER.debug("Updating cloud storage logging (environment telemetry feature): {}.", features.getCloudStorageLogging().isEnabled());
            }
            telemetry.setFeatures(actualFeatures);
            // required to re-set as telemetry is saved as a JSON string
            environment.setTelemetry(telemetry);
        } else if (features != null) {
            telemetry.setFeatures(features);
            // required to re-set as telemetry is saved as a JSON string
            environment.setTelemetry(telemetry);
            LOGGER.debug("Adding new feature object for environment level telemetry.");
        } else {
            LOGGER.debug("No telemetry feature related changes has been made.");
        }
    }
    Environment saved = environmentService.save(environment);
    return environmentDtoConverter.environmentToDto(saved);
}
Also used : EnvironmentTelemetry(com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry) Environment(com.sequenceiq.environment.environment.domain.Environment) EnvironmentFeatures(com.sequenceiq.environment.environment.dto.telemetry.EnvironmentFeatures)

Example 7 with EnvironmentFeatures

use of com.sequenceiq.environment.environment.dto.telemetry.EnvironmentFeatures in project cloudbreak by hortonworks.

the class EnvironmentController method changeTelemetryFeaturesByEnvironmentName.

@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.EDIT_ENVIRONMENT)
public DetailedEnvironmentResponse changeTelemetryFeaturesByEnvironmentName(@ResourceName String name, @Valid FeaturesRequest request) {
    String accountId = ThreadBasedUserCrnProvider.getAccountId();
    EnvironmentFeatures features = environmentApiConverter.convertToEnvironmentTelemetryFeatures(request);
    EnvironmentDto result = environmentModificationService.changeTelemetryFeaturesByEnvironmentName(accountId, name, features);
    return environmentResponseConverter.dtoToDetailedResponse(result);
}
Also used : EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) EnvironmentFeatures(com.sequenceiq.environment.environment.dto.telemetry.EnvironmentFeatures) CheckPermissionByResourceName(com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)

Example 8 with EnvironmentFeatures

use of com.sequenceiq.environment.environment.dto.telemetry.EnvironmentFeatures in project cloudbreak by hortonworks.

the class EnvironmentApiConverter method convertToEnvironmentTelemetryFeatures.

public EnvironmentFeatures convertToEnvironmentTelemetryFeatures(FeaturesRequest featuresRequest) {
    EnvironmentFeatures features = new EnvironmentFeatures();
    features.setWorkloadAnalytics(featuresRequest.getWorkloadAnalytics());
    features.setClusterLogsCollection(featuresRequest.getClusterLogsCollection());
    features.setCloudStorageLogging(featuresRequest.getCloudStorageLogging());
    return features;
}
Also used : EnvironmentFeatures(com.sequenceiq.environment.environment.dto.telemetry.EnvironmentFeatures)

Example 9 with EnvironmentFeatures

use of com.sequenceiq.environment.environment.dto.telemetry.EnvironmentFeatures in project cloudbreak by hortonworks.

the class EnvironmentDetailsToCDPEnvironmentTelemetryFeatureDetailsConverter method convert.

public UsageProto.CDPEnvironmentTelemetryFeatureDetails convert(EnvironmentDetails environmentDetails) {
    UsageProto.CDPEnvironmentTelemetryFeatureDetails.Builder cdpTelemetryFeatureDetailsBuilder = UsageProto.CDPEnvironmentTelemetryFeatureDetails.newBuilder();
    if (environmentDetails != null && environmentDetails.getEnvironmentTelemetryFeatures() != null) {
        EnvironmentFeatures environmentFeatures = environmentDetails.getEnvironmentTelemetryFeatures();
        if (environmentFeatures.getWorkloadAnalytics() != null && environmentFeatures.getWorkloadAnalytics().isEnabled() != null) {
            cdpTelemetryFeatureDetailsBuilder.setWorkloadAnalytics(environmentFeatures.getWorkloadAnalytics().isEnabled().toString());
        }
        if (environmentFeatures.getClusterLogsCollection() != null && environmentFeatures.getClusterLogsCollection().isEnabled() != null) {
            cdpTelemetryFeatureDetailsBuilder.setClusterLogsCollection(environmentFeatures.getClusterLogsCollection().isEnabled().toString());
        }
    }
    UsageProto.CDPEnvironmentTelemetryFeatureDetails ret = cdpTelemetryFeatureDetailsBuilder.build();
    LOGGER.debug("Converted CDPEnvironmentTelemetryFeatureDetails: {}", ret);
    return ret;
}
Also used : UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto) EnvironmentFeatures(com.sequenceiq.environment.environment.dto.telemetry.EnvironmentFeatures)

Example 10 with EnvironmentFeatures

use of com.sequenceiq.environment.environment.dto.telemetry.EnvironmentFeatures in project cloudbreak by hortonworks.

the class TelemetryApiConverter method createEnvironmentFeaturesFromRequest.

private EnvironmentFeatures createEnvironmentFeaturesFromRequest(FeaturesRequest featuresRequest, Features accountFeatures) {
    EnvironmentFeatures features = null;
    if (featuresRequest != null) {
        features = new EnvironmentFeatures();
        if (useSharedAltusCredential) {
            features.addUseSharedAltusredential(true);
        }
        setClusterLogsCollectionFromAccountAndRequest(featuresRequest, accountFeatures, features);
        setMonitoringFromAccountAndRequest(featuresRequest, accountFeatures, features);
        setCloudStorageLoggingFromAccountAndRequest(featuresRequest, accountFeatures, features);
        if (accountFeatures.getWorkloadAnalytics() != null) {
            features.setWorkloadAnalytics(accountFeatures.getWorkloadAnalytics());
        }
        if (featuresRequest.getWorkloadAnalytics() != null) {
            features.setWorkloadAnalytics(featuresRequest.getWorkloadAnalytics());
        }
    }
    return features;
}
Also used : EnvironmentFeatures(com.sequenceiq.environment.environment.dto.telemetry.EnvironmentFeatures)

Aggregations

EnvironmentFeatures (com.sequenceiq.environment.environment.dto.telemetry.EnvironmentFeatures)10 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)4 EnvironmentTelemetry (com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry)4 Environment (com.sequenceiq.environment.environment.domain.Environment)3 Test (org.junit.jupiter.api.Test)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 UsageProto (com.cloudera.thunderhead.service.common.usage.UsageProto)1 CheckPermissionByResourceCrn (com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)1 CheckPermissionByResourceName (com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)1 TelemetryRequest (com.sequenceiq.common.api.telemetry.request.TelemetryRequest)1 EnvironmentLogging (com.sequenceiq.environment.environment.dto.telemetry.EnvironmentLogging)1 S3CloudStorageParameters (com.sequenceiq.environment.environment.dto.telemetry.S3CloudStorageParameters)1