Skip to content

Commit

Permalink
Merge branch 'master' into fix-issue-5259
Browse files Browse the repository at this point in the history
  • Loading branch information
yunlongn committed Nov 1, 2023
2 parents 9855933 + 5419212 commit f874b72
Show file tree
Hide file tree
Showing 32 changed files with 1,135 additions and 50 deletions.
6 changes: 0 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,6 @@
<scope>import</scope>
</dependency>

<dependency>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-client</artifactId>
<version>${nacos-client.version}</version>
</dependency>

<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-tree</artifactId>
Expand Down
23 changes: 18 additions & 5 deletions shenyu-admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,6 @@
<artifactId>pagehelper</artifactId>
</dependency>

<dependency>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-client</artifactId>
</dependency>

<dependency>
<groupId>com.tencent.polaris</groupId>
<artifactId>polaris-all</artifactId>
Expand Down Expand Up @@ -313,6 +308,24 @@
<artifactId>shenyu-discovery-zookeeper</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-discovery-etcd</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-discovery-eureka</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-discovery-nacos</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@ public void createProxySelector(final DiscoveryHandlerDTO discoveryHandlerDTO, f
if (Objects.isNull(shenyuDiscoveryService)) {
throw new ShenyuAdminException(String.format("before start ProxySelector you need init DiscoveryId=%s", discoveryHandlerDTO.getDiscoveryId()));
}
if (!shenyuDiscoveryService.exits(key)) {
if (!shenyuDiscoveryService.exists(key)) {
throw new ShenyuAdminException(String.format("shenyu discovery start watcher need you has this key %s in Discovery", key));
}
Set<String> cacheKey = dataChangedEventListenerCache.get(discoveryHandlerDTO.getDiscoveryId());
if (Objects.nonNull(cacheKey) && cacheKey.contains(key)) {
throw new ShenyuAdminException(String.format("shenyu discovery has watcher key = %s", key));
}
shenyuDiscoveryService.watcher(key, getDiscoveryDataChangedEventListener(discoveryHandlerDTO, proxySelectorDTO));
shenyuDiscoveryService.watch(key, getDiscoveryDataChangedEventListener(discoveryHandlerDTO, proxySelectorDTO));
cacheKey.add(key);
DataChangedEvent dataChangedEvent = new DataChangedEvent(ConfigGroupEnum.PROXY_SELECTOR, DataEventTypeEnum.CREATE,
Collections.singletonList(DiscoveryTransfer.INSTANCE.mapToData(proxySelectorDTO)));
Expand Down Expand Up @@ -159,7 +159,7 @@ public void removeProxySelector(final DiscoveryHandlerDTO discoveryHandlerDTO, f
String key = buildProxySelectorKey(discoveryHandlerDTO.getListenerNode());
Set<String> cacheKey = dataChangedEventListenerCache.get(discoveryHandlerDTO.getDiscoveryId());
cacheKey.remove(key);
shenyuDiscoveryService.unWatcher(key);
shenyuDiscoveryService.unwatch(key);
DataChangedEvent dataChangedEvent = new DataChangedEvent(ConfigGroupEnum.PROXY_SELECTOR, DataEventTypeEnum.DELETE,
Collections.singletonList(DiscoveryTransfer.INSTANCE.mapToData(proxySelectorDTO)));
eventPublisher.publishEvent(dataChangedEvent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,9 @@ public enum DiscoveryMode {
/**
* Eureka discovery mode.
*/
EUREKA
EUREKA,
/**
* ETCD discovery mode.
*/
ETCD
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ public DiscoveryProcessor chooseProcessor(final String mode) {
return localDiscoveryProcessor;
} else if (DiscoveryMode.ZOOKEEPER.name().equalsIgnoreCase(mode)) {
return defaultDiscoveryProcessor;
} else if (DiscoveryMode.ETCD.name().equalsIgnoreCase(mode)) {
return defaultDiscoveryProcessor;
} else if (DiscoveryMode.NACOS.name().equalsIgnoreCase(mode)) {
return defaultDiscoveryProcessor;
} else if (DiscoveryMode.EUREKA.name().equalsIgnoreCase(mode)) {
return defaultDiscoveryProcessor;
} else {
throw new NotImplementedException("shenyu discovery mode current didn't support " + mode);
}
Expand Down
1 change: 0 additions & 1 deletion shenyu-admin/src/main/resources/static/index.49ece78d.js

This file was deleted.

1 change: 1 addition & 0 deletions shenyu-admin/src/main/resources/static/index.8eee91d2.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions shenyu-admin/src/main/resources/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Apache ShenYu Gateway</title>
<link rel="icon" href="/favicon.ico" type="image/x-icon">
<link href="/index.03e7d63c.css" rel="stylesheet"></head>
<link href="/index.d99bb5eb.css" rel="stylesheet"></head>

<body>
<div id="httpPath" style="display: none" th:text="${domain}"></div>
<div id="root"></div>
<script type="text/javascript" src="/index.49ece78d.js"></script></body>
<script type="text/javascript" src="/index.8eee91d2.js"></script></body>

</html>
3 changes: 3 additions & 0 deletions shenyu-discovery/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
<modules>
<module>shenyu-discovery-api</module>
<module>shenyu-discovery-zookeeper</module>
<module>shenyu-discovery-etcd</module>
<module>shenyu-discovery-nacos</module>
<module>shenyu-discovery-eureka</module>
</modules>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ public interface ShenyuDiscoveryService {
void init(DiscoveryConfig config);

/**
* Watcher path , fire data changed event.
* Watch path , fire data changed event.
*
* @param key the key
* @param listener the listener
*/
void watcher(String key, DataChangedEventListener listener);
void watch(String key, DataChangedEventListener listener);

/**
* unWatcher path.
* unwatch path.
*
* @param key key
*/
void unWatcher(String key);
void unwatch(String key);

/**
* Register data.
Expand All @@ -68,12 +68,12 @@ public interface ShenyuDiscoveryService {
List<String> getRegisterData(String key);

/**
* exits.
* exists.
*
* @param key key
* @return Boolean
*/
Boolean exits(String key);
Boolean exists(String key);

/**
* shutdown.
Expand Down
87 changes: 87 additions & 0 deletions shenyu-discovery/shenyu-discovery-etcd/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-discovery</artifactId>
<version>2.6.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>shenyu-discovery-etcd</artifactId>

<dependencies>
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-discovery-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-common</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.etcd</groupId>
<artifactId>jetcd-core</artifactId>
<exclusions>
<exclusion>
<artifactId>grpc-protobuf</artifactId>
<groupId>io.grpc</groupId>
</exclusion>
<exclusion>
<artifactId>grpc-stub</artifactId>
<groupId>io.grpc</groupId>
</exclusion>
<exclusion>
<groupId>io.grpc</groupId>
<artifactId>grpc-core</artifactId>
</exclusion>
<exclusion>
<artifactId>grpc-netty</artifactId>
<groupId>io.grpc</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-core</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<artifactId>grpc-protobuf</artifactId>
<groupId>io.grpc</groupId>
<version>${grpc.version}</version>
</dependency>

<dependency>
<artifactId>grpc-stub</artifactId>
<groupId>io.grpc</groupId>
<version>${grpc.version}</version>
</dependency>

<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
</dependency>
</dependencies>

</project>
Loading

0 comments on commit f874b72

Please sign in to comment.