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


Java Event类代码示例

本文整理汇总了Java中com.github.shyiko.mysql.binlog.event.Event的典型用法代码示例。如果您正苦于以下问题:Java Event类的具体用法?Java Event怎么用?Java Event使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Event类属于com.github.shyiko.mysql.binlog.event包,在下文中一共展示了Event类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handle

import com.github.shyiko.mysql.binlog.event.Event; //导入依赖的package包/类
private void handle(Event eventSrc) {
  if (!connected) {
    return;
  }
  try {
    lock.lock();
    if (pending) {
      pendingCondition.await();
    }
    context.runOnContext((v) ->
      dispatcher.dispatch(eventSrc)
    );
  } catch (Exception e) {
    context.runOnContext((v) -> {
      if (exceptionHandler != null) {
        exceptionHandler.handle(e);
      }
    });
  } finally {
    lock.unlock();
  }
}
 
开发者ID:guoyu511,项目名称:vertx-mysql-binlog-client,代码行数:23,代码来源:BinlogClientImpl.java

示例2: onEvent

import com.github.shyiko.mysql.binlog.event.Event; //导入依赖的package包/类
public void onEvent(Event event) {
    try {
        System.out.println(event);
        events.add(event);
        EventType type = event.getHeader().getEventType();
        if (EventType.isDelete(type) || EventType.isUpdate(type) || EventType.isWrite(type)) {
            List<PackagedEvent> packagedEvents = new ArrayList<PackagedEvent>();
            PackagedEvent packagedEvent = new PackagedEvent(events);
            if (!packagedEvent.filterOutBy(EventFilter.getAllFilters())) {
                packagedEvents.add(packagedEvent);
            }

            ui.displayEvent(packagedEvents);
            events.clear();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:xumc,项目名称:easy_db_checker,代码行数:20,代码来源:EventListener.java

示例3: 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

示例4: createTableMapEvent

import com.github.shyiko.mysql.binlog.event.Event; //导入依赖的package包/类
public Event createTableMapEvent(int tableId, String database, String table) {
	EventHeaderV4 eventHeader = new EventHeaderV4();
	eventHeader.setEventType(EventType.TABLE_MAP);
	
	TableMapEventData eventData = new TableMapEventData();
	eventData.setTableId(tableId);
	eventData.setDatabase(database);
	eventData.setTable(table);
	
	return new Event(eventHeader, eventData);
}
 
开发者ID:mrkamel,项目名称:replicaza,代码行数:12,代码来源:BinlogEventListenerTest.java

示例5: createOffset

import com.github.shyiko.mysql.binlog.event.Event; //导入依赖的package包/类
private SourceOffset createOffset(Event event) {
  if (isGtidEnabled()) {
    return new GtidSourceOffset(currentGtidSet)
        .withIncompleteTransaction(currentTxGtid, currentTxEventSeqNo);
  } else {
    return new BinLogPositionSourceOffset(
        currentBinLogFileName,
        ((EventHeaderV4) event.getHeader()).getNextPosition()
    );
  }
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:12,代码来源:BinaryLogConsumer.java

示例6: 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

示例7: testOnEventWriteRows

import com.github.shyiko.mysql.binlog.event.Event; //导入依赖的package包/类
public void testOnEventWriteRows() {
	BinlogEventListener binlogEventListener = new BinlogEventListener(createBinaryLogClient(), createKafkaProducer());
	
	binlogEventListener.onEvent(createTableMapEvent(1, "database", "table"));
	
	EventHeaderV4 eventHeader = new EventHeaderV4();
	eventHeader.setEventType(EventType.EXT_WRITE_ROWS);
	
	WriteRowsEventData eventData = new WriteRowsEventData();
	eventData.setTableId(1);
	
	List<Serializable[]> rows = new ArrayList<Serializable[]>();
	
	Serializable[] row = { "1" };
	
	rows.add(row);
	
	eventData.setRows(rows);
	
	binlogEventListener.onEvent(new Event(eventHeader, eventData));
}
 
开发者ID:mrkamel,项目名称:replicaza,代码行数:22,代码来源:BinlogEventListenerTest.java

示例8: testOnEventDeleteRows

import com.github.shyiko.mysql.binlog.event.Event; //导入依赖的package包/类
public void testOnEventDeleteRows() {
	BinlogEventListener binlogEventListener = new BinlogEventListener(createBinaryLogClient(), createKafkaProducer());
	
	binlogEventListener.onEvent(createTableMapEvent(1, "database", "table"));
	
	EventHeaderV4 eventHeader = new EventHeaderV4();
	eventHeader.setEventType(EventType.EXT_DELETE_ROWS);
	
	DeleteRowsEventData eventData = new DeleteRowsEventData();
	eventData.setTableId(1);
	
	List<Serializable[]> rows = new ArrayList<Serializable[]>();
	
	Serializable[] row = { "1" };
	
	rows.add(row);
	
	eventData.setRows(rows);
	
	binlogEventListener.onEvent(new Event(eventHeader, eventData));
}
 
开发者ID:mrkamel,项目名称:replicaza,代码行数:22,代码来源:BinlogEventListenerTest.java

示例9: testOnEventUpdateRows

import com.github.shyiko.mysql.binlog.event.Event; //导入依赖的package包/类
public void testOnEventUpdateRows() {
	BinlogEventListener binlogEventListener = new BinlogEventListener(createBinaryLogClient(), createKafkaProducer());
	
	binlogEventListener.onEvent(createTableMapEvent(1, "database", "table"));
	
	EventHeaderV4 eventHeader = new EventHeaderV4();
	eventHeader.setEventType(EventType.EXT_UPDATE_ROWS);
	
	UpdateRowsEventData eventData = new UpdateRowsEventData();
	eventData.setTableId(1);
	
	List<Map.Entry<Serializable[], Serializable[]>> rows = new ArrayList<Map.Entry<Serializable[], Serializable[]>>();
	
	Serializable[] row = { "1" };
	
	rows.add(new AbstractMap.SimpleEntry<Serializable[], Serializable[]>(row, row));
	
	eventData.setRows(rows);
	
	binlogEventListener.onEvent(new Event(eventHeader, eventData));
}
 
开发者ID:mrkamel,项目名称:replicaza,代码行数:22,代码来源:BinlogEventListenerTest.java

示例10: EventError

import com.github.shyiko.mysql.binlog.event.Event; //导入依赖的package包/类
public EventError(Event event, SourceOffset offset, Exception exception) {
  this.event = event;
  this.offset = offset;
  this.exception = exception;
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:6,代码来源:EventError.java

示例11: getEvent

import com.github.shyiko.mysql.binlog.event.Event; //导入依赖的package包/类
public Event getEvent() {
  return event;
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:4,代码来源:EventError.java

示例12: 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

示例13: handleRowEvent

import com.github.shyiko.mysql.binlog.event.Event; //导入依赖的package包/类
private void handleRowEvent(Event event, long tableId) {
  LOG.trace("New event, current offset: {}, event: {}", currentOffset, event);
  currentTxEventSeqNo++;

  // for gtid offsets it is impossible to position client to precise position (it always positions to tx beginning)
  // so we need to add additional filtering based on event seqNo and skip some events
  if (currentOffset instanceof GtidSourceOffset) {
    if (((GtidSourceOffset) currentOffset).incompleteTransactionsContain(currentTxGtid, currentTxEventSeqNo)) {
      LOG.info("Skipping event gtid {}, seqNo {}", currentTxGtid, currentTxEventSeqNo);
      // skip
      return;
    } else {
      // record current gtid + seqNo as incomplete tx
      currentOffset = ((GtidSourceOffset) currentOffset)
          .withIncompleteTransaction(currentTxGtid, currentTxEventSeqNo)
          .withGtidSet(currentGtidSet);
    }
  } else {
    // current offset is null or gtid mode off
    currentOffset = createOffset(event);
  }

  DatabaseAndTable tableName = tableMapping.get(tableId);
  Optional<? extends Table> tableOpt = schemaRepository.getTable(tableName);
  Table table = null;
  if (tableOpt.isPresent()) {
    table = tableOpt.get();
  } else {
    LOG.error(Errors.MYSQL_002.getMessage(), tableName.getDatabase(), tableName.getTable());
    // fallback to table without columns names
    table = new TableWithoutColumnsNames(tableName.getDatabase(), tableName.getTable());
  }
  EnrichedEvent enrichedEvent = new EnrichedEvent(event, table, currentOffset);
  if (!eventBuffer.put(enrichedEvent)) {
    LOG.error("Error adding event to buffer. Closing event buffer, disconnecting client.");
    eventBuffer.close();
    try {
      client.disconnect();
    } catch (IOException e) {
      LOG.error("Error disconnecting client: {}", e.getMessage(), e);
    }
  }
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:44,代码来源:BinaryLogConsumer.java

示例14: EnrichedEvent

import com.github.shyiko.mysql.binlog.event.Event; //导入依赖的package包/类
public EnrichedEvent(Event event, Table table, SourceOffset offset) {
  this.event = event;
  this.table = table;
  this.offset = offset;
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:6,代码来源:EnrichedEvent.java

示例15: EventListener

import com.github.shyiko.mysql.binlog.event.Event; //导入依赖的package包/类
public EventListener(UI ui) {
    this.ui = ui;
    events = new ArrayList<Event>();
}
 
开发者ID:xumc,项目名称:easy_db_checker,代码行数:5,代码来源:EventListener.java


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