use of com.sequenceiq.common.api.telemetry.model.WorkloadAnalytics in project cloudbreak by hortonworks.
the class ClouderaManagerMgmtTelemetryServiceTest method testEnrichWithSdxData.
@Test
public void testEnrichWithSdxData() {
// GIVEN
Stack stack = new Stack();
Cluster cluster = new Cluster();
cluster.setId(1L);
cluster.setName("cl1");
stack.setCluster(cluster);
Map<String, String> safetyValveMap = new HashMap<>();
WorkloadAnalytics workloadAnalytics = new WorkloadAnalytics();
workloadAnalytics.setDatabusEndpoint("customEndpoint");
// WHEN
underTest.enrichWithSdxData(null, null, stack, workloadAnalytics, safetyValveMap);
// THEN
assertTrue(safetyValveMap.containsKey("databus.header.sdx.id"));
assertTrue(safetyValveMap.containsKey("databus.header.sdx.name"));
assertEquals(safetyValveMap.get("databus.header.sdx.name"), "cl1-1");
}
use of com.sequenceiq.common.api.telemetry.model.WorkloadAnalytics 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.model.WorkloadAnalytics in project cloudbreak by hortonworks.
the class ClouderaManagerMgmtTelemetryService method setupTelemetryRole.
public void setupTelemetryRole(final Stack stack, final ApiClient client, final ApiHostRef cmHostRef, final ApiRoleList mgmtRoles, final Telemetry telemetry) throws ApiException {
if (isWorkflowAnalyticsEnabled(stack, telemetry)) {
WorkloadAnalytics workloadAnalytics = telemetry.getWorkloadAnalytics();
String accountId = Crn.safeFromString(stack.getResourceCrn()).getAccountId();
boolean useDbusCnameEndpoint = entitlementService.useDataBusCNameEndpointEnabled(accountId);
String databusEndpoint = dataBusEndpointProvider.getDataBusEndpoint(workloadAnalytics.getDatabusEndpoint(), useDbusCnameEndpoint);
ClouderaManagerResourceApi cmResourceApi = clouderaManagerApiFactory.getClouderaManagerResourceApi(client);
ApiConfigList apiConfigList = buildTelemetryCMConfigList(workloadAnalytics, databusEndpoint);
cmResourceApi.updateConfig("Adding telemetry settings.", apiConfigList);
AltusCredential credentials = clouderaManagerDatabusService.getAltusCredential(stack);
Map<String, String> accountConfigs = new HashMap<>();
accountConfigs.put(ALTUS_CREDENTIAL_ACCESS_KEY_NAME, credentials.getAccessKey());
accountConfigs.put(ALTUS_CREDENTIAL_PRIVATE_KEY_NAME, new String(credentials.getPrivateKey()));
externalAccountService.createExternalAccount(ALTUS_CREDENTIAL_NAME, ALTUS_CREDENTIAL_NAME, ALTUS_CREDENTIAL_TYPE, accountConfigs, client);
final ApiRole telemetryPublisher = new ApiRole();
telemetryPublisher.setName(TELEMETRYPUBLISHER);
telemetryPublisher.setType(TELEMETRYPUBLISHER);
telemetryPublisher.setHostRef(cmHostRef);
mgmtRoles.addItemsItem(telemetryPublisher);
} else {
LOGGER.info("Telemetry WA is disabled");
}
}
Aggregations