Authored by peuei

update

@@ -54,7 +54,7 @@ public class CanalClientHandler implements InitializingBean, ApplicationEventPub @@ -54,7 +54,7 @@ public class CanalClientHandler implements InitializingBean, ApplicationEventPub
54 54
55 @Override 55 @Override
56 public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { 56 public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
57 - List<CanalConfig.CanalInstance> canalInstancesList = canalConfig.getCanalInstance(); 57 + List<CanalConfig.CanalInstance> canalInstancesList = canalConfig.getCanalInstance();
58 if (!CollectionUtils.isEmpty(canalInstancesList)) { 58 if (!CollectionUtils.isEmpty(canalInstancesList)) {
59 threadPool = Executors.newFixedThreadPool(canalInstancesList.size()); 59 threadPool = Executors.newFixedThreadPool(canalInstancesList.size());
60 logger.info("CanalInstance total count is [{}]", canalInstancesList.size()); 60 logger.info("CanalInstance total count is [{}]", canalInstancesList.size());
@@ -85,7 +85,7 @@ public class CanalClientHandler implements InitializingBean, ApplicationEventPub @@ -85,7 +85,7 @@ public class CanalClientHandler implements InitializingBean, ApplicationEventPub
85 } 85 }
86 86
87 private void startClient() { 87 private void startClient() {
88 - List<CanalConfig.CanalInstance> canalInstancesList = canalConfig.getCanalInstance(); 88 + List<CanalConfig.CanalInstance> canalInstancesList = canalConfig.getCanalInstance();
89 for (CanalConfig.CanalInstance instance : canalInstancesList) { 89 for (CanalConfig.CanalInstance instance : canalInstancesList) {
90 threadPool.execute(() -> { 90 threadPool.execute(() -> {
91 Thread.currentThread().setName(Thread.currentThread().getName() + "-" + instance.getDestination()); 91 Thread.currentThread().setName(Thread.currentThread().getName() + "-" + instance.getDestination());
@@ -95,11 +95,11 @@ public class CanalClientHandler implements InitializingBean, ApplicationEventPub @@ -95,11 +95,11 @@ public class CanalClientHandler implements InitializingBean, ApplicationEventPub
95 95
96 handleCanalMessage(canalInstConnectors.get(instance.getDestination()), instance); 96 handleCanalMessage(canalInstConnectors.get(instance.getDestination()), instance);
97 } 97 }
98 - }catch (CanalClientException e) { 98 + } catch (CanalClientException e) {
99 //TODO 事件上报 99 //TODO 事件上报
100 logger.error("CanalClientHandler invoke thread error!", e); 100 logger.error("CanalClientHandler invoke thread error!", e);
101 reConnectCanal(instance); 101 reConnectCanal(instance);
102 - }catch (Throwable e) { 102 + } catch (Throwable e) {
103 // 避免未捕获的异常导致连接丢失 103 // 避免未捕获的异常导致连接丢失
104 // TODO 事件上报 104 // TODO 事件上报
105 logger.error("CanalClientHandler invoke thread error!", e); 105 logger.error("CanalClientHandler invoke thread error!", e);
@@ -113,7 +113,7 @@ public class CanalClientHandler implements InitializingBean, ApplicationEventPub @@ -113,7 +113,7 @@ public class CanalClientHandler implements InitializingBean, ApplicationEventPub
113 } 113 }
114 } 114 }
115 115
116 - private void initConnector(CanalConfig.CanalInstance instance) throws CanalClientException{ 116 + private void initConnector(CanalConfig.CanalInstance instance) throws CanalClientException {
117 //暂且canal server端单实例 TODO 集群 117 //暂且canal server端单实例 TODO 集群
118 logger.info("Start to connect to canal server for instance: {}", instance); 118 logger.info("Start to connect to canal server for instance: {}", instance);
119 CanalConnector canalConnector = CanalConnectors.newSingleConnector(new InetSocketAddress(canalConfig.getSingleSocketAddress(), canalConfig.getSingleSocketPort()), 119 CanalConnector canalConnector = CanalConnectors.newSingleConnector(new InetSocketAddress(canalConfig.getSingleSocketAddress(), canalConfig.getSingleSocketPort()),
@@ -173,7 +173,7 @@ public class CanalClientHandler implements InitializingBean, ApplicationEventPub @@ -173,7 +173,7 @@ public class CanalClientHandler implements InitializingBean, ApplicationEventPub
173 long nowtimemillis = System.currentTimeMillis(); 173 long nowtimemillis = System.currentTimeMillis();
174 //TODO 上报生产者的数量至influxdb 174 //TODO 上报生产者的数量至influxdb
175 logger.info("handle canal config from [{}],currentTimeMillis is [{}],reportCount is [{}]", 175 logger.info("handle canal config from [{}],currentTimeMillis is [{}],reportCount is [{}]",
176 - config.getDestination(),nowtimemillis, reportCount); 176 + config.getDestination(), nowtimemillis, reportCount);
177 } catch (CanalClientException e) { 177 } catch (CanalClientException e) {
178 // 由外围处理进行重连 178 // 由外围处理进行重连
179 throw e; 179 throw e;
@@ -211,7 +211,7 @@ public class CanalClientHandler implements InitializingBean, ApplicationEventPub @@ -211,7 +211,7 @@ public class CanalClientHandler implements InitializingBean, ApplicationEventPub
211 int reportCount = 0; 211 int reportCount = 0;
212 for (RowData rowData : rowChage.getRowDatasList()) { 212 for (RowData rowData : rowChage.getRowDatasList()) {
213 //TODO MQ发送 213 //TODO MQ发送
214 - producerRabbitMqMessageHelper.sendRabbitMqMessage(eventType,dbName,tableName, rowData); 214 + producerRabbitMqMessageHelper.sendRabbitMqMessage(eventType, dbName, tableName, rowData);
215 reportCount++; 215 reportCount++;
216 } 216 }
217 return reportCount; 217 return reportCount;
@@ -6,7 +6,7 @@ canal: @@ -6,7 +6,7 @@ canal:
6 destination: "yhgrass" 6 destination: "yhgrass"
7 username: "" 7 username: ""
8 password: "" 8 password: ""
9 - filter: "yh_grass.grass_article_praise, yh_grass.grass_article_block, yh_grass.grass_article, yh_grass.grass_article_comment" 9 + filter: "yh_grass.grass_article_praise,yh_grass.grass_article_block,yh_grass.grass_article,yh_grass.grass_article_comment"
10 fetchSize: "1000" 10 fetchSize: "1000"
11 zkAddress: "" 11 zkAddress: ""
12 12