本文整理匯總了Java中com.alibaba.otter.canal.parse.inbound.mysql.MysqlEventParser類的典型用法代碼示例。如果您正苦於以下問題:Java MysqlEventParser類的具體用法?Java MysqlEventParser怎麽用?Java MysqlEventParser使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MysqlEventParser類屬於com.alibaba.otter.canal.parse.inbound.mysql包,在下文中一共展示了MysqlEventParser類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: startEventParserInternal
import com.alibaba.otter.canal.parse.inbound.mysql.MysqlEventParser; //導入依賴的package包/類
/**
* 初始化單個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();
}
}
}
示例2: stopEventParserInternal
import com.alibaba.otter.canal.parse.inbound.mysql.MysqlEventParser; //導入依賴的package包/類
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();
}
}
}
示例3: testMysqlWithMysql
import com.alibaba.otter.canal.parse.inbound.mysql.MysqlEventParser; //導入依賴的package包/類
@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();
}