com.alibaba.otter.canal.parse.inbound.mysql.MysqlEventParser Java Examples
The following examples show how to use
com.alibaba.otter.canal.parse.inbound.mysql.MysqlEventParser.
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 |
/** * 初始化单个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 |
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 |
/** * 初始化单个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 |
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: GroupEventPaserTest.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
@Test public void testMysqlWithMysql() { // MemoryEventStoreWithBuffer eventStore = new // MemoryEventStoreWithBuffer(); // eventStore.setBufferSize(8196); GroupEventSink eventSink = new GroupEventSink(3); eventSink.setFilterTransactionEntry(false); eventSink.setEventStore(new DummyEventStore()); eventSink.start(); // 构造第一个mysql MysqlEventParser mysqlEventPaser1 = buildEventParser(3344); mysqlEventPaser1.setEventSink(eventSink); // 构造第二个mysql MysqlEventParser mysqlEventPaser2 = buildEventParser(3345); mysqlEventPaser2.setEventSink(eventSink); // 构造第二个mysql MysqlEventParser mysqlEventPaser3 = buildEventParser(3346); mysqlEventPaser3.setEventSink(eventSink); // 启动 mysqlEventPaser1.start(); mysqlEventPaser2.start(); mysqlEventPaser3.start(); try { Thread.sleep(30 * 10 * 1000L); } catch (InterruptedException e) { } mysqlEventPaser1.stop(); mysqlEventPaser2.stop(); mysqlEventPaser3.stop(); }
Example #6
Source File: Binlog.java From jlogstash-input-plugin with Apache License 2.0 | 5 votes |
@Override public void prepare() { logger.info("binlog prepare started.."); parseCategories(); controller = new MysqlEventParser(); controller.setConnectionCharset(Charset.forName("UTF-8")); controller.setSlaveId(slaveId); controller.setDetectingEnable(false); controller.setMasterInfo(new AuthenticationInfo(new InetSocketAddress(host, port), username, password)); controller.setEnableTsdb(true); controller.setDestination("example"); controller.setParallel(true); controller.setParallelBufferSize(256); controller.setParallelThreadSize(2); controller.setIsGTIDMode(false); controller.setEventSink(new BinlogEventSink(this)); controller.setLogPositionManager(new BinlogPositionManager(this)); EntryPosition startPosition = findStartPosition(); if (startPosition != null) { controller.setMasterPosition(startPosition); } if (filter != null) { controller.setEventFilter(new AviaterRegexFilter(filter)); } logger.info("binlog prepare ended.."); }
Example #7
Source File: GroupEventPaserTest.java From canal with Apache License 2.0 | 5 votes |
@Ignore @Test public void testMysqlWithMysql() { // MemoryEventStoreWithBuffer eventStore = new // MemoryEventStoreWithBuffer(); // eventStore.setBufferSize(8196); GroupEventSink eventSink = new GroupEventSink(3); eventSink.setFilterTransactionEntry(false); eventSink.setEventStore(new DummyEventStore()); eventSink.start(); // 构造第一个mysql MysqlEventParser mysqlEventPaser1 = buildEventParser(3344); mysqlEventPaser1.setEventSink(eventSink); // 构造第二个mysql MysqlEventParser mysqlEventPaser2 = buildEventParser(3345); mysqlEventPaser2.setEventSink(eventSink); // 构造第二个mysql MysqlEventParser mysqlEventPaser3 = buildEventParser(3346); mysqlEventPaser3.setEventSink(eventSink); // 启动 mysqlEventPaser1.start(); mysqlEventPaser2.start(); mysqlEventPaser3.start(); try { Thread.sleep(30 * 10 * 1000L); } catch (InterruptedException e) { } mysqlEventPaser1.stop(); mysqlEventPaser2.stop(); mysqlEventPaser3.stop(); }