use of com.linkedin.databus.core.DatabusRuntimeException in project databus by linkedin.
the class ORListener method frameAvroRecord.
private void frameAvroRecord(long tableId, BinlogEventV4Header bh, List<Row> rl, final DbusOpcode doc) {
try {
final long timestampInNanos = bh.getTimestamp() * 1000000L;
final long scn = scn(_currFileNum, (int) bh.getPosition());
final boolean isReplicated = false;
final TableMapEvent tme = _tableMapEvents.get(tableId);
String tableName = tme.getDatabaseName().toString().toLowerCase() + "." + tme.getTableName().toString().toLowerCase();
VersionedSchema vs = _schemaRegistryService.fetchLatestVersionedSchemaBySourceName(_tableUriToSrcNameMap.get(tableName));
Schema schema = vs.getSchema();
if (_log.isDebugEnabled())
_log.debug("File Number :" + _currFileNum + ", Position :" + (int) bh.getPosition() + ", SCN =" + scn);
for (Row r : rl) {
List<Column> cl = r.getColumns();
GenericRecord gr = new GenericData.Record(schema);
generateAvroEvent(schema, cl, gr);
List<KeyPair> kps = generateKeyPair(cl, schema);
DbChangeEntry db = new DbChangeEntry(scn, timestampInNanos, gr, doc, isReplicated, schema, kps);
_transaction.getPerSourceTransaction(_tableUriToSrcIdMap.get(tableName)).mergeDbChangeEntrySet(db);
}
} catch (NoSuchSchemaException ne) {
throw new DatabusRuntimeException(ne);
} catch (DatabusException de) {
throw new DatabusRuntimeException(de);
}
}
use of com.linkedin.databus.core.DatabusRuntimeException in project databus by linkedin.
the class DbusEventAvroDecoder method getMetadataSchema.
/**
* Returns the single version of the metadata schema specified in the given event's header.
* For INTERNAL USE ONLY (by Espresso and Databus). This is not a stable API and may change
* without warning!
*
* @param e DbusEvent
* @return {AvroSchema, "metadata-source", version} tuple for given event 'e' with
* metadata-schema-id; null if event contains no metadata
* @throws DatabusRuntimeException if event contains metadata but schema to decode it is missing
*/
public VersionedSchema getMetadataSchema(DbusEvent e) {
DbusEventPart metadataPart = e.getPayloadMetadataPart();
if (null == metadataPart) {
LOG.debug("No metadata for event " + e);
return null;
}
VersionedSchema schema = getMetadataSchema(metadataPart);
if (null == schema) {
throw new DatabusRuntimeException("No schema available to decode metadata for event " + e);
}
return schema;
}
Aggregations