Search in sources :

Example 1 with DatabusRequest

use of com.sequenceiq.cloudbreak.sigmadbus.model.DatabusRequest in project cloudbreak by hortonworks.

the class NodeStatusCheckerJob method processCmMetricsReport.

private void processCmMetricsReport(Optional<RPCResponse<NodeStatusProto.CmMetricsReport>> cmMetricsReport, Stack stack, String accountId, boolean process) {
    if (cmMetricsReport.isPresent()) {
        LOGGER.debug("CM metrics report: {}", cmMetricsReport.get().getFirstTextMessage());
        if (isCmMetricsReportNotEmpty(cmMetricsReport.get())) {
            if (process) {
                DatabusRequestContext context = createDatabusRequestContext(accountId, stack, CdpNodeStatusType.CM_METRICS_REPORT);
                DatabusRequest recordRequest = createDatabusRecordRequest(cmMetricsReport.get().getResult(), context);
                metricsDataBusRecordProcessor.processRecord(recordRequest);
            }
        }
    } else {
        LOGGER.debug("Node status report does not contain CM metrics report for {}", stack.getName());
    }
}
Also used : DatabusRequest(com.sequenceiq.cloudbreak.sigmadbus.model.DatabusRequest) DatabusRequestContext(com.sequenceiq.cloudbreak.sigmadbus.model.DatabusRequestContext)

Example 2 with DatabusRequest

use of com.sequenceiq.cloudbreak.sigmadbus.model.DatabusRequest in project cloudbreak by hortonworks.

the class NodeStatusCheckerJob method processNodeStatusReport.

private <T extends GeneratedMessageV3> void processNodeStatusReport(Optional<RPCResponse<NodeStatusProto.NodeStatusReport>> nodeStatusReport, Function<NodeStatusProto.NodeStatus, T> nodeStatusDetails, Stack stack, String type, String accountId, boolean processAsMetrics) {
    if (nodeStatusReport.isPresent()) {
        LOGGER.debug("{} report: {}", type, nodeStatusReport.get().getFirstTextMessage());
        if (isStatusReportNotEmpty(nodeStatusReport.get())) {
            DatabusRequestContext context = createDatabusRequestContext(accountId, stack, CdpNodeStatusType.SYSTEM_METRICS);
            for (NodeStatusProto.NodeStatus nodeStatus : nodeStatusReport.get().getResult().getNodesList()) {
                T report = nodeStatusDetails.apply(nodeStatus);
                LOGGER.debug("{} details report: \n{}{}", type, report, getStatusDetailsStr(nodeStatus.getStatusDetails()));
                if (processAsMetrics) {
                    DatabusRequest recordRequest = createDatabusRecordRequest(report, context);
                    metricsDataBusRecordProcessor.processRecord(recordRequest);
                }
            }
        }
    } else {
        LOGGER.debug("Node status report does not contain {} report for {}", type, stack.getName());
    }
}
Also used : DatabusRequest(com.sequenceiq.cloudbreak.sigmadbus.model.DatabusRequest) NodeStatusProto(com.cloudera.thunderhead.telemetry.nodestatus.NodeStatusProto) DatabusRequestContext(com.sequenceiq.cloudbreak.sigmadbus.model.DatabusRequestContext)

Example 3 with DatabusRequest

use of com.sequenceiq.cloudbreak.sigmadbus.model.DatabusRequest in project cloudbreak by hortonworks.

the class FreeipaChecker method processSystemMetrics.

private void processSystemMetrics(RPCResponse<NodeStatusProto.NodeStatusReport> systemMetricsResponse, Stack stack) {
    if (entitlementService.datalakeMetricsDatabusProcessing(stack.getAccountId())) {
        DatabusRequestContext context = createDatabusRequestContext(stack);
        if (isSuccessfulRequest(systemMetricsResponse) && systemMetricsResponse.getResult() != null && CollectionUtils.isNotEmpty(systemMetricsResponse.getResult().getNodesList())) {
            for (NodeStatusProto.NodeStatus nodeStatus : systemMetricsResponse.getResult().getNodesList()) {
                DatabusRequest recordRequest = createDatabusRecordRequest(nodeStatus.getSystemMetrics(), context);
                metricsDatabusRecordProcessor.processRecord(recordRequest);
            }
        }
    } else {
        LOGGER.debug("Skip databus metrics processing as databus record processing is disabled for {}", stack.getAccountId());
    }
}
Also used : DatabusRequest(com.sequenceiq.cloudbreak.sigmadbus.model.DatabusRequest) NodeStatusProto(com.cloudera.thunderhead.telemetry.nodestatus.NodeStatusProto) DatabusRequestContext(com.sequenceiq.cloudbreak.sigmadbus.model.DatabusRequestContext)

Example 4 with DatabusRequest

use of com.sequenceiq.cloudbreak.sigmadbus.model.DatabusRequest in project cloudbreak by hortonworks.

the class DatabusRequestConverterTest method testConvertWithoutAccountId.

@Test
public void testConvertWithoutAccountId() {
    // GIVEN
    MeteringConfiguration meteringConfiguration = new MeteringConfiguration(true, "CdpVmMetrics", "CdpVmMetrics");
    DatabusRequest input = DatabusRequest.Builder.newBuilder().withRawBody("{}").withContext(DatabusRequestContext.Builder.newBuilder().addAdditionalDatabusHeader("third-header", "app-name").build()).build();
    // WHEN
    IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> DatabusRequestConverter.convert(input, meteringConfiguration));
    // THEN
    assertTrue(exception.getMessage().contains("At least accountId needs to be filled"));
}
Also used : MeteringConfiguration(com.sequenceiq.cloudbreak.telemetry.metering.MeteringConfiguration) DatabusRequest(com.sequenceiq.cloudbreak.sigmadbus.model.DatabusRequest) Test(org.junit.jupiter.api.Test)

Example 5 with DatabusRequest

use of com.sequenceiq.cloudbreak.sigmadbus.model.DatabusRequest in project cloudbreak by hortonworks.

the class DatabusRequestConverterTest method testConvertWithoutPayload.

@Test
public void testConvertWithoutPayload() {
    // GIVEN
    MeteringConfiguration meteringConfiguration = new MeteringConfiguration(true, "CdpVmMetrics", "CdpVmMetrics");
    DatabusRequest input = DatabusRequest.Builder.newBuilder().withContext(DatabusRequestContext.Builder.newBuilder().withAccountId("cloudera").build()).build();
    // WHEN
    IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> DatabusRequestConverter.convert(input, meteringConfiguration));
    // THEN
    assertTrue(exception.getMessage().contains("At least raw body message needs to be filled"));
}
Also used : MeteringConfiguration(com.sequenceiq.cloudbreak.telemetry.metering.MeteringConfiguration) DatabusRequest(com.sequenceiq.cloudbreak.sigmadbus.model.DatabusRequest) Test(org.junit.jupiter.api.Test)

Aggregations

DatabusRequest (com.sequenceiq.cloudbreak.sigmadbus.model.DatabusRequest)10 Test (org.junit.jupiter.api.Test)6 MeteringConfiguration (com.sequenceiq.cloudbreak.telemetry.metering.MeteringConfiguration)5 DatabusRequestContext (com.sequenceiq.cloudbreak.sigmadbus.model.DatabusRequestContext)4 DbusProto (com.cloudera.sigma.service.dbus.DbusProto)2 NodeStatusProto (com.cloudera.thunderhead.telemetry.nodestatus.NodeStatusProto)2 AbstractDatabusStreamConfiguration (com.sequenceiq.cloudbreak.telemetry.databus.AbstractDatabusStreamConfiguration)1