use of org.apache.avro.AvroRuntimeException in project incubator-gobblin by apache.
the class KafkaAvroJobMonitor method parseJobSpec.
@Override
public Collection<JobSpec> parseJobSpec(byte[] message) throws IOException {
InputStream is = new ByteArrayInputStream(message);
this.versionWriter.readSchemaVersioningInformation(new DataInputStream(is));
Decoder decoder = DecoderFactory.get().binaryDecoder(is, this.decoder.get());
try {
T decodedMessage = this.reader.get().read(null, decoder);
return parseJobSpec(decodedMessage);
} catch (AvroRuntimeException | IOException exc) {
this.messageParseFailures.mark();
if (this.messageParseFailures.getFiveMinuteRate() < 1) {
log.warn("Unable to decode input message.", exc);
} else {
log.warn("Unable to decode input message.");
}
return Lists.newArrayList();
}
}
use of org.apache.avro.AvroRuntimeException in project spf4j by zolyfarkas.
the class CsvDecoder method arrayNext.
@Override
public long arrayNext() throws IOException {
parser.advance(Symbol.ITEM_END);
CsvReader.TokenType current = csvReader.current();
if (current == CsvReader.TokenType.START_DOCUMENT) {
throw new IllegalStateException("cannot be at the beginning of " + csvReader);
}
if (current == CsvReader.TokenType.END_ROW) {
try {
current = csvReader.next();
} catch (CsvParseException ex) {
throw new AvroRuntimeException(ex);
}
}
if (current == CsvReader.TokenType.ELEMENT) {
return 1L;
} else {
return 0L;
}
}
Aggregations