Search in sources :

Example 1 with FailbackLogPositionManager

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

CanalException (com.alibaba.otter.canal.common.CanalException)1 IndexMode (com.alibaba.otter.canal.instance.manager.model.CanalParameter.IndexMode)1 CanalLogPositionManager (com.alibaba.otter.canal.parse.index.CanalLogPositionManager)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