use of com.github.shyiko.mysql.binlog.event.WriteRowsEventData in project SpinalTap by airbnb.
the class MysqlSource method toBinlogEvent.
public static BinlogEvent toBinlogEvent(Event event, BinlogFilePos filePos) {
EventHeaderV4 header = event.getHeader();
EventType eventType = header.getEventType();
long serverId = header.getServerId();
long timestamp = header.getTimestamp();
if (EventType.isWrite(eventType)) {
WriteRowsEventData data = event.getData();
return new WriteEvent(data.getTableId(), serverId, timestamp, filePos, data.getRows());
} else if (EventType.isUpdate(eventType)) {
UpdateRowsEventData data = event.getData();
return new UpdateEvent(data.getTableId(), serverId, timestamp, filePos, data.getRows());
} else if (EventType.isDelete(eventType)) {
DeleteRowsEventData data = event.getData();
return new DeleteEvent(data.getTableId(), serverId, timestamp, filePos, data.getRows());
} else {
switch(eventType) {
case TABLE_MAP:
TableMapEventData tableMapData = event.getData();
return new TableMapEvent(tableMapData.getTableId(), serverId, timestamp, filePos, tableMapData.getDatabase(), tableMapData.getTable(), tableMapData.getColumnTypes());
case XID:
XidEventData xidData = event.getData();
return new XidEvent(serverId, timestamp, filePos, xidData.getXid());
case QUERY:
QueryEventData queryData = event.getData();
return new QueryEvent(serverId, timestamp, filePos, queryData.getDatabase(), queryData.getSql());
case FORMAT_DESCRIPTION:
return new StartEvent(serverId, timestamp, filePos);
default:
return null;
}
}
}
use of com.github.shyiko.mysql.binlog.event.WriteRowsEventData in project debezium by debezium.
the class BinlogReader method handleInsert.
/**
* Generate source records for the supplied event with an {@link WriteRowsEventData}.
*
* @param event the database change data event to be processed; may not be null
* @throws InterruptedException if this thread is interrupted while blocking
*/
protected void handleInsert(Event event) throws InterruptedException {
if (skipEvent) {
// We can skip this because we should already be at least this far ...
logger.debug("Skipping previously processed row event: {}", event);
return;
}
if (ignoreDmlEventByGtidSource) {
logger.debug("Skipping DML event because this GTID source is filtered: {}", event);
return;
}
WriteRowsEventData write = unwrapData(event);
long tableNumber = write.getTableId();
BitSet includedColumns = write.getIncludedColumns();
RecordsForTable recordMaker = recordMakers.forTable(tableNumber, includedColumns, super::enqueueRecord);
if (recordMaker != null) {
List<Serializable[]> rows = write.getRows();
Long ts = context.getClock().currentTimeInMillis();
int count = 0;
int numRows = rows.size();
if (startingRowNumber < numRows) {
for (int row = startingRowNumber; row != numRows; ++row) {
count += recordMaker.create(rows.get(row), ts, row, numRows);
}
if (logger.isDebugEnabled()) {
if (startingRowNumber != 0) {
logger.debug("Recorded {} insert record(s) for last {} row(s) in event: {}", count, numRows - startingRowNumber, event);
} else {
logger.debug("Recorded {} insert record(s) for event: {}", count, event);
}
}
} else {
// All rows were previously processed ...
logger.debug("Skipping previously processed insert event: {}", event);
}
} else {
informAboutUnknownTableIfRequired(event, recordMakers.getTableIdFromTableNumber(tableNumber), "insert row");
}
startingRowNumber = 0;
}
use of com.github.shyiko.mysql.binlog.event.WriteRowsEventData in project rocketmq-externals by apache.
the class EventProcessor method processWriteEvent.
private void processWriteEvent(Event event) {
WriteRowsEventData data = event.getData();
Long tableId = data.getTableId();
List<Serializable[]> list = data.getRows();
for (Serializable[] row : list) {
addRow("WRITE", tableId, row);
}
}
Aggregations