本文整理汇总了Java中com.github.shyiko.mysql.binlog.event.Event.getData方法的典型用法代码示例。如果您正苦于以下问题:Java Event.getData方法的具体用法?Java Event.getData怎么用?Java Event.getData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.shyiko.mysql.binlog.event.Event
的用法示例。
在下文中一共展示了Event.getData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dispatch
import com.github.shyiko.mysql.binlog.event.Event; //导入方法依赖的package包/类
void dispatch(Event evt) {
Object data = evt.getData();
if (TableMapEventData.class.isInstance(data)) {
handleTableMapEvent((TableMapEventData) data);
} else if (EventType.isWrite(evt.getHeader().getEventType())) {
handleWriteEvent((WriteRowsEventData) data);
} else if (EventType.isUpdate(evt.getHeader().getEventType())) {
handleUpdateEvent((UpdateRowsEventData) data);
} else if (EventType.isDelete(evt.getHeader().getEventType())) {
handleDeleteEvent((DeleteRowsEventData) data);
} else if (QueryEventData.class.isInstance(data)) {
handleQueryEvent((QueryEventData) data);
}
}
示例2: onEvent
import com.github.shyiko.mysql.binlog.event.Event; //导入方法依赖的package包/类
@Override
public void onEvent(Event event) {
try {
EventData data = event.getData();
if (! (event.getHeader() instanceof EventHeaderV4)) {
throw new RuntimeException("Header is not V4!");
}
System.out.println(event);
EventHeaderV4 header = event.getHeader();
List<DataChange> dataChanges = new ArrayList<DataChange>();
EventType type = header.getEventType();
if (type == EventType.TABLE_MAP) {
handleTableMap((TableMapEventData) data);
} else if (EventType.isWrite(type)) {
handleWriteRows((WriteRowsEventData) data, dataChanges);
} else if (EventType.isDelete(type)) {
handleDeleteRows((DeleteRowsEventData) data, dataChanges);
} else if (EventType.isUpdate(type)) {
handleUpdateRows((UpdateRowsEventData) data, dataChanges);
} else if (type == EventType.QUERY) {
handleQuery((QueryEventData) data, header);
} else if (type == EventType.ROTATE) {
handleRotate((RotateEventData) data);
} else if (type == EventType.XID) {
handleXid((XidEventData) data, header);
}
for (DataChange change : dataChanges) {
change.setOffset(this.transactionStartPosition,
this.binlogFilename, header.getPosition());
change.setServerId(this.mysqlServerId);
outputter.output(change);
}
outputter.flush();
} catch (Throwable e) {
// during development, on any and all errors, disconnect.
// This allows me to learn what errors will happen, and how to
// handle each one appropriately.
e.printStackTrace();
try {
this.binlogClient.disconnect();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
示例3: onEvent
import com.github.shyiko.mysql.binlog.event.Event; //导入方法依赖的package包/类
@Override
public void onEvent(Event event) {
LOG.trace("Received event {}", event);
EventType eventType = event.getHeader().getEventType();
currentBinLogFileName = client.getBinlogFilename();
switch (eventType) {
case TABLE_MAP:
handleTableMappingEvent((TableMapEventData) event.getData());
break;
case PRE_GA_WRITE_ROWS:
case WRITE_ROWS:
case EXT_WRITE_ROWS:
handleRowEvent(event, event.<WriteRowsEventData>getData().getTableId());
break;
case PRE_GA_UPDATE_ROWS:
case UPDATE_ROWS:
case EXT_UPDATE_ROWS:
handleRowEvent(event, event.<UpdateRowsEventData>getData().getTableId());
break;
case PRE_GA_DELETE_ROWS:
case DELETE_ROWS:
case EXT_DELETE_ROWS:
handleRowEvent(event, event.<DeleteRowsEventData>getData().getTableId());
break;
case QUERY:
QueryEventData queryEventData = event.getData();
String query = queryEventData.getSql();
if (isCommit(query)) {
finishTx();
} else if (isSchemaChangeQuery(query)) {
schemaRepository.evictAll();
}
break;
case XID:
finishTx();
break;
case GTID:
GtidEventData eventData = event.getData();
currentGtidSet = client.getGtidSet();
currentTxGtid = eventData.getGtid();
currentTxEventSeqNo = 0;
LOG.trace("Started new tx, gtid: {}", currentTxGtid);
break;
default:
// ignore
break;
}
}