com.alibaba.otter.canal.parse.ha.CanalHAController Java Examples

The following examples show how to use com.alibaba.otter.canal.parse.ha.CanalHAController. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractCanalInstance.java    From canal-1.1.3 with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化单个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();
        }

    }
}
 
Example #2
Source File: AbstractCanalInstance.java    From canal-1.1.3 with Apache License 2.0 6 votes vote down vote up
protected void stopEventParserInternal(CanalEventParser eventParser) {
    if (eventParser instanceof AbstractEventParser) {
        AbstractEventParser abstractEventParser = (AbstractEventParser) eventParser;
        // 首先启动log position管理器
        CanalLogPositionManager logPositionManager = abstractEventParser.getLogPositionManager();
        if (logPositionManager.isStart()) {
            logPositionManager.stop();
        }
    }

    if (eventParser instanceof MysqlEventParser) {
        MysqlEventParser mysqlEventParser = (MysqlEventParser) eventParser;
        CanalHAController haController = mysqlEventParser.getHaController();
        if (haController.isStart()) {
            haController.stop();
        }
    }
}
 
Example #3
Source File: AbstractCanalInstance.java    From canal with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化单个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();
        }

    }
}
 
Example #4
Source File: AbstractCanalInstance.java    From canal with Apache License 2.0 6 votes vote down vote up
protected void stopEventParserInternal(CanalEventParser eventParser) {
    if (eventParser instanceof AbstractEventParser) {
        AbstractEventParser abstractEventParser = (AbstractEventParser) eventParser;
        // 首先启动log position管理器
        CanalLogPositionManager logPositionManager = abstractEventParser.getLogPositionManager();
        if (logPositionManager.isStart()) {
            logPositionManager.stop();
        }
    }

    if (eventParser instanceof MysqlEventParser) {
        MysqlEventParser mysqlEventParser = (MysqlEventParser) eventParser;
        CanalHAController haController = mysqlEventParser.getHaController();
        if (haController.isStart()) {
            haController.stop();
        }
    }
}
 
Example #5
Source File: CanalInstanceWithManager.java    From canal-1.1.3 with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #6
Source File: CanalInstanceWithManager.java    From canal with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #7
Source File: MysqlEventParser.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
public CanalHAController getHaController() {
    return haController;
}
 
Example #8
Source File: MysqlEventParser.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
public void setHaController(CanalHAController haController) {
    this.haController = haController;
}
 
Example #9
Source File: MysqlEventParser.java    From canal with Apache License 2.0 4 votes vote down vote up
public CanalHAController getHaController() {
    return haController;
}
 
Example #10
Source File: MysqlEventParser.java    From canal with Apache License 2.0 4 votes vote down vote up
public void setHaController(CanalHAController haController) {
    this.haController = haController;
}