Java Code Examples for com.github.shyiko.mysql.binlog.event.EventHeaderV4

The following examples show how to use com.github.shyiko.mysql.binlog.event.EventHeaderV4. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: openmessaging-connect-odar   Source File: EventProcessor.java    License: Apache License 2.0 6 votes vote down vote up
private void processXidEvent(Event event) {
    EventHeaderV4 header = event.getHeader();
    XidEventData data = event.getData();

    String binlogFilename = binaryLogClient.getBinlogFilename();
    Long position = header.getNextPosition();
    Long xid = data.getXid();

    BinlogPosition binlogPosition = new BinlogPosition(binlogFilename, position);
    transaction.setNextBinlogPosition(binlogPosition);
    transaction.setXid(xid);

    replicator.commit(transaction, true);

    transaction = new Transaction(config);
}
 
Example 2
Source Project: SpinalTap   Source File: BinaryLogConnectorSource.java    License: Apache License 2.0 6 votes vote down vote up
public void onEvent(Event event) {
  Preconditions.checkState(isStarted(), "Source is not started and should not process events");

  final EventHeaderV4 header = event.getHeader();
  final BinlogFilePos filePos =
      new BinlogFilePos(
          binlogClient.getBinlogFilename(),
          header.getPosition(),
          header.getNextPosition(),
          binlogClient.getGtidSet(),
          serverUUID);

  BinaryLogConnectorEventMapper.INSTANCE
      .map(event, filePos)
      .ifPresent(BinaryLogConnectorSource.super::processEvent);
}
 
Example 3
Source Project: syncer   Source File: DataId.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * <a href="https://github.com/shyiko/mysql-binlog-connector-java/issues/200">binlog table
 * map</a>
 */
static BinlogDataId fromEvent(Event[] event, String binlogFileName) {
  EventHeaderV4 tableMap = event[0].getHeader();
  EventHeaderV4 second = event[1].getHeader();
  // have to remember table map event for restart
  // have to add data event position for unique id:
  // because one table map event may follow multiple data event
  return new BinlogDataId(binlogFileName, tableMap.getPosition(), second.getPosition());
}
 
Example 4
Source Project: datacollector   Source File: BinaryLogConsumer.java    License: Apache License 2.0 5 votes vote down vote up
private SourceOffset createOffset(Event event) {
  if (isGtidEnabled()) {
    return new GtidSourceOffset(currentGtidSet)
        .withIncompleteTransaction(currentTxGtid, currentTxEventSeqNo);
  } else {
    return new BinLogPositionSourceOffset(
        currentBinLogFileName,
        ((EventHeaderV4) event.getHeader()).getNextPosition()
    );
  }
}
 
Example 5
Source Project: datacollector   Source File: BinaryLogConsumer.java    License: Apache License 2.0 5 votes vote down vote up
private SourceOffset createOffset(Event event) {
  if (isGtidEnabled()) {
    return new GtidSourceOffset(currentGtidSet)
        .withIncompleteTransaction(currentTxGtid, currentTxEventSeqNo);
  } else {
    return new BinLogPositionSourceOffset(
        currentBinLogFileName,
        ((EventHeaderV4) event.getHeader()).getNextPosition()
    );
  }
}