Search in sources :

Example 1 with DatabaseTableMeta

use of com.alibaba.otter.canal.parse.inbound.mysql.tsdb.DatabaseTableMeta in project canal by alibaba.

the class LocalBinlogEventParser method preDump.

@Override
protected void preDump(ErosaConnection connection) {
    metaConnection = buildMysqlConnection();
    try {
        metaConnection.connect();
    } catch (IOException e) {
        throw new CanalParseException(e);
    }
    if (tableMetaTSDB != null && tableMetaTSDB instanceof DatabaseTableMeta) {
        ((DatabaseTableMeta) tableMetaTSDB).setConnection(metaConnection);
        ((DatabaseTableMeta) tableMetaTSDB).setFilter(eventFilter);
        ((DatabaseTableMeta) tableMetaTSDB).setBlackFilter(eventBlackFilter);
        ((DatabaseTableMeta) tableMetaTSDB).setSnapshotInterval(tsdbSnapshotInterval);
        ((DatabaseTableMeta) tableMetaTSDB).setSnapshotExpire(tsdbSnapshotExpire);
        ((DatabaseTableMeta) tableMetaTSDB).init(destination);
    }
    tableMetaCache = new TableMetaCache(metaConnection, tableMetaTSDB);
    ((LogEventConvert) binlogParser).setTableMetaCache(tableMetaCache);
}
Also used : LogEventConvert(com.alibaba.otter.canal.parse.inbound.mysql.dbsync.LogEventConvert) DatabaseTableMeta(com.alibaba.otter.canal.parse.inbound.mysql.tsdb.DatabaseTableMeta) IOException(java.io.IOException) TableMetaCache(com.alibaba.otter.canal.parse.inbound.mysql.dbsync.TableMetaCache) CanalParseException(com.alibaba.otter.canal.parse.exception.CanalParseException)

Example 2 with DatabaseTableMeta

use of com.alibaba.otter.canal.parse.inbound.mysql.tsdb.DatabaseTableMeta in project canal by alibaba.

the class MysqlEventParser method preDump.

protected void preDump(ErosaConnection connection) {
    if (!(connection instanceof MysqlConnection)) {
        throw new CanalParseException("Unsupported connection type : " + connection.getClass().getSimpleName());
    }
    if (binlogParser != null && binlogParser instanceof LogEventConvert) {
        metaConnection = (MysqlConnection) connection.fork();
        try {
            metaConnection.connect();
        } catch (IOException e) {
            throw new CanalParseException(e);
        }
        if (supportBinlogFormats != null && supportBinlogFormats.length > 0) {
            BinlogFormat format = ((MysqlConnection) metaConnection).getBinlogFormat();
            boolean found = false;
            for (BinlogFormat supportFormat : supportBinlogFormats) {
                if (supportFormat != null && format == supportFormat) {
                    found = true;
                    break;
                }
            }
            if (!found) {
                throw new CanalParseException("Unsupported BinlogFormat " + format);
            }
        }
        if (supportBinlogImages != null && supportBinlogImages.length > 0) {
            BinlogImage image = ((MysqlConnection) metaConnection).getBinlogImage();
            boolean found = false;
            for (BinlogImage supportImage : supportBinlogImages) {
                if (supportImage != null && image == supportImage) {
                    found = true;
                    break;
                }
            }
            if (!found) {
                throw new CanalParseException("Unsupported BinlogImage " + image);
            }
        }
        if (tableMetaTSDB != null && tableMetaTSDB instanceof DatabaseTableMeta) {
            ((DatabaseTableMeta) tableMetaTSDB).setConnection(metaConnection);
            ((DatabaseTableMeta) tableMetaTSDB).setFilter(eventFilter);
            ((DatabaseTableMeta) tableMetaTSDB).setBlackFilter(eventBlackFilter);
            ((DatabaseTableMeta) tableMetaTSDB).setSnapshotInterval(tsdbSnapshotInterval);
            ((DatabaseTableMeta) tableMetaTSDB).setSnapshotExpire(tsdbSnapshotExpire);
            ((DatabaseTableMeta) tableMetaTSDB).init(destination);
        }
        tableMetaCache = new TableMetaCache(metaConnection, tableMetaTSDB);
        ((LogEventConvert) binlogParser).setTableMetaCache(tableMetaCache);
    }
}
Also used : BinlogFormat(com.alibaba.otter.canal.parse.inbound.mysql.MysqlConnection.BinlogFormat) BinlogImage(com.alibaba.otter.canal.parse.inbound.mysql.MysqlConnection.BinlogImage) LogEventConvert(com.alibaba.otter.canal.parse.inbound.mysql.dbsync.LogEventConvert) DatabaseTableMeta(com.alibaba.otter.canal.parse.inbound.mysql.tsdb.DatabaseTableMeta) IOException(java.io.IOException) TableMetaCache(com.alibaba.otter.canal.parse.inbound.mysql.dbsync.TableMetaCache) CanalParseException(com.alibaba.otter.canal.parse.exception.CanalParseException)

Aggregations

CanalParseException (com.alibaba.otter.canal.parse.exception.CanalParseException)2 LogEventConvert (com.alibaba.otter.canal.parse.inbound.mysql.dbsync.LogEventConvert)2 TableMetaCache (com.alibaba.otter.canal.parse.inbound.mysql.dbsync.TableMetaCache)2 DatabaseTableMeta (com.alibaba.otter.canal.parse.inbound.mysql.tsdb.DatabaseTableMeta)2 IOException (java.io.IOException)2 BinlogFormat (com.alibaba.otter.canal.parse.inbound.mysql.MysqlConnection.BinlogFormat)1 BinlogImage (com.alibaba.otter.canal.parse.inbound.mysql.MysqlConnection.BinlogImage)1