提交 | 用户 | age
|
de8c2b
|
1 |
package com.duxinglangzi.canal.starter.configuration;
|
D |
2 |
|
|
3 |
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
4 |
import org.springframework.core.Ordered;
|
|
5 |
import org.springframework.core.annotation.Order;
|
|
6 |
|
|
7 |
import java.util.LinkedHashMap;
|
|
8 |
import java.util.Map;
|
|
9 |
|
|
10 |
/**
|
|
11 |
* @author wuqiong 2022/4/11
|
|
12 |
* @description
|
|
13 |
*/
|
|
14 |
@Order(Ordered.HIGHEST_PRECEDENCE)
|
|
15 |
@ConfigurationProperties(prefix = "spring.canal")
|
|
16 |
public class CanalAutoConfigurationProperties {
|
|
17 |
|
|
18 |
private Map<String, EndpointInstance> instances = new LinkedHashMap<>();
|
|
19 |
|
|
20 |
public static class EndpointInstance {
|
|
21 |
|
|
22 |
/**
|
|
23 |
* 是否开启 cluster
|
|
24 |
*/
|
|
25 |
private boolean clusterEnabled;
|
|
26 |
|
|
27 |
/**
|
|
28 |
* zookeeper 地址, 例: 192.168.0.1:2181,192.168.0.2:2181,192.168.0.3:2181
|
|
29 |
*/
|
|
30 |
private String zookeeperAddress;
|
|
31 |
|
|
32 |
/**
|
|
33 |
* 默认 127.0.0.1
|
|
34 |
*/
|
|
35 |
private String host = "127.0.0.1";
|
|
36 |
|
|
37 |
/**
|
|
38 |
* 端口 , 默认: 11111
|
|
39 |
*/
|
|
40 |
private int port = 11111;
|
|
41 |
|
|
42 |
/**
|
|
43 |
* 用户名
|
|
44 |
*/
|
|
45 |
private String userName = "";
|
|
46 |
|
|
47 |
/**
|
|
48 |
* 密码
|
|
49 |
*/
|
|
50 |
private String password = "";
|
|
51 |
|
|
52 |
/**
|
|
53 |
* 每次获取数据条数 , 默认: 200
|
|
54 |
*/
|
|
55 |
private int batchSize = 200;
|
|
56 |
|
|
57 |
/**
|
|
58 |
* 发生错误时重试次数 , 默认: 5
|
|
59 |
*/
|
|
60 |
private int retryCount = 5;
|
|
61 |
|
|
62 |
/**
|
|
63 |
*
|
|
64 |
* mysql 数据解析关注的表,Perl正则表达式.
|
|
65 |
* <p>
|
|
66 |
*
|
|
67 |
* 多个正则之间以逗号(,)分隔,转义符需要双斜杠(\\)
|
|
68 |
* <p>
|
|
69 |
*
|
|
70 |
* 常见例子: <p>
|
|
71 |
* 1. 所有库表:.* or .*\\..* <p>
|
|
72 |
* 2. canal_db 下所有表: canal_db\\..* <p>
|
|
73 |
* 3. canal_db 下的以canal打头的表: canal_db\\.canal.* <p>
|
|
74 |
* 4. canal_db 下的一张表: canal_db\\.test1 <p>
|
|
75 |
* 5. 多个规则组合使用:canal_db\\..*,mysql_db.test1,mysql.test2 (逗号分隔) <p>
|
|
76 |
*
|
|
77 |
* 默认: 全库全表(.*\\..*)
|
|
78 |
*/
|
|
79 |
private String subscribe = ".*\\..*";
|
|
80 |
|
|
81 |
/**
|
|
82 |
* 未拉取到消息情况下,获取消息的时间间隔毫秒值 , 默认: 1000
|
|
83 |
*/
|
|
84 |
private long acquireInterval = 1000;
|
|
85 |
|
|
86 |
public EndpointInstance() {
|
|
87 |
}
|
|
88 |
|
|
89 |
public boolean isClusterEnabled() {
|
|
90 |
return clusterEnabled;
|
|
91 |
}
|
|
92 |
|
|
93 |
public void setClusterEnabled(boolean clusterEnabled) {
|
|
94 |
this.clusterEnabled = clusterEnabled;
|
|
95 |
}
|
|
96 |
|
|
97 |
public String getZookeeperAddress() {
|
|
98 |
return zookeeperAddress;
|
|
99 |
}
|
|
100 |
|
|
101 |
public void setZookeeperAddress(String zookeeperAddress) {
|
|
102 |
this.zookeeperAddress = zookeeperAddress;
|
|
103 |
}
|
|
104 |
|
|
105 |
public String getHost() {
|
|
106 |
return host;
|
|
107 |
}
|
|
108 |
|
|
109 |
public void setHost(String host) {
|
|
110 |
this.host = host;
|
|
111 |
}
|
|
112 |
|
|
113 |
public int getPort() {
|
|
114 |
return port;
|
|
115 |
}
|
|
116 |
|
|
117 |
public void setPort(int port) {
|
|
118 |
this.port = port;
|
|
119 |
}
|
|
120 |
|
|
121 |
public String getUserName() {
|
|
122 |
return userName;
|
|
123 |
}
|
|
124 |
|
|
125 |
public void setUserName(String userName) {
|
|
126 |
this.userName = userName;
|
|
127 |
}
|
|
128 |
|
|
129 |
public String getPassword() {
|
|
130 |
return password;
|
|
131 |
}
|
|
132 |
|
|
133 |
public void setPassword(String password) {
|
|
134 |
this.password = password;
|
|
135 |
}
|
|
136 |
|
|
137 |
public int getBatchSize() {
|
|
138 |
return batchSize;
|
|
139 |
}
|
|
140 |
|
|
141 |
public void setBatchSize(int batchSize) {
|
|
142 |
this.batchSize = batchSize;
|
|
143 |
}
|
|
144 |
|
|
145 |
public int getRetryCount() {
|
|
146 |
return retryCount;
|
|
147 |
}
|
|
148 |
|
|
149 |
public void setRetryCount(int retryCount) {
|
|
150 |
this.retryCount = retryCount;
|
|
151 |
}
|
|
152 |
|
|
153 |
public long getAcquireInterval() {
|
|
154 |
return acquireInterval;
|
|
155 |
}
|
|
156 |
|
|
157 |
public void setAcquireInterval(long acquireInterval) {
|
|
158 |
this.acquireInterval = acquireInterval;
|
|
159 |
}
|
|
160 |
|
|
161 |
public String getSubscribe() {
|
|
162 |
return subscribe;
|
|
163 |
}
|
|
164 |
|
|
165 |
public void setSubscribe(String subscribe) {
|
|
166 |
this.subscribe = subscribe;
|
|
167 |
}
|
|
168 |
}
|
|
169 |
|
|
170 |
public Map<String, EndpointInstance> getInstances() {
|
|
171 |
return instances;
|
|
172 |
}
|
|
173 |
|
|
174 |
public void setInstances(Map<String, EndpointInstance> instances) {
|
|
175 |
this.instances = instances;
|
|
176 |
}
|
|
177 |
}
|