Search in sources :

Example 1 with HeartBeatHAController

use of com.alibaba.otter.canal.parse.ha.HeartBeatHAController in project canal by alibaba.

the class AbstractCanalInstance method startEventParserInternal.

/**
 * 初始化单个eventParser,不需要考虑group
 */
protected void startEventParserInternal(CanalEventParser eventParser, boolean isGroup) {
    if (eventParser instanceof AbstractEventParser) {
        AbstractEventParser abstractEventParser = (AbstractEventParser) eventParser;
        // 首先启动log position管理器
        CanalLogPositionManager logPositionManager = abstractEventParser.getLogPositionManager();
        if (!logPositionManager.isStart()) {
            logPositionManager.start();
        }
    }
    if (eventParser instanceof MysqlEventParser) {
        MysqlEventParser mysqlEventParser = (MysqlEventParser) eventParser;
        CanalHAController haController = mysqlEventParser.getHaController();
        if (haController instanceof HeartBeatHAController) {
            ((HeartBeatHAController) haController).setCanalHASwitchable(mysqlEventParser);
        }
        if (!haController.isStart()) {
            haController.start();
        }
    }
}
Also used : CanalLogPositionManager(com.alibaba.otter.canal.parse.index.CanalLogPositionManager) MysqlEventParser(com.alibaba.otter.canal.parse.inbound.mysql.MysqlEventParser) HeartBeatHAController(com.alibaba.otter.canal.parse.ha.HeartBeatHAController) AbstractEventParser(com.alibaba.otter.canal.parse.inbound.AbstractEventParser) CanalHAController(com.alibaba.otter.canal.parse.ha.CanalHAController)

Example 2 with HeartBeatHAController

use of com.alibaba.otter.canal.parse.ha.HeartBeatHAController in project canal by alibaba.

the class CanalInstanceWithManager method initHaController.

protected CanalHAController initHaController() {
    logger.info("init haController begin...");
    HAMode haMode = parameters.getHaMode();
    CanalHAController haController = null;
    if (haMode.isHeartBeat()) {
        haController = new HeartBeatHAController();
        ((HeartBeatHAController) haController).setDetectingRetryTimes(parameters.getDetectingRetryTimes());
        ((HeartBeatHAController) haController).setSwitchEnable(parameters.getHeartbeatHaEnable());
    } else {
        throw new CanalException("unsupport HAMode for " + haMode);
    }
    logger.info("init haController end! \n\t load CanalHAController:{}", haController.getClass().getName());
    return haController;
}
Also used : HeartBeatHAController(com.alibaba.otter.canal.parse.ha.HeartBeatHAController) HAMode(com.alibaba.otter.canal.instance.manager.model.CanalParameter.HAMode) CanalHAController(com.alibaba.otter.canal.parse.ha.CanalHAController) CanalException(com.alibaba.otter.canal.common.CanalException)

Aggregations

CanalHAController (com.alibaba.otter.canal.parse.ha.CanalHAController)2 HeartBeatHAController (com.alibaba.otter.canal.parse.ha.HeartBeatHAController)2 CanalException (com.alibaba.otter.canal.common.CanalException)1 HAMode (com.alibaba.otter.canal.instance.manager.model.CanalParameter.HAMode)1 AbstractEventParser (com.alibaba.otter.canal.parse.inbound.AbstractEventParser)1 MysqlEventParser (com.alibaba.otter.canal.parse.inbound.mysql.MysqlEventParser)1 CanalLogPositionManager (com.alibaba.otter.canal.parse.index.CanalLogPositionManager)1