Search in sources :

Example 1 with CanalLogPositionManager

use of com.alibaba.otter.canal.parse.index.CanalLogPositionManager in project canal by alibaba.

the class AbstractCanalInstance method stopEventParserInternal.

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();
        }
    }
}
Also used : CanalLogPositionManager(com.alibaba.otter.canal.parse.index.CanalLogPositionManager) MysqlEventParser(com.alibaba.otter.canal.parse.inbound.mysql.MysqlEventParser) AbstractEventParser(com.alibaba.otter.canal.parse.inbound.AbstractEventParser) CanalHAController(com.alibaba.otter.canal.parse.ha.CanalHAController)

Example 2 with CanalLogPositionManager

use of com.alibaba.otter.canal.parse.index.CanalLogPositionManager 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 3 with CanalLogPositionManager

use of com.alibaba.otter.canal.parse.index.CanalLogPositionManager in project canal by alibaba.

the class CanalInstanceWithManager method initLogPositionManager.

protected CanalLogPositionManager initLogPositionManager() {
    logger.info("init logPositionPersistManager begin...");
    IndexMode indexMode = parameters.getIndexMode();
    CanalLogPositionManager logPositionManager = null;
    if (indexMode.isMemory()) {
        logPositionManager = new MemoryLogPositionManager();
    } else if (indexMode.isZookeeper()) {
        logPositionManager = new ZooKeeperLogPositionManager();
        ((ZooKeeperLogPositionManager) logPositionManager).setZkClientx(getZkclientx());
    } else if (indexMode.isMixed()) {
        logPositionManager = new PeriodMixedLogPositionManager();
        ZooKeeperLogPositionManager zooKeeperLogPositionManager = new ZooKeeperLogPositionManager();
        zooKeeperLogPositionManager.setZkClientx(getZkclientx());
        ((PeriodMixedLogPositionManager) logPositionManager).setZooKeeperLogPositionManager(zooKeeperLogPositionManager);
    } else if (indexMode.isMeta()) {
        logPositionManager = new MetaLogPositionManager();
        ((MetaLogPositionManager) logPositionManager).setMetaManager(metaManager);
    } else if (indexMode.isMemoryMetaFailback()) {
        MemoryLogPositionManager primaryLogPositionManager = new MemoryLogPositionManager();
        MetaLogPositionManager failbackLogPositionManager = new MetaLogPositionManager();
        failbackLogPositionManager.setMetaManager(metaManager);
        logPositionManager = new FailbackLogPositionManager();
        ((FailbackLogPositionManager) logPositionManager).setPrimary(primaryLogPositionManager);
        ((FailbackLogPositionManager) logPositionManager).setFailback(failbackLogPositionManager);
    } else {
        throw new CanalException("unsupport indexMode for " + indexMode);
    }
    logger.info("init logPositionManager end! \n\t load CanalLogPositionManager:{}", logPositionManager.getClass().getName());
    return logPositionManager;
}
Also used : MemoryLogPositionManager(com.alibaba.otter.canal.parse.index.MemoryLogPositionManager) FailbackLogPositionManager(com.alibaba.otter.canal.parse.index.FailbackLogPositionManager) CanalLogPositionManager(com.alibaba.otter.canal.parse.index.CanalLogPositionManager) MetaLogPositionManager(com.alibaba.otter.canal.parse.index.MetaLogPositionManager) IndexMode(com.alibaba.otter.canal.instance.manager.model.CanalParameter.IndexMode) ZooKeeperLogPositionManager(com.alibaba.otter.canal.parse.index.ZooKeeperLogPositionManager) PeriodMixedLogPositionManager(com.alibaba.otter.canal.parse.index.PeriodMixedLogPositionManager) CanalException(com.alibaba.otter.canal.common.CanalException)

Aggregations

CanalLogPositionManager (com.alibaba.otter.canal.parse.index.CanalLogPositionManager)3 CanalHAController (com.alibaba.otter.canal.parse.ha.CanalHAController)2 AbstractEventParser (com.alibaba.otter.canal.parse.inbound.AbstractEventParser)2 MysqlEventParser (com.alibaba.otter.canal.parse.inbound.mysql.MysqlEventParser)2 CanalException (com.alibaba.otter.canal.common.CanalException)1 IndexMode (com.alibaba.otter.canal.instance.manager.model.CanalParameter.IndexMode)1 HeartBeatHAController (com.alibaba.otter.canal.parse.ha.HeartBeatHAController)1 FailbackLogPositionManager (com.alibaba.otter.canal.parse.index.FailbackLogPositionManager)1 MemoryLogPositionManager (com.alibaba.otter.canal.parse.index.MemoryLogPositionManager)1 MetaLogPositionManager (com.alibaba.otter.canal.parse.index.MetaLogPositionManager)1 PeriodMixedLogPositionManager (com.alibaba.otter.canal.parse.index.PeriodMixedLogPositionManager)1 ZooKeeperLogPositionManager (com.alibaba.otter.canal.parse.index.ZooKeeperLogPositionManager)1