Search in sources :

Example 11 with MetricsSnapshotSerdeV2

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);
}
Also used : MetricsSnapshot(org.apache.samza.metrics.reporter.MetricsSnapshot) MetricsSnapshotSerdeV2(org.apache.samza.serializers.MetricsSnapshotSerdeV2) SamzaException(org.apache.samza.SamzaException) Test(org.junit.Test)

Example 12 with MetricsSnapshotSerdeV2

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());
}
Also used : MetricsHeader(org.apache.samza.metrics.reporter.MetricsHeader) MetricsSnapshot(org.apache.samza.metrics.reporter.MetricsSnapshot) MetricsSnapshotSerdeV2(org.apache.samza.serializers.MetricsSnapshotSerdeV2)

Aggregations

MetricsSnapshotSerdeV2 (org.apache.samza.serializers.MetricsSnapshotSerdeV2)12 MetricsSnapshot (org.apache.samza.metrics.reporter.MetricsSnapshot)9 Test (org.junit.Test)7 SamzaException (org.apache.samza.SamzaException)4 MetricsHeader (org.apache.samza.metrics.reporter.MetricsHeader)2 OutgoingMessageEnvelope (org.apache.samza.system.OutgoingMessageEnvelope)2 File (java.io.File)1 HashMap (java.util.HashMap)1 Config (org.apache.samza.config.Config)1 MapConfig (org.apache.samza.config.MapConfig)1 SerializerConfig (org.apache.samza.config.SerializerConfig)1 StreamConfig (org.apache.samza.config.StreamConfig)1 SystemConfig (org.apache.samza.config.SystemConfig)1 Metrics (org.apache.samza.metrics.reporter.Metrics)1 LocalContainerRunner (org.apache.samza.runtime.LocalContainerRunner)1 SystemProducer (org.apache.samza.system.SystemProducer)1 SystemStream (org.apache.samza.system.SystemStream)1 Clock (org.apache.samza.util.Clock)1 Before (org.junit.Before)1