Search in sources :

Example 1 with JmxMetricsAccessor

use of org.apache.samza.metrics.JmxMetricsAccessor in project samza by apache.

the class TestYarnJobValidationTool method testValidateJmxMetrics.

@Test
public void testValidateJmxMetrics() throws MetricsValidationFailureException {
    JmxMetricsAccessor jmxMetricsAccessor = mock(JmxMetricsAccessor.class);
    Map<String, Long> values = new HashMap<>();
    values.put("samza-container-0", 100L);
    when(jmxMetricsAccessor.getCounterValues(SamzaContainerMetrics.class.getName(), "commit-calls")).thenReturn(values);
    validator.validate(jmxMetricsAccessor);
    values.put("samza-container-0", -1L);
    // the mock validator will fail if the commit-calls are less than or equal to 0
    exception.expect(MetricsValidationFailureException.class);
    validator.validate(jmxMetricsAccessor);
}
Also used : JmxMetricsAccessor(org.apache.samza.metrics.JmxMetricsAccessor) HashMap(java.util.HashMap) SamzaContainerMetrics(org.apache.samza.container.SamzaContainerMetrics) Test(org.junit.Test)

Example 2 with JmxMetricsAccessor

use of org.apache.samza.metrics.JmxMetricsAccessor in project samza by apache.

the class YarnJobValidationTool method validateJmxMetrics.

public void validateJmxMetrics() throws Exception {
    JobModelManager jobModelManager = JobModelManager.apply(config);
    validator.init(config);
    Map<String, String> jmxUrls = jobModelManager.jobModel().getAllContainerToHostValues(SetContainerHostMapping.JMX_TUNNELING_URL_KEY);
    for (Map.Entry<String, String> entry : jmxUrls.entrySet()) {
        String containerId = entry.getKey();
        String jmxUrl = entry.getValue();
        log.info("validate container " + containerId + " metrics with JMX: " + jmxUrl);
        JmxMetricsAccessor jmxMetrics = new JmxMetricsAccessor(jmxUrl);
        jmxMetrics.connect();
        validator.validate(jmxMetrics);
        jmxMetrics.close();
        log.info("validate container " + containerId + " successfully");
    }
    validator.complete();
}
Also used : JmxMetricsAccessor(org.apache.samza.metrics.JmxMetricsAccessor) JobModelManager(org.apache.samza.coordinator.JobModelManager) Map(java.util.Map)

Aggregations

JmxMetricsAccessor (org.apache.samza.metrics.JmxMetricsAccessor)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 SamzaContainerMetrics (org.apache.samza.container.SamzaContainerMetrics)1 JobModelManager (org.apache.samza.coordinator.JobModelManager)1 Test (org.junit.Test)1