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