Search in sources :

Example 1 with AbstractMysqlEventParser

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

the class ParserCollector method register.

@Override
public void register(CanalInstance instance) {
    final String destination = instance.getDestination();
    ParserMetricsHolder holder;
    CanalEventParser parser = instance.getEventParser();
    if (parser instanceof AbstractMysqlEventParser) {
        holder = singleHolder(destination, (AbstractMysqlEventParser) parser, "0");
    } else if (parser instanceof GroupEventParser) {
        holder = groupHolder(destination, (GroupEventParser) parser);
    } else {
        throw new IllegalArgumentException("CanalEventParser must be either AbstractMysqlEventParser or GroupEventParser.");
    }
    Preconditions.checkNotNull(holder);
    ParserMetricsHolder old = instances.put(destination, holder);
    if (old != null) {
        logger.warn("Remove stale ParserCollector for instance {}.", destination);
    }
}
Also used : AbstractMysqlEventParser(com.alibaba.otter.canal.parse.inbound.mysql.AbstractMysqlEventParser) CanalEventParser(com.alibaba.otter.canal.parse.CanalEventParser) GroupEventParser(com.alibaba.otter.canal.parse.inbound.group.GroupEventParser)

Example 2 with AbstractMysqlEventParser

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

the class ParserCollector method groupHolder.

private GroupParserMetricsHolder groupHolder(String destination, GroupEventParser group) {
    List<CanalEventParser> parsers = group.getEventParsers();
    GroupParserMetricsHolder groupHolder = new GroupParserMetricsHolder();
    int num = parsers.size();
    for (int i = 0; i < num; i++) {
        CanalEventParser parser = parsers.get(i);
        if (parser instanceof AbstractMysqlEventParser) {
            ParserMetricsHolder single = singleHolder(destination, (AbstractMysqlEventParser) parser, Integer.toString(i + 1));
            groupHolder.holders.add(single);
        } else {
            logger.warn("Null or non AbstractMysqlEventParser, ignore.");
        }
    }
    return groupHolder;
}
Also used : AbstractMysqlEventParser(com.alibaba.otter.canal.parse.inbound.mysql.AbstractMysqlEventParser) CanalEventParser(com.alibaba.otter.canal.parse.CanalEventParser)

Aggregations

CanalEventParser (com.alibaba.otter.canal.parse.CanalEventParser)2 AbstractMysqlEventParser (com.alibaba.otter.canal.parse.inbound.mysql.AbstractMysqlEventParser)2 GroupEventParser (com.alibaba.otter.canal.parse.inbound.group.GroupEventParser)1