Skip to content

Commit

Permalink
此版本支持 zookeeper 3.4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
gujiachun committed Jan 28, 2022
1 parent 6ccb265 commit 63a16d2
Show file tree
Hide file tree
Showing 19 changed files with 169 additions and 39 deletions.
2 changes: 1 addition & 1 deletion bridge-admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bridge</artifactId>
<groupId>com.rainbow.bridge</groupId>
<version>1.2.1</version>
<version>1.2.1.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
*/
public class ZkBridgeClient extends ZkClientImpl {

public ZkBridgeClient(String zkServers, int sessionTimeout, String rootPath,String env) {
super(zkServers, sessionTimeout);
public ZkBridgeClient(String zkServers, String rootPath,String env) {
super(zkServers);
this.rootPath = rootPath;
this.env = env;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void run(ApplicationArguments args) throws Exception {
private void initZkClient(){
List<BasicZkEntity> list = zkService.list();
for (BasicZkEntity entity : list){
ZkBridgeClient client = new ZkBridgeClient(entity.getServers(), 5000,entity.getRootPath(),entity.getEnv());
ZkBridgeClient client = new ZkBridgeClient(entity.getServers(),entity.getRootPath(),entity.getEnv());
zkBridgeClientFactory.addZkBridgeClient(entity.getEnv(),client);
}
}
Expand Down
2 changes: 1 addition & 1 deletion bridge-admin/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
server:
port: 8072
port: 12138

spring:
profiles:
Expand Down
2 changes: 1 addition & 1 deletion bridge-biz/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bridge</artifactId>
<groupId>com.rainbow.bridge</groupId>
<version>1.2.1</version>
<version>1.2.1.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
22 changes: 21 additions & 1 deletion bridge-canal-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bridge</artifactId>
<groupId>com.rainbow.bridge</groupId>
<version>1.2.1</version>
<version>1.2.1.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -25,10 +25,30 @@
<dependency>
<groupId>com.alibaba.otter</groupId>
<artifactId>canal.client</artifactId>
<exclusions>
<exclusion>
<groupId>com.101tec</groupId>
<artifactId>zkclient</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.alibaba.otter</groupId>
<artifactId>canal.common</artifactId>
<exclusions>
<exclusion>
<groupId>com.101tec</groupId>
<artifactId>zkclient</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.alibaba.otter</groupId>
Expand Down
24 changes: 9 additions & 15 deletions bridge-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bridge</artifactId>
<groupId>com.rainbow.bridge</groupId>
<version>1.2.1</version>
<version>1.2.1.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -46,17 +46,7 @@
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.101tec</groupId>-->
<!-- <artifactId>zkclient</artifactId>-->
<!-- <version>0.10</version>-->
<!-- <exclusions>-->
<!-- <exclusion>-->
<!-- <groupId>org.slf4j</groupId>-->
<!-- <artifactId>slf4j-log4j12</artifactId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
<!-- </dependency>-->

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Expand All @@ -69,7 +59,7 @@
</dependency>


<!-- zookeeper -->
<!-- &lt;!&ndash; zookeeper &ndash;&gt;-->
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
Expand All @@ -89,7 +79,7 @@
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
<version>4.2.0</version>
<version>2.11.1</version>
<exclusions>
<exclusion>
<groupId>org.apache.zookeeper</groupId>
Expand All @@ -101,8 +91,12 @@
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
<version>4.2.0</version>
<version>2.11.1</version>
<exclusions>
<exclusion>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ public class ZkClientImpl implements ZkClient {
/** zkclient 重试次数 */
private int retryCount = 5;

public ZkClientImpl(String zkServers, int sessionTimeout){
public ZkClientImpl(String zkServers){
client = CuratorFrameworkFactory
.builder()
.connectString(zkServers)
.sessionTimeoutMs(sessionTimeout)
.retryPolicy(new ExponentialBackoffRetry(baseSleepTimeMs, retryCount))
.build();
client.start();
Expand Down
56 changes: 55 additions & 1 deletion bridge-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bridge</artifactId>
<groupId>com.rainbow.bridge</groupId>
<version>1.2.1</version>
<version>1.2.1.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -18,7 +18,60 @@
<groupId>com.rainbow.bridge</groupId>
<artifactId>bridge-web-starter</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- zookeeper -->
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.4.14</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- curator-framework -->
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
<version>2.11.1</version>
<exclusions>
<exclusion>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- curator-recipes -->
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
<version>2.11.1</version>
<exclusions>
<exclusion>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>com.rainbow.bridge</groupId>
<artifactId>bridge-target-mysql</artifactId>
Expand Down Expand Up @@ -50,6 +103,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>16.0.1</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public ZkClientExt zkClientExt(ZkService zkService) throws Exception {

ZkClientExt zkc;
if (StringUtils.isNotBlank(clusterCode)){
zkc = new ZkClientExt(one.getServers(), 5000,one.getRootPath(),clusterCode);
zkc = new ZkClientExt(one.getServers(),one.getRootPath(),clusterCode);
}else{
zkc = new ZkClientExt(one.getServers(), 5000);
zkc = new ZkClientExt(one.getServers());
List<BasicClusterEntity> listByEnv = clusterService.getListByEnv(env);
if (listByEnv == null || listByEnv.size() == 0){
logger.error("环境:{}没有对应的集群配置,请到控制台中的集群管理菜单去配置",env);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import com.rainbow.bridge.targetcore.factory.taskrule.TaskRuleFactory;
import org.apache.commons.lang3.StringUtils;
import org.apache.curator.framework.recipes.locks.InterProcessLock;
import org.apache.curator.framework.recipes.locks.InterProcessMultiLock;
import org.apache.curator.framework.recipes.locks.InterProcessMutex;
import org.apache.curator.framework.recipes.locks.InterProcessSemaphoreMutex;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -200,7 +202,12 @@ public synchronized void refresh() throws Exception {
logger.info("自动refresh了哦........");

String lockName = zkClientExt.getRootPath() + "/" + zkClientExt.getClusterName() + "-task-locker";
InterProcessLock lock = new InterProcessSemaphoreMutex(zkClientExt.getClient(), lockName );
String s = zkClientExt.readData(zkClientExt.getRootPath() + "/" + zkClientExt.getClusterName());
logger.info("c:{}",s);
// if (!zkClientExt.exists(lockName)){
// zkClientExt.createPersistent(lockName);
// }
InterProcessLock lock = new InterProcessMutex(zkClientExt.getClient(), lockName );

try{
logger.info(">>>>>>>>去申请加锁:{}",lockName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ public class ZkClientExt extends ZkClientImpl {

private static final Logger logger = LoggerFactory.getLogger(ZkClientExt.class);

public ZkClientExt(String zkServers, int sessionTimeout,
public ZkClientExt(String zkServers,
String rootPath,String clusterName) {
super(zkServers, sessionTimeout);
super(zkServers);
setRootPathCluster(rootPath,clusterName);
}

public ZkClientExt(String zkServers, int sessionTimeout) {
super(zkServers, sessionTimeout);
public ZkClientExt(String zkServers) {
super(zkServers);
}

private String rootPath;
Expand Down
6 changes: 5 additions & 1 deletion bridge-server/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
server:
port: 8067
port: 12156

spring:
profiles:
Expand Down Expand Up @@ -46,6 +46,10 @@ mybatis-plus:
spring:
profiles: dev
db:
# host: 192.168.58.79:13306
# database: bridgedev
# username: bridgedev
# password: D1_ucXgN
host: 127.0.0.1:3306
database: rainbow_bridge
username: root
Expand Down
2 changes: 1 addition & 1 deletion bridge-target-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bridge</artifactId>
<groupId>com.rainbow.bridge</groupId>
<version>1.2.1</version>
<version>1.2.1.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion bridge-target-elasticsearch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bridge</artifactId>
<groupId>com.rainbow.bridge</groupId>
<version>1.2.1</version>
<version>1.2.1.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion bridge-target-mysql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bridge</artifactId>
<groupId>com.rainbow.bridge</groupId>
<version>1.2.1</version>
<version>1.2.1.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion bridge-target-redis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bridge</artifactId>
<groupId>com.rainbow.bridge</groupId>
<version>1.2.1</version>
<version>1.2.1.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Loading

0 comments on commit 63a16d2

Please sign in to comment.