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);
}
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);
}
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;
}
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;
}
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;
}
Aggregations