Search in sources :

Example 1 with StorageScavengeMode

use of com.alibaba.otter.canal.instance.manager.model.CanalParameter.StorageScavengeMode in project canal by alibaba.

the class CanalInstanceWithManager method initEventStore.

protected void initEventStore() {
    logger.info("init eventStore begin...");
    StorageMode mode = parameters.getStorageMode();
    if (mode.isMemory()) {
        MemoryEventStoreWithBuffer memoryEventStore = new MemoryEventStoreWithBuffer();
        memoryEventStore.setBufferSize(parameters.getMemoryStorageBufferSize());
        memoryEventStore.setBufferMemUnit(parameters.getMemoryStorageBufferMemUnit());
        memoryEventStore.setBatchMode(BatchMode.valueOf(parameters.getStorageBatchMode().name()));
        memoryEventStore.setDdlIsolation(parameters.getDdlIsolation());
        eventStore = memoryEventStore;
    } else if (mode.isFile()) {
        // 后续版本支持
        throw new CanalException("unsupport MetaMode for " + mode);
    } else if (mode.isMixed()) {
        // 后续版本支持
        throw new CanalException("unsupport MetaMode for " + mode);
    } else {
        throw new CanalException("unsupport MetaMode for " + mode);
    }
    if (eventStore instanceof AbstractCanalStoreScavenge) {
        StorageScavengeMode scavengeMode = parameters.getStorageScavengeMode();
        AbstractCanalStoreScavenge eventScavengeStore = (AbstractCanalStoreScavenge) eventStore;
        eventScavengeStore.setDestination(destination);
        eventScavengeStore.setCanalMetaManager(metaManager);
        eventScavengeStore.setOnAck(scavengeMode.isOnAck());
        eventScavengeStore.setOnFull(scavengeMode.isOnFull());
        eventScavengeStore.setOnSchedule(scavengeMode.isOnSchedule());
        if (scavengeMode.isOnSchedule()) {
            eventScavengeStore.setScavengeSchedule(parameters.getScavengeSchdule());
        }
    }
    logger.info("init eventStore end! \n\t load CanalEventStore:{}", eventStore.getClass().getName());
}
Also used : MemoryEventStoreWithBuffer(com.alibaba.otter.canal.store.memory.MemoryEventStoreWithBuffer) StorageScavengeMode(com.alibaba.otter.canal.instance.manager.model.CanalParameter.StorageScavengeMode) StorageMode(com.alibaba.otter.canal.instance.manager.model.CanalParameter.StorageMode) AbstractCanalStoreScavenge(com.alibaba.otter.canal.store.AbstractCanalStoreScavenge) CanalException(com.alibaba.otter.canal.common.CanalException)

Aggregations

CanalException (com.alibaba.otter.canal.common.CanalException)1 StorageMode (com.alibaba.otter.canal.instance.manager.model.CanalParameter.StorageMode)1 StorageScavengeMode (com.alibaba.otter.canal.instance.manager.model.CanalParameter.StorageScavengeMode)1 AbstractCanalStoreScavenge (com.alibaba.otter.canal.store.AbstractCanalStoreScavenge)1 MemoryEventStoreWithBuffer (com.alibaba.otter.canal.store.memory.MemoryEventStoreWithBuffer)1