use of org.apache.samza.diagnostics.BoundedList in project samza by apache.
the class TestMetricsSnapshotSerdeV2 method metricsSnapshot.
private static MetricsSnapshot metricsSnapshot(Exception exception, boolean includeSamzaEpochId) {
MetricsHeader metricsHeader;
if (includeSamzaEpochId) {
metricsHeader = new MetricsHeader("jobName", "i001", "container 0", "test container ID", Optional.of("epoch-123"), "source", "300.14.25.1", "1", "1", 1, 1);
} else {
metricsHeader = new MetricsHeader("jobName", "i001", "container 0", "test container ID", "source", "300.14.25.1", "1", "1", 1, 1);
}
BoundedList<DiagnosticsExceptionEvent> boundedList = new BoundedList<>("exceptions");
DiagnosticsExceptionEvent diagnosticsExceptionEvent = new DiagnosticsExceptionEvent(1, exception, new HashMap<>());
boundedList.add(diagnosticsExceptionEvent);
Map<String, Map<String, Object>> metricMessage = new HashMap<>();
Map<String, Object> samzaContainerMetrics = new HashMap<>();
samzaContainerMetrics.put("commit-calls", 1);
metricMessage.put("org.apache.samza.container.SamzaContainerMetrics", samzaContainerMetrics);
Map<String, Object> exceptions = new HashMap<>();
exceptions.put("exceptions", boundedList.getValues());
metricMessage.put("org.apache.samza.exceptions", exceptions);
return new MetricsSnapshot(metricsHeader, new Metrics(metricMessage));
}
use of org.apache.samza.diagnostics.BoundedList in project samza by apache.
the class TestBoundedList method testSizeEnforcement.
@Test
public void testSizeEnforcement() {
BoundedList boundedList = getBoundedListForTest();
for (int i = 15; i > 0; i--) {
boundedList.add("v" + i);
}
Assert.assertEquals("List sizes should be as configured at creation time", boundedList.getValues().size(), 10);
int valueIndex = 10;
Collection<String> currentList = boundedList.getValues();
Iterator iterator = currentList.iterator();
while (iterator.hasNext()) {
String gaugeValue = (String) iterator.next();
Assert.assertTrue(gaugeValue.equals("v" + valueIndex));
valueIndex--;
}
}
Aggregations