use of com.sequenceiq.common.api.telemetry.request.TelemetryRequest in project cloudbreak by hortonworks.
the class TelemetryConverterTest method testConvertFromEnvAndSdxResponseWithWADisabledGlobally.
@Test
public void testConvertFromEnvAndSdxResponseWithWADisabledGlobally() {
// GIVEN
TelemetryResponse response = new TelemetryResponse();
SdxClusterResponse sdxClusterResponse = new SdxClusterResponse();
sdxClusterResponse.setCrn("crn:cdp:cloudbreak:us-west-1:someone:sdxcluster:sdxId");
sdxClusterResponse.setName("sdxName");
AltusDatabusConfiguration altusDatabusConfiguration = new AltusDatabusConfiguration(DATABUS_ENDPOINT, DATABUS_S3_BUCKET, false, "", null);
MeteringConfiguration meteringConfiguration = new MeteringConfiguration(true, null, null);
ClusterLogsCollectionConfiguration logCollectionConfig = new ClusterLogsCollectionConfiguration(true, null, null);
MonitoringConfiguration monitoringConfig = new MonitoringConfiguration();
monitoringConfig.setEnabled(true);
TelemetryConfiguration telemetryConfiguration = new TelemetryConfiguration(altusDatabusConfiguration, meteringConfiguration, logCollectionConfig, monitoringConfig, null);
TelemetryConverter converter = new TelemetryConverter(telemetryConfiguration, false, true);
// WHEN
TelemetryRequest result = converter.convert(response, sdxClusterResponse);
// THEN
assertNull(result.getWorkloadAnalytics());
}
use of com.sequenceiq.common.api.telemetry.request.TelemetryRequest in project cloudbreak by hortonworks.
the class TelemetryConverterTest method testConvertFromEnvAndSdxResponseWithMonitoring.
@Test
public void testConvertFromEnvAndSdxResponseWithMonitoring() {
// GIVEN
TelemetryResponse response = new TelemetryResponse();
FeaturesResponse featuresResponse = new FeaturesResponse();
featuresResponse.addMonitoring(true);
response.setFeatures(featuresResponse);
MonitoringResponse monitoringResponse = new MonitoringResponse();
monitoringResponse.setRemoteWriteUrl(MONITORING_REMOTE_WRITE_URL);
response.setMonitoring(monitoringResponse);
// WHEN
TelemetryRequest result = underTest.convert(response, null);
// THEN
assertTrue(result.getFeatures().getMonitoring().isEnabled());
assertEquals(MONITORING_REMOTE_WRITE_URL, result.getMonitoring().getRemoteWriteUrl());
}
use of com.sequenceiq.common.api.telemetry.request.TelemetryRequest in project cloudbreak by hortonworks.
the class TelemetryConverterTest method testConvertToRequest.
@Test
public void testConvertToRequest() {
// GIVEN
Telemetry telemetry = new Telemetry();
telemetry.setDatabusEndpoint(DATABUS_ENDPOINT);
Logging logging = new Logging();
logging.setS3(new S3CloudStorageV1Parameters());
telemetry.setLogging(logging);
Monitoring monitoring = new Monitoring();
monitoring.setRemoteWriteUrl(MONITORING_REMOTE_WRITE_URL);
telemetry.setMonitoring(monitoring);
Features features = new Features();
features.addClusterLogsCollection(true);
features.addMonitoring(true);
telemetry.setFeatures(features);
WorkloadAnalytics workloadAnalytics = new WorkloadAnalytics();
Map<String, Object> waAttributes = new HashMap<>();
waAttributes.put("myWAKey", "myWAValue");
workloadAnalytics.setAttributes(waAttributes);
telemetry.setWorkloadAnalytics(workloadAnalytics);
Map<String, Object> fluentAttributes = new HashMap<>();
fluentAttributes.put("myKey", "myValue");
telemetry.setFluentAttributes(fluentAttributes);
// WHEN
TelemetryRequest result = underTest.convertToRequest(telemetry);
// THEN
assertNotNull(result.getLogging().getS3());
assertEquals("myValue", result.getFluentAttributes().get("myKey"));
assertEquals("myWAValue", result.getWorkloadAnalytics().getAttributes().get("myWAKey"));
assertTrue(result.getFeatures().getClusterLogsCollection().isEnabled());
assertTrue(result.getFeatures().getMonitoring().isEnabled());
assertEquals(MONITORING_REMOTE_WRITE_URL, result.getMonitoring().getRemoteWriteUrl());
}
use of com.sequenceiq.common.api.telemetry.request.TelemetryRequest in project cloudbreak by hortonworks.
the class TelemetryConverter method convert.
public TelemetryRequest convert(TelemetryResponse response, SdxClusterResponse sdxClusterResponse) {
LOGGER.debug("Creating telemetry request based on datalake and environment responses.");
TelemetryRequest telemetryRequest = new TelemetryRequest();
FeaturesRequest featuresRequest = new FeaturesRequest();
if (response != null) {
LoggingRequest loggingRequest = createLoggingRequestFromResponse(response);
telemetryRequest.setLogging(loggingRequest);
MonitoringRequest monitoringRequest = createMonitoringRequestFromResponse(response);
telemetryRequest.setMonitoring(monitoringRequest);
FeaturesResponse featuresResponse = response.getFeatures();
if (featuresResponse != null) {
LOGGER.debug("Setting cluster logs collection request (telemetry) based on environment response.");
featuresRequest.setClusterLogsCollection(featuresResponse.getClusterLogsCollection());
LOGGER.debug("Setting cluster monitoring request (telemetry) based on environment response.");
featuresRequest.setMonitoring(featuresResponse.getMonitoring());
LOGGER.debug("Setting cloud storage logging request (telemetry) based on environment response.");
if (featuresResponse.getCloudStorageLogging() != null) {
featuresRequest.setCloudStorageLogging(featuresResponse.getCloudStorageLogging());
} else {
featuresRequest.addCloudStorageLogging(true);
}
}
telemetryRequest.setFluentAttributes(response.getFluentAttributes());
}
telemetryRequest.setWorkloadAnalytics(createWorkloadAnalyticsRequest(response, sdxClusterResponse));
Optional<FeatureSetting> waFeature = createWorkloadAnalyticsFeature(telemetryRequest.getWorkloadAnalytics());
featuresRequest.setWorkloadAnalytics(waFeature.orElse(null));
telemetryRequest.setFeatures(featuresRequest);
return telemetryRequest;
}
use of com.sequenceiq.common.api.telemetry.request.TelemetryRequest in project cloudbreak by hortonworks.
the class TelemetryConverter method convertToRequest.
public TelemetryRequest convertToRequest(Telemetry telemetry) {
TelemetryRequest telemetryRequest = new TelemetryRequest();
if (telemetry != null) {
LoggingRequest loggingRequest = createLoggingRequestFromSource(telemetry);
MonitoringRequest monitoringRequest = createMonitoringRequestFromSource(telemetry);
WorkloadAnalyticsRequest waRequest = createWorkloadAnalyticsRequestFromSource(telemetry);
FeaturesRequest featuresRequest = createFeaturesRequestFromSource(telemetry);
telemetryRequest.setWorkloadAnalytics(waRequest);
telemetryRequest.setLogging(loggingRequest);
telemetryRequest.setMonitoring(monitoringRequest);
telemetryRequest.setFluentAttributes(telemetry.getFluentAttributes());
telemetryRequest.setFeatures(featuresRequest);
}
return telemetryRequest;
}
Aggregations