Search in sources :

Example 1 with FixedSchemaVersionWriter

use of org.apache.gobblin.metrics.reporter.util.FixedSchemaVersionWriter in project incubator-gobblin by apache.

the class KafkaAvroJobMonitorTest method testWrongSchemaVersionWriter.

@Test
public void testWrongSchemaVersionWriter() throws Exception {
    TestKafkaAvroJobMonitor monitor = new TestKafkaAvroJobMonitor(GobblinTrackingEvent.SCHEMA$, new NoopSchemaVersionWriter());
    monitor.buildMetricsContextAndMetrics();
    AvroSerializer<GobblinTrackingEvent> serializer = new AvroBinarySerializer<>(GobblinTrackingEvent.SCHEMA$, new FixedSchemaVersionWriter());
    GobblinTrackingEvent event = new GobblinTrackingEvent(0L, "namespace", "event", Maps.<String, String>newHashMap());
    Collection<Either<JobSpec, URI>> results = monitor.parseJobSpec(serializer.serializeRecord(event));
    Assert.assertEquals(results.size(), 0);
    Assert.assertEquals(monitor.events.size(), 0);
    Assert.assertEquals(monitor.getMessageParseFailures().getCount(), 1);
    monitor.shutdownMetrics();
}
Also used : GobblinTrackingEvent(org.apache.gobblin.metrics.GobblinTrackingEvent) FixedSchemaVersionWriter(org.apache.gobblin.metrics.reporter.util.FixedSchemaVersionWriter) Either(org.apache.gobblin.util.Either) NoopSchemaVersionWriter(org.apache.gobblin.metrics.reporter.util.NoopSchemaVersionWriter) AvroBinarySerializer(org.apache.gobblin.metrics.reporter.util.AvroBinarySerializer) HighLevelConsumerTest(org.apache.gobblin.runtime.kafka.HighLevelConsumerTest) Test(org.testng.annotations.Test)

Example 2 with FixedSchemaVersionWriter

use of org.apache.gobblin.metrics.reporter.util.FixedSchemaVersionWriter in project incubator-gobblin by apache.

the class KafkaAvroJobMonitorTest method testUsingSchemaVersion.

@Test
public void testUsingSchemaVersion() throws Exception {
    TestKafkaAvroJobMonitor monitor = new TestKafkaAvroJobMonitor(GobblinTrackingEvent.SCHEMA$, new FixedSchemaVersionWriter());
    monitor.buildMetricsContextAndMetrics();
    AvroSerializer<GobblinTrackingEvent> serializer = new AvroBinarySerializer<>(GobblinTrackingEvent.SCHEMA$, new FixedSchemaVersionWriter());
    GobblinTrackingEvent event = new GobblinTrackingEvent(0L, "namespace", "event", Maps.<String, String>newHashMap());
    Collection<Either<JobSpec, URI>> results = monitor.parseJobSpec(serializer.serializeRecord(event));
    Assert.assertEquals(results.size(), 1);
    Assert.assertEquals(monitor.events.size(), 1);
    Assert.assertEquals(monitor.events.get(0), event);
    monitor.shutdownMetrics();
}
Also used : GobblinTrackingEvent(org.apache.gobblin.metrics.GobblinTrackingEvent) FixedSchemaVersionWriter(org.apache.gobblin.metrics.reporter.util.FixedSchemaVersionWriter) Either(org.apache.gobblin.util.Either) AvroBinarySerializer(org.apache.gobblin.metrics.reporter.util.AvroBinarySerializer) HighLevelConsumerTest(org.apache.gobblin.runtime.kafka.HighLevelConsumerTest) Test(org.testng.annotations.Test)

Example 3 with FixedSchemaVersionWriter

use of org.apache.gobblin.metrics.reporter.util.FixedSchemaVersionWriter in project incubator-gobblin by apache.

the class AvroJobSpecDeserializer method configure.

@Override
public void configure(Map<String, ?> configs, boolean isKey) {
    InputStream dummyInputStream = new ByteArrayInputStream(new byte[0]);
    _decoder = DecoderFactory.get().binaryDecoder(dummyInputStream, null);
    _reader = new SpecificDatumReader<AvroJobSpec>(AvroJobSpec.SCHEMA$);
    _versionWriter = new FixedSchemaVersionWriter();
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) DataInputStream(java.io.DataInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) FixedSchemaVersionWriter(org.apache.gobblin.metrics.reporter.util.FixedSchemaVersionWriter) AvroJobSpec(org.apache.gobblin.runtime.job_spec.AvroJobSpec)

Aggregations

FixedSchemaVersionWriter (org.apache.gobblin.metrics.reporter.util.FixedSchemaVersionWriter)3 GobblinTrackingEvent (org.apache.gobblin.metrics.GobblinTrackingEvent)2 AvroBinarySerializer (org.apache.gobblin.metrics.reporter.util.AvroBinarySerializer)2 HighLevelConsumerTest (org.apache.gobblin.runtime.kafka.HighLevelConsumerTest)2 Either (org.apache.gobblin.util.Either)2 Test (org.testng.annotations.Test)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataInputStream (java.io.DataInputStream)1 InputStream (java.io.InputStream)1 NoopSchemaVersionWriter (org.apache.gobblin.metrics.reporter.util.NoopSchemaVersionWriter)1 AvroJobSpec (org.apache.gobblin.runtime.job_spec.AvroJobSpec)1