com.alibaba.otter.canal.instance.manager.model.Canal Java Examples
The following examples show how to use
com.alibaba.otter.canal.instance.manager.model.Canal.
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: CanalServerTest.java From canal with Apache License 2.0 | 6 votes |
@Before public void setUp() { CanalServerWithEmbedded embeddedServer = new CanalServerWithEmbedded(); embeddedServer.setCanalInstanceGenerator(new CanalInstanceGenerator() { public CanalInstance generate(String destination) { Canal canal = buildCanal(); return new CanalInstanceWithManager(canal, FILTER); } }); nettyServer = CanalServerWithNetty.instance(); nettyServer.setEmbeddedServer(embeddedServer); nettyServer.setPort(1088); nettyServer.start(); }
Example #2
Source File: CanalServerWithNettyTest.java From canal-1.1.3 with Apache License 2.0 | 6 votes |
@Before public void setUp() { CanalServerWithEmbedded embeddedServer = new CanalServerWithEmbedded(); embeddedServer.setCanalInstanceGenerator(new CanalInstanceGenerator() { public CanalInstance generate(String destination) { Canal canal = buildCanal(); return new CanalInstanceWithManager(canal, FILTER); } }); nettyServer = CanalServerWithNetty.instance(); nettyServer.setEmbeddedServer(embeddedServer); nettyServer.setPort(1088); nettyServer.start(); }
Example #3
Source File: GatewayUtil.java From DataLink with Apache License 2.0 | 5 votes |
private static Canal cloneAndAdjustCanalConfig(Canal in) { Canal out = clone(in); out.setName(buildCanalName(out)); //让parser自己自动生成slaveid out.getCanalParameter().setSlaveId(-1L); return out; }
Example #4
Source File: CanalServerTest.java From canal with Apache License 2.0 | 5 votes |
private Canal buildCanal() { Canal canal = new Canal(); canal.setId(1L); canal.setName(DESTINATION); canal.setDesc("test"); CanalParameter parameter = new CanalParameter(); parameter.setZkClusters(Arrays.asList("127.0.0.1:2188")); parameter.setMetaMode(MetaMode.MEMORY); parameter.setHaMode(HAMode.HEARTBEAT); parameter.setIndexMode(IndexMode.MEMORY); parameter.setStorageMode(StorageMode.MEMORY); parameter.setMemoryStorageBufferSize(32 * 1024); parameter.setSourcingType(SourcingType.MYSQL); parameter.setDbAddresses(Arrays.asList(new InetSocketAddress(MYSQL_ADDRESS, 3306), new InetSocketAddress(MYSQL_ADDRESS, 3306))); parameter.setDbUsername(USERNAME); parameter.setDbPassword(PASSWORD); parameter.setPositions(Arrays.asList("{\"journalName\":\"mysql-bin.000001\",\"position\":6163L,\"timestamp\":1322803601000L}", "{\"journalName\":\"mysql-bin.000001\",\"position\":6163L,\"timestamp\":1322803601000L}")); parameter.setSlaveId(1234L); parameter.setDefaultConnectionTimeoutInSeconds(30); parameter.setConnectionCharset("UTF-8"); parameter.setConnectionCharsetNumber((byte) 33); parameter.setReceiveBufferSize(8 * 1024); parameter.setSendBufferSize(8 * 1024); parameter.setDetectingEnable(false); parameter.setDetectingIntervalInSeconds(10); parameter.setDetectingRetryTimes(3); parameter.setDetectingSQL(DETECTING_SQL); canal.setCanalParameter(parameter); return canal; }
Example #5
Source File: CanalServerWithEmbedded_StandbyTest.java From canal with Apache License 2.0 | 5 votes |
protected Canal buildCanal() { Canal canal = new Canal(); canal.setId(1L); canal.setName(DESTINATION); canal.setDesc("test"); CanalParameter parameter = new CanalParameter(); parameter.setZkClusters(Arrays.asList("127.0.0.1:2188")); parameter.setMetaMode(MetaMode.MIXED); // 冷备,可选择混合模式 parameter.setHaMode(HAMode.HEARTBEAT); parameter.setIndexMode(IndexMode.META);// 内存版store,需要选择meta做为index parameter.setStorageMode(StorageMode.MEMORY); parameter.setMemoryStorageBufferSize(32 * 1024); parameter.setSourcingType(SourcingType.MYSQL); parameter.setDbAddresses(Arrays.asList(new InetSocketAddress(MYSQL_ADDRESS, 3306), new InetSocketAddress(MYSQL_ADDRESS, 3306))); parameter.setDbUsername(USERNAME); parameter.setDbPassword(PASSWORD); parameter.setPositions(Arrays.asList("{\"journalName\":\"mysql-bin.000001\",\"position\":6163L,\"timestamp\":1322803601000L}", "{\"journalName\":\"mysql-bin.000001\",\"position\":6163L,\"timestamp\":1322803601000L}")); parameter.setSlaveId(1234L); parameter.setDefaultConnectionTimeoutInSeconds(30); parameter.setConnectionCharset("UTF-8"); parameter.setConnectionCharsetNumber((byte) 33); parameter.setReceiveBufferSize(8 * 1024); parameter.setSendBufferSize(8 * 1024); parameter.setDetectingEnable(false); parameter.setDetectingIntervalInSeconds(10); parameter.setDetectingRetryTimes(3); parameter.setDetectingSQL(DETECTING_SQL); canal.setCanalParameter(parameter); return canal; }
Example #6
Source File: CanalServerWithEmbedded_StandaloneTest.java From canal with Apache License 2.0 | 5 votes |
protected Canal buildCanal() { Canal canal = new Canal(); canal.setId(1L); canal.setName(DESTINATION); canal.setDesc("test"); CanalParameter parameter = new CanalParameter(); parameter.setZkClusters(Arrays.asList("127.0.0.1:2188")); parameter.setMetaMode(MetaMode.MEMORY); parameter.setHaMode(HAMode.HEARTBEAT); parameter.setIndexMode(IndexMode.MEMORY); parameter.setStorageMode(StorageMode.MEMORY); parameter.setMemoryStorageBufferSize(32 * 1024); parameter.setSourcingType(SourcingType.MYSQL); parameter.setDbAddresses(Arrays.asList(new InetSocketAddress(MYSQL_ADDRESS, 3306), new InetSocketAddress(MYSQL_ADDRESS, 3306))); parameter.setDbUsername(USERNAME); parameter.setDbPassword(PASSWORD); parameter.setPositions(Arrays.asList("{\"journalName\":\"mysql-bin.000003\",\"position\":14217L,\"timestamp\":\"1505998863000\"}", "{\"journalName\":\"mysql-bin.000003\",\"position\":14377L,\"timestamp\":\"1505998863000\"}")); parameter.setSlaveId(1234L); parameter.setDefaultConnectionTimeoutInSeconds(30); parameter.setConnectionCharset("UTF-8"); parameter.setConnectionCharsetNumber((byte) 33); parameter.setReceiveBufferSize(8 * 1024); parameter.setSendBufferSize(8 * 1024); parameter.setDetectingEnable(false); parameter.setDetectingIntervalInSeconds(10); parameter.setDetectingRetryTimes(3); parameter.setDetectingSQL(DETECTING_SQL); canal.setCanalParameter(parameter); return canal; }
Example #7
Source File: BaseCanalServerWithEmbededTest.java From canal with Apache License 2.0 | 5 votes |
@Before public void setUp() { server = CanalServerWithEmbedded.instance(); server.setCanalInstanceGenerator(new CanalInstanceGenerator() { public CanalInstance generate(String destination) { Canal canal = buildCanal(); return new CanalInstanceWithManager(canal, FILTER); } }); server.start(); server.start(DESTINATION); }
Example #8
Source File: CanalInstanceWithManager.java From canal with Apache License 2.0 | 5 votes |
public CanalInstanceWithManager(Canal canal, String filter){ this.parameters = canal.getCanalParameter(); this.canalId = canal.getId(); this.destination = canal.getName(); this.filter = filter; logger.info("init CanalInstance for {}-{} with parameters:{}", canalId, destination, parameters); // 初始化报警机制 initAlarmHandler(); // 初始化metaManager initMetaManager(); // 初始化eventStore initEventStore(); // 初始化eventSink initEventSink(); // 初始化eventParser; initEventParser(); // 基础工具,需要提前start,会有先订阅再根据filter条件启动parse的需求 if (!alarmHandler.isStart()) { alarmHandler.start(); } if (!metaManager.isStart()) { metaManager.start(); } logger.info("init successful...."); }
Example #9
Source File: CanalReaderConfigGenerator.java From DataLink with Apache License 2.0 | 5 votes |
public static Canal buildCanalConfig(String destination, MysqlReaderParameter parameter, TaskReaderContext context, CanalReaderType readerType, TaskShadowInfo taskShadow) { Canal canal = new Canal(); canal.setId(9999L);//id值没有太多意义,赋一个固定值即可 canal.setName(destination); canal.setCanalParameter(buildCanalParameter(destination, parameter, context, readerType, taskShadow)); return canal; }
Example #10
Source File: CanalInstanceWithManager.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
public CanalInstanceWithManager(Canal canal, String filter){ this.parameters = canal.getCanalParameter(); this.canalId = canal.getId(); this.destination = canal.getName(); this.filter = filter; logger.info("init CanalInstance for {}-{} with parameters:{}", canalId, destination, parameters); // 初始化报警机制 initAlarmHandler(); // 初始化metaManager initMetaManager(); // 初始化eventStore initEventStore(); // 初始化eventSink initEventSink(); // 初始化eventParser; initEventParser(); // 基础工具,需要提前start,会有先订阅再根据filter条件启动parse的需求 if (!alarmHandler.isStart()) { alarmHandler.start(); } if (!metaManager.isStart()) { metaManager.start(); } logger.info("init successful...."); }
Example #11
Source File: BaseCanalServerWithEmbededTest.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
@Before public void setUp() { server = CanalServerWithEmbedded.instance(); server.setCanalInstanceGenerator(new CanalInstanceGenerator() { public CanalInstance generate(String destination) { Canal canal = buildCanal(); return new CanalInstanceWithManager(canal, FILTER); } }); server.start(); server.start(DESTINATION); }
Example #12
Source File: CanalServerWithEmbedded_StandaloneTest.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
protected Canal buildCanal() { Canal canal = new Canal(); canal.setId(1L); canal.setName(DESTINATION); canal.setDesc("test"); CanalParameter parameter = new CanalParameter(); parameter.setZkClusters(Arrays.asList("127.0.0.1:2188")); parameter.setMetaMode(MetaMode.MEMORY); parameter.setHaMode(HAMode.HEARTBEAT); parameter.setIndexMode(IndexMode.MEMORY); parameter.setStorageMode(StorageMode.MEMORY); parameter.setMemoryStorageBufferSize(32 * 1024); parameter.setSourcingType(SourcingType.MYSQL); parameter.setDbAddresses(Arrays.asList(new InetSocketAddress(MYSQL_ADDRESS, 3306), new InetSocketAddress(MYSQL_ADDRESS, 3306))); parameter.setDbUsername(USERNAME); parameter.setDbPassword(PASSWORD); parameter.setPositions(Arrays.asList("{\"journalName\":\"mysql-bin.000003\",\"position\":14217L,\"timestamp\":\"1505998863000\"}", "{\"journalName\":\"mysql-bin.000003\",\"position\":14377L,\"timestamp\":\"1505998863000\"}")); parameter.setSlaveId(1234L); parameter.setDefaultConnectionTimeoutInSeconds(30); parameter.setConnectionCharset("UTF-8"); parameter.setConnectionCharsetNumber((byte) 33); parameter.setReceiveBufferSize(8 * 1024); parameter.setSendBufferSize(8 * 1024); parameter.setDetectingEnable(false); parameter.setDetectingIntervalInSeconds(10); parameter.setDetectingRetryTimes(3); parameter.setDetectingSQL(DETECTING_SQL); canal.setCanalParameter(parameter); return canal; }
Example #13
Source File: CanalServerWithNettyTest.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
private Canal buildCanal() { Canal canal = new Canal(); canal.setId(1L); canal.setName(DESTINATION); canal.setDesc("test"); CanalParameter parameter = new CanalParameter(); parameter.setZkClusters(Arrays.asList("127.0.0.1:2188")); parameter.setMetaMode(MetaMode.MEMORY); parameter.setHaMode(HAMode.HEARTBEAT); parameter.setIndexMode(IndexMode.MEMORY); parameter.setStorageMode(StorageMode.MEMORY); parameter.setMemoryStorageBufferSize(32 * 1024); parameter.setSourcingType(SourcingType.MYSQL); parameter.setDbAddresses(Arrays.asList(new InetSocketAddress(MYSQL_ADDRESS, 3306), new InetSocketAddress(MYSQL_ADDRESS, 3306))); parameter.setDbUsername(USERNAME); parameter.setDbPassword(PASSWORD); parameter.setPositions(Arrays.asList("{\"journalName\":\"mysql-bin.000001\",\"position\":6163L,\"timestamp\":1322803601000L}", "{\"journalName\":\"mysql-bin.000001\",\"position\":6163L,\"timestamp\":1322803601000L}")); parameter.setSlaveId(1234L); parameter.setDefaultConnectionTimeoutInSeconds(30); parameter.setConnectionCharset("UTF-8"); parameter.setConnectionCharsetNumber((byte) 33); parameter.setReceiveBufferSize(8 * 1024); parameter.setSendBufferSize(8 * 1024); parameter.setDetectingEnable(false); parameter.setDetectingIntervalInSeconds(10); parameter.setDetectingRetryTimes(3); parameter.setDetectingSQL(DETECTING_SQL); canal.setCanalParameter(parameter); return canal; }
Example #14
Source File: CanalServerWithEmbedded_StandbyTest.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
protected Canal buildCanal() { Canal canal = new Canal(); canal.setId(1L); canal.setName(DESTINATION); canal.setDesc("test"); CanalParameter parameter = new CanalParameter(); parameter.setZkClusters(Arrays.asList("127.0.0.1:2188")); parameter.setMetaMode(MetaMode.MIXED); // 冷备,可选择混合模式 parameter.setHaMode(HAMode.HEARTBEAT); parameter.setIndexMode(IndexMode.META);// 内存版store,需要选择meta做为index parameter.setStorageMode(StorageMode.MEMORY); parameter.setMemoryStorageBufferSize(32 * 1024); parameter.setSourcingType(SourcingType.MYSQL); parameter.setDbAddresses(Arrays.asList(new InetSocketAddress(MYSQL_ADDRESS, 3306), new InetSocketAddress(MYSQL_ADDRESS, 3306))); parameter.setDbUsername(USERNAME); parameter.setDbPassword(PASSWORD); parameter.setPositions(Arrays.asList("{\"journalName\":\"mysql-bin.000001\",\"position\":6163L,\"timestamp\":1322803601000L}", "{\"journalName\":\"mysql-bin.000001\",\"position\":6163L,\"timestamp\":1322803601000L}")); parameter.setSlaveId(1234L); parameter.setDefaultConnectionTimeoutInSeconds(30); parameter.setConnectionCharset("UTF-8"); parameter.setConnectionCharsetNumber((byte) 33); parameter.setReceiveBufferSize(8 * 1024); parameter.setSendBufferSize(8 * 1024); parameter.setDetectingEnable(false); parameter.setDetectingIntervalInSeconds(10); parameter.setDetectingRetryTimes(3); parameter.setDetectingSQL(DETECTING_SQL); canal.setCanalParameter(parameter); return canal; }
Example #15
Source File: CanalConfigClient.java From canal-1.1.3 with Apache License 2.0 | 4 votes |
/** * 根据对应的destinantion查询Canal信息 */ public Canal findCanal(String destination) { // TODO 根据自己的业务实现 throw new UnsupportedOperationException(); }
Example #16
Source File: CustomCanalInstanceWithManager.java From DataLink with Apache License 2.0 | 4 votes |
public CustomCanalInstanceWithManager(Canal canal, String filter) { super(canal, filter); }
Example #17
Source File: ManagerCanalInstanceGenerator.java From canal-1.1.3 with Apache License 2.0 | 4 votes |
public CanalInstance generate(String destination) { Canal canal = canalConfigClient.findCanal(destination); String filter = canalConfigClient.findFilter(destination); return new CanalInstanceWithManager(canal, filter); }
Example #18
Source File: CanalServerWithEmbedded_FileModeTest.java From canal with Apache License 2.0 | 4 votes |
protected Canal buildCanal() { Canal canal = new Canal(); canal.setId(1L); canal.setName(DESTINATION); canal.setDesc("my standalone server test "); CanalParameter parameter = new CanalParameter(); parameter.setMetaMode(MetaMode.LOCAL_FILE); parameter.setDataDir("./conf"); parameter.setMetaFileFlushPeriod(1000); parameter.setHaMode(HAMode.HEARTBEAT); parameter.setIndexMode(IndexMode.MEMORY_META_FAILBACK); parameter.setStorageMode(StorageMode.MEMORY); parameter.setMemoryStorageBufferSize(32 * 1024); parameter.setSourcingType(SourcingType.MYSQL); parameter.setDbAddresses(Arrays.asList(new InetSocketAddress(MYSQL_ADDRESS, 3306), new InetSocketAddress(MYSQL_ADDRESS, 3306))); parameter.setDbUsername(USERNAME); parameter.setDbPassword(PASSWORD); parameter.setPositions(Arrays.asList("{\"journalName\":\"mysql-bin.000001\",\"position\":332L,\"timestamp\":\"1505998863000\"}", "{\"journalName\":\"mysql-bin.000001\",\"position\":332L,\"timestamp\":\"1505998863000\"}")); parameter.setSlaveId(1234L); parameter.setDefaultConnectionTimeoutInSeconds(30); parameter.setConnectionCharset("UTF-8"); parameter.setConnectionCharsetNumber((byte) 33); parameter.setReceiveBufferSize(8 * 1024); parameter.setSendBufferSize(8 * 1024); parameter.setDetectingEnable(false); parameter.setDetectingIntervalInSeconds(10); parameter.setDetectingRetryTimes(3); parameter.setDetectingSQL(DETECTING_SQL); canal.setCanalParameter(parameter); return canal; }
Example #19
Source File: ManagerCanalInstanceGenerator.java From canal with Apache License 2.0 | 4 votes |
public CanalInstance generate(String destination) { Canal canal = canalConfigClient.findCanal(destination); String filter = canalConfigClient.findFilter(destination); return new CanalInstanceWithManager(canal, filter); }
Example #20
Source File: CanalConfigClient.java From canal with Apache License 2.0 | 4 votes |
/** * 根据对应的destinantion查询Canal信息 */ public Canal findCanal(String destination) { // TODO 根据自己的业务实现 throw new UnsupportedOperationException(); }
Example #21
Source File: CanalServerWithEmbedded_FileModeTest.java From canal-1.1.3 with Apache License 2.0 | 4 votes |
protected Canal buildCanal() { Canal canal = new Canal(); canal.setId(1L); canal.setName(DESTINATION); canal.setDesc("my standalone server test "); CanalParameter parameter = new CanalParameter(); parameter.setMetaMode(MetaMode.LOCAL_FILE); parameter.setDataDir("./conf"); parameter.setMetaFileFlushPeriod(1000); parameter.setHaMode(HAMode.HEARTBEAT); parameter.setIndexMode(IndexMode.MEMORY_META_FAILBACK); parameter.setStorageMode(StorageMode.MEMORY); parameter.setMemoryStorageBufferSize(32 * 1024); parameter.setSourcingType(SourcingType.MYSQL); parameter.setDbAddresses(Arrays.asList(new InetSocketAddress(MYSQL_ADDRESS, 3306), new InetSocketAddress(MYSQL_ADDRESS, 3306))); parameter.setDbUsername(USERNAME); parameter.setDbPassword(PASSWORD); parameter.setPositions(Arrays.asList("{\"journalName\":\"mysql-bin.000001\",\"position\":332L,\"timestamp\":\"1505998863000\"}", "{\"journalName\":\"mysql-bin.000001\",\"position\":332L,\"timestamp\":\"1505998863000\"}")); parameter.setSlaveId(1234L); parameter.setDefaultConnectionTimeoutInSeconds(30); parameter.setConnectionCharset("UTF-8"); parameter.setConnectionCharsetNumber((byte) 33); parameter.setReceiveBufferSize(8 * 1024); parameter.setSendBufferSize(8 * 1024); parameter.setDetectingEnable(false); parameter.setDetectingIntervalInSeconds(10); parameter.setDetectingRetryTimes(3); parameter.setDetectingSQL(DETECTING_SQL); canal.setCanalParameter(parameter); return canal; }
Example #22
Source File: GatewayMetaManager.java From DataLink with Apache License 2.0 | 4 votes |
public GatewayMetaManager(Canal gwCanal) { this.gwCanal = gwCanal; this.attachedMetaManagers = new ConcurrentHashMap<>(); }
Example #23
Source File: GatewayEventStore.java From DataLink with Apache License 2.0 | 4 votes |
public GatewayEventStore(Canal gwCanal) { this.gwCanal = gwCanal; this.attachedEventStores = new ConcurrentHashMap<>(); this.succeededStores = new HashMap<>(); }
Example #24
Source File: GatewayUtil.java From DataLink with Apache License 2.0 | 4 votes |
public LoadingKey(String gwCanalName, Canal gwCanal) { this.gwCanalName = gwCanalName; this.gwCanal = gwCanal; }
Example #25
Source File: GatewayUtil.java From DataLink with Apache License 2.0 | 4 votes |
private static String buildCanalName(Canal canal) { List<List<CanalParameter.DataSourcing>> datasources = canal.getCanalParameter().getGroupDbAddresses(); CanalParameter.DataSourcing master = datasources.get(0).get(0); InetSocketAddress socketAddress = master.getDbAddress(); return NAME_PREFIX + "-" + socketAddress.getHostName() + "-" + socketAddress.getPort(); }
Example #26
Source File: GatewayUtil.java From DataLink with Apache License 2.0 | 4 votes |
public static GatewayInstance getGatewayInstance(Canal canal) { Canal gwCanal = cloneAndAdjustCanalConfig(canal); return instances.getUnchecked(new LoadingKey(gwCanal.getName(), gwCanal)); }
Example #27
Source File: GatewayInstance.java From DataLink with Apache License 2.0 | 4 votes |
public GatewayInstance(Canal gwCanal) { this.gwCanal = gwCanal; this.endpointInstances = new ConcurrentHashMap<>(); }
Example #28
Source File: GatewayEventSink.java From DataLink with Apache License 2.0 | 4 votes |
public GatewayEventSink(Canal gwCanal, CanalEventSink eventSink, GatewayEventStore gatewayEventStore) { this.gwCanal = gwCanal; this.eventSink = eventSink; this.gatewayEventStore = gatewayEventStore; this.attachedEventSinks = new ConcurrentHashMap<>(); }
Example #29
Source File: FakeEventSink.java From DataLink with Apache License 2.0 | 4 votes |
public FakeEventSink(Canal canal, CanalInstance canalInstance) { this.canal = canal; this.canalInstance = canalInstance; }
Example #30
Source File: FakeEventParser.java From DataLink with Apache License 2.0 | 4 votes |
public FakeEventParser(Canal canal, CanalInstance canalInstance, KickoutListener kickoutListener, String filter) { this.canal = canal; this.canalInstance = canalInstance; this.kickoutListener = kickoutListener; this.filter = filter; }