Beispiel #1
0
  protected void preDump(ErosaConnection connection) {
    if (!(connection instanceof MysqlConnection)) {
      throw new CanalParseException(
          "Unsupported connection type : " + connection.getClass().getSimpleName());
    }

    // 开始启动心跳包
    if (detectingEnable && StringUtils.isNotBlank(detectingSQL)) {
      // fixed issue #56,避免重复创建heartbeat线程
      if (mysqlHeartBeatTimeTask == null) {
        logger.info("start heart beat.... ");
        startHeartbeat((MysqlConnection) connection.fork());
      }
    }

    if (binlogParser != null && binlogParser instanceof LogEventConvert) {
      metaConnection = (MysqlConnection) connection.fork();
      try {
        metaConnection.connect();
      } catch (IOException e) {
        throw new CanalParseException(e);
      }

      tableMetaCache = new TableMetaCache(metaConnection);
      ((LogEventConvert) binlogParser).setTableMetaCache(tableMetaCache);
    }
  }
  public void setEventBlackFilter(CanalEventFilter eventBlackFilter) {
    super.setEventBlackFilter(eventBlackFilter);

    // 触发一下filter变更
    if (eventBlackFilter != null
        && eventBlackFilter instanceof AviaterRegexFilter
        && binlogParser instanceof LogEventConvert) {
      ((LogEventConvert) binlogParser).setNameBlackFilter((AviaterRegexFilter) eventBlackFilter);
    }
  }
  @Override
  protected void preDump(ErosaConnection connection) {
    metaConnection = buildMysqlConnection();
    try {
      metaConnection.connect();
    } catch (IOException e) {
      throw new CanalParseException(e);
    }

    tableMetaCache = new TableMetaCache(metaConnection);
    ((LogEventConvert) binlogParser).setTableMetaCache(tableMetaCache);
  }
  protected BinlogParser buildParser() {
    LogEventConvert convert = new LogEventConvert();
    if (eventFilter != null && eventFilter instanceof AviaterRegexFilter) {
      convert.setNameFilter((AviaterRegexFilter) eventFilter);
    }

    if (eventBlackFilter != null && eventBlackFilter instanceof AviaterRegexFilter) {
      convert.setNameBlackFilter((AviaterRegexFilter) eventBlackFilter);
    }

    convert.setCharset(connectionCharset);
    convert.setFilterQueryDcl(filterQueryDcl);
    convert.setFilterQueryDml(filterQueryDml);
    convert.setFilterQueryDdl(filterQueryDdl);
    convert.setFilterRows(filterRows);
    convert.setFilterTableError(filterTableError);
    return convert;
  }