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);
}
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();
}
Aggregations