Skip to content

Commit 557256e

Browse files
committed
[feat] init shenyu java client
1 parent 9d3bd58 commit 557256e

File tree

328 files changed

+38171
-13
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

328 files changed

+38171
-13
lines changed

.asf.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,12 @@ github:
3232
merge: false
3333
rebase: false
3434
protected_branches:
35-
master:
35+
main:
3636
required_status_checks:
3737
strict: true
3838
contexts:
3939
- check-license-header
4040
- build
41-
- e2e
4241
required_pull_request_reviews:
4342
dismiss_stale_reviews: true
4443
required_approving_review_count: 1

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<packaging>pom</packaging>
3030
<version>2.7.1-SNAPSHOT</version>
3131
<modules>
32+
<module>shenyu-java-common</module>
3233
<module>shenyu-client-java-core</module>
3334
<module>shenyu-client-java-http</module>
3435
<module>shenyu-client-java-dubbo</module>
@@ -39,6 +40,8 @@
3940
<module>shenyu-client-java-websocket</module>
4041
<module>shenyu-client-java-api-docs-annotations</module>
4142
<module>shenyu-client-java-autoconfig</module>
43+
<module>shenyu-register-java-common</module>
44+
<module>shenyu-register-java-client</module>
4245
<module>shenyu-spring-boot-starter-java-client</module>
4346
<module>shenyu-java-examples</module>
4447
</modules>
@@ -66,6 +69,10 @@
6669
<maven-shade-plugin.version>3.5.1</maven-shade-plugin.version>
6770
<docker-maven-plugin.version>0.40.1</docker-maven-plugin.version>
6871
<maven-assembly-plugin.version>3.5.0</maven-assembly-plugin.version>
72+
<wiremock.version>2.18.0</wiremock.version>
73+
<commons-collections4.version>4.4</commons-collections4.version>
74+
<asm.version>9.2</asm.version>
75+
<bcprov-jdk18on.version>1.78</bcprov-jdk18on.version>
6976
<!-- maven plugin version end -->
7077

7178
<!-- dependency version start -->

shenyu-client-java-core/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@
6565
</dependency>
6666
<dependency>
6767
<groupId>org.apache.shenyu</groupId>
68-
<artifactId>shenyu-register-client-http</artifactId>
69-
<version>2.6.1</version>
68+
<artifactId>shenyu-register-java-client-http</artifactId>
69+
<version>${project.version}</version>
7070
</dependency>
7171
<dependency>
7272
<groupId>org.springframework</groupId>
@@ -85,7 +85,7 @@
8585
</dependency>
8686
<dependency>
8787
<groupId>org.apache.shenyu</groupId>
88-
<artifactId>shenyu-client-api-docs-annotations</artifactId>
88+
<artifactId>shenyu-client-java-api-docs-annotations</artifactId>
8989
<version>${project.version}</version>
9090
</dependency>
9191
<dependency>

