use of org.apache.samza.serializers.MetricsSnapshotSerdeV2 in project samza by apache.
the class TestMetricsSnapshotSerdeV2 method testSerializeThenDeserialize.
@Test
public void testSerializeThenDeserialize() {
SamzaException samzaException = new SamzaException("this is a samza exception", new RuntimeException("cause"));
MetricsSnapshot metricsSnapshot = metricsSnapshot(samzaException, true);
MetricsSnapshotSerdeV2 metricsSnapshotSerde = new MetricsSnapshotSerdeV2();
byte[] serializedBytes = metricsSnapshotSerde.toBytes(metricsSnapshot);
MetricsSnapshot deserializedMetricsSnapshot = metricsSnapshotSerde.fromBytes(serializedBytes);
assertEquals(metricsSnapshot, deserializedMetricsSnapshot);
}
use of org.apache.samza.serializers.MetricsSnapshotSerdeV2 in project samza by apache.
the class TestDiagnosticsManager method validateMetricsHeader.
private void validateMetricsHeader(OutgoingMessageEnvelope outgoingMessageEnvelope, long sendTime) {
// Validate the outgoing message
Assert.assertTrue(outgoingMessageEnvelope.getSystemStream().equals(diagnosticsSystemStream));
MetricsSnapshot metricsSnapshot = new MetricsSnapshotSerdeV2().fromBytes((byte[]) outgoingMessageEnvelope.getMessage());
MetricsHeader expectedHeader = new MetricsHeader(JOB_NAME, JOB_ID, "samza-container-0", EXECUTION_ENV_CONTAINER_ID, Optional.of(SAMZA_EPOCH_ID), DiagnosticsManager.class.getName(), TASK_CLASS_VERSION, SAMZA_VERSION, HOSTNAME, sendTime, RESET_TIME);
Assert.assertEquals(expectedHeader, metricsSnapshot.getHeader());
}
Aggregations