当前位置: 首页>>代码示例>>Java>>正文


Java Event.getData方法代码示例

本文整理汇总了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);
  }
}
 
开发者ID:guoyu511,项目名称:vertx-mysql-binlog-client,代码行数:15,代码来源:EventDispatcher.java

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

    }
}
 
开发者ID:TiVo,项目名称:wombat,代码行数:56,代码来源:EventHandler.java

示例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;
  }
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:49,代码来源:BinaryLogConsumer.java


注:本文中的com.github.shyiko.mysql.binlog.event.Event.getData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。