shenyu-java-common/pom.xml

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one or more
4+
~ contributor license agreements. See the NOTICE file distributed with
5+
~ this work for additional information regarding copyright ownership.
6+
~ The ASF licenses this file to You under the Apache License, Version 2.0
7+
~ (the "License"); you may not use this file except in compliance with
8+
~ the License. You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing, software
13+
~ distributed under the License is distributed on an "AS IS" BASIS,
14+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
~ See the License for the specific language governing permissions and
16+
~ limitations under the License.
17+
-->
18+
19+
<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">
20+
<parent>
21+
<groupId>org.apache.shenyu</groupId>
22+
<artifactId>shenyu-client-java</artifactId>
23+
<version>2.7.1-SNAPSHOT</version>
24+
</parent>
25+
<modelVersion>4.0.0</modelVersion>
26+
<artifactId>shenyu-java-common</artifactId>
27+
28+
<dependencies>
29+
<dependency>
30+
<groupId>com.google.code.gson</groupId>
31+
<artifactId>gson</artifactId>
32+
</dependency>
33+
34+
<dependency>
35+
<groupId>org.apache.commons</groupId>
36+
<artifactId>commons-lang3</artifactId>
37+
</dependency>
38+
39+
<dependency>
40+
<groupId>com.fasterxml.jackson.core</groupId>
41+
<artifactId>jackson-databind</artifactId>
42+
</dependency>
43+
44+
<dependency>
45+
<groupId>com.fasterxml.jackson.datatype</groupId>
46+
<artifactId>jackson-datatype-jdk8</artifactId>
47+
</dependency>
48+
<dependency>
49+
<groupId>com.fasterxml.jackson.datatype</groupId>
50+
<artifactId>jackson-datatype-jsr310</artifactId>
51+
</dependency>
52+
53+
<dependency>
54+
<groupId>com.fasterxml.jackson.module</groupId>
55+
<artifactId>jackson-module-parameter-names</artifactId>
56+
</dependency>
57+
58+
<dependency>
59+
<groupId>org.apache.commons</groupId>
60+
<artifactId>commons-collections4</artifactId>
61+
<version>${commons-collections4.version}</version>
62+
</dependency>
63+
64+
<dependency>
65+
<groupId>com.github.ben-manes.caffeine</groupId>
66+
<artifactId>caffeine</artifactId>
67+
</dependency>
68+
<dependency>
69+
<groupId>commons-codec</groupId>
70+
<artifactId>commons-codec</artifactId>
71+
</dependency>
72+
73+
<dependency>
74+
<groupId>org.ow2.asm</groupId>
75+
<artifactId>asm-tree</artifactId>
76+
<version>${asm.version}</version>
77+
</dependency>
78+
79+
<dependency>
80+
<groupId>io.projectreactor.netty</groupId>
81+
<artifactId>reactor-netty-core</artifactId>
82+
</dependency>
83+
84+
<dependency>
85+
<groupId>io.projectreactor.netty</groupId>
86+
<artifactId>reactor-netty-http</artifactId>
87+
</dependency>
88+
89+
<dependency>
90+
<groupId>org.bouncycastle</groupId>
91+
<artifactId>bcprov-jdk18on</artifactId>
92+
<version>${bcprov-jdk18on.version}</version>
93+
</dependency>
94+
<dependency>
95+
<groupId>org.slf4j</groupId>
96+
<artifactId>slf4j-api</artifactId>
97+
</dependency>
98+
<dependency>
99+
<groupId>org.slf4j</groupId>
100+
<artifactId>jcl-over-slf4j</artifactId>
101+
</dependency>
102+
<dependency>
103+
<groupId>com.google.code.findbugs</groupId>
104+
<artifactId>jsr305</artifactId>
105+
<version>3.0.2</version>
106+
</dependency>
107+
<dependency>
108+
<groupId>com.google.guava</groupId>
109+
<artifactId>guava</artifactId>
110+
<version>32.0.0-jre</version>
111+
<exclusions>
112+
<exclusion>
113+
<groupId>com.google.re2j</groupId>
114+
<artifactId>re2j</artifactId>
115+
</exclusion>
116+
</exclusions>
117+
</dependency>
118+
<dependency>
119+
<groupId>org.hamcrest</groupId>
120+
<artifactId>hamcrest</artifactId>
121+
<version>2.2</version>
122+
<scope>test</scope>
123+
</dependency>
124+
<dependency>
125+
<groupId>org.mockito</groupId>
126+
<artifactId>mockito-junit-jupiter</artifactId>
127+
<version>4.11.0</version>
128+
<scope>test</scope>
129+
</dependency>
130+
<dependency>
131+
<groupId>org.mockito</groupId>
132+
<artifactId>mockito-inline</artifactId>
133+
<version>3.3.3</version>
134+
<scope>test</scope>
135+
</dependency>
136+
<dependency>
137+
<groupId>org.junit.jupiter</groupId>
138+
<artifactId>junit-jupiter-api</artifactId>
139+
<version>5.8.2</version>
140+
<scope>test</scope>
141+
</dependency>
142+
<dependency>
143+
<groupId>org.junit.jupiter</groupId>
144+
<artifactId>junit-jupiter-params</artifactId>
145+
<version>5.8.2</version>
146+
<scope>test</scope>
147+
</dependency>
148+
<!-- https://mvnrepository.com/artifact/junit/junit -->
149+
<dependency>
150+
<groupId>junit</groupId>
151+
<artifactId>junit</artifactId>
152+
<version>4.13.2</version>
153+
<scope>test</scope>
154+
</dependency>
155+
156+
</dependencies>
157+
</project>
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.shenyu.common.cache;
19+
20+
import org.apache.commons.collections4.map.LRUMap;
21+
import org.apache.shenyu.common.concurrent.MemoryLimitCalculator;
22+
23+
import javax.annotation.concurrent.NotThreadSafe;
24+
import java.util.Map;
25+
26+
/**
27+
* The only difference between this class and {@link org.apache.commons.collections4.map.LRUMap}
28+
* is that it handles memory issues via {@link org.apache.shenyu.common.concurrent.MemoryLimitCalculator}.
29+
*
30+
* <p>Note: this class is not thread safe! see https://github.com/apache/shenyu/issues/3929
31+
*/
32+
@NotThreadSafe
33+
public class MemorySafeLRUMap<K, V> extends LRUMap<K, V> {
34+
35+
private final int maxFreeMemory;
36+
37+
public MemorySafeLRUMap(final int maxFreeMemory,
38+
final int initialSize) {
39+
super(MAXIMUM_CAPACITY, initialSize);
40+
this.maxFreeMemory = maxFreeMemory;
41+
}
42+
43+
public MemorySafeLRUMap(final int maxFreeMemory,
44+
final int initialSize,
45+
final float loadFactor) {
46+
super(MAXIMUM_CAPACITY, initialSize, loadFactor);
47+
this.maxFreeMemory = maxFreeMemory;
48+
}
49+
50+
public MemorySafeLRUMap(final int maxFreeMemory,
51+
final int initialSize,
52+
final float loadFactor,
53+
final boolean scanUntilRemovable) {
54+
super(MAXIMUM_CAPACITY, initialSize, loadFactor, scanUntilRemovable);
55+
this.maxFreeMemory = maxFreeMemory;
56+
}
57+
58+
public MemorySafeLRUMap(final int maxFreeMemory,
59+
final Map<? extends K, ? extends V> map) {
60+
super(map);
61+
this.maxFreeMemory = maxFreeMemory;
62+
}
63+
64+
public MemorySafeLRUMap(final int maxFreeMemory,
65+
final Map<? extends K, ? extends V> map,
66+
final boolean scanUntilRemovable) {
67+
super(map, scanUntilRemovable);
68+
this.maxFreeMemory = maxFreeMemory;
69+
}
70+
71+
@Override
72+
public boolean isFull() {
73+
// when free memory less than certain value, consider it's full
74+
return size() > 0 && MemoryLimitCalculator.maxAvailable() < maxFreeMemory;
75+
}
76+
}

0 commit comments

Comments
 (0)