Search in sources :

Example 16 with WorkloadAnalytics

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");
}
Also used : HashMap(java.util.HashMap) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) WorkloadAnalytics(com.sequenceiq.common.api.telemetry.model.WorkloadAnalytics) Test(org.junit.Test)

Example 17 with WorkloadAnalytics

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());
}
Also used : Logging(com.sequenceiq.common.api.telemetry.model.Logging) TelemetryRequest(com.sequenceiq.common.api.telemetry.request.TelemetryRequest) S3CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters) HashMap(java.util.HashMap) Features(com.sequenceiq.common.api.telemetry.model.Features) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) Monitoring(com.sequenceiq.common.api.telemetry.model.Monitoring) WorkloadAnalytics(com.sequenceiq.common.api.telemetry.model.WorkloadAnalytics) Test(org.junit.Test)

Example 18 with WorkloadAnalytics

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");
    }
}
Also used : ApiConfigList(com.cloudera.api.swagger.model.ApiConfigList) ConfigUtils.makeApiConfigList(com.sequenceiq.cloudbreak.cm.util.ConfigUtils.makeApiConfigList) ApiRole(com.cloudera.api.swagger.model.ApiRole) HashMap(java.util.HashMap) AltusCredential(com.sequenceiq.cloudbreak.auth.altus.model.AltusCredential) ClouderaManagerResourceApi(com.cloudera.api.swagger.ClouderaManagerResourceApi) WorkloadAnalytics(com.sequenceiq.common.api.telemetry.model.WorkloadAnalytics)

Aggregations

WorkloadAnalytics (com.sequenceiq.common.api.telemetry.model.WorkloadAnalytics)18 Test (org.junit.Test)11 ApiConfigList (com.cloudera.api.swagger.model.ApiConfigList)7 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)6 Telemetry (com.sequenceiq.common.api.telemetry.model.Telemetry)6 HashMap (java.util.HashMap)6 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)4 AltusCredential (com.sequenceiq.cloudbreak.auth.altus.model.AltusCredential)3 Features (com.sequenceiq.common.api.telemetry.model.Features)3 Logging (com.sequenceiq.common.api.telemetry.model.Logging)3 ClouderaManagerResourceApi (com.cloudera.api.swagger.ClouderaManagerResourceApi)2 ApiClient (com.cloudera.api.swagger.client.ApiClient)2 ApiRole (com.cloudera.api.swagger.model.ApiRole)2 ConfigUtils.makeApiConfigList (com.sequenceiq.cloudbreak.cm.util.ConfigUtils.makeApiConfigList)2 S3CloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters)2 Monitoring (com.sequenceiq.common.api.telemetry.model.Monitoring)2 TelemetryRequest (com.sequenceiq.common.api.telemetry.request.TelemetryRequest)2 WorkloadAnalyticsRequest (com.sequenceiq.common.api.telemetry.request.WorkloadAnalyticsRequest)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 ApiResponse (com.cloudera.api.swagger.client.ApiResponse)1