Skip to content

Commit cee315f

Browse files
trickMinmarkGbugshuxingzfw
authored
feat: release-v1.1 features and bugfixs (#11)
* feat: update Springboot maven version to 2.5.14 (#9) Signed-off-by: yutao04 <[email protected]> Signed-off-by: yutao04 <[email protected]> * feat: support nacos registry Signed-off-by: zhangbaojun <[email protected]> * feat: switch mesh-registry debug interface to slime Signed-off-by: zhufengwei <[email protected]> Signed-off-by: yutao04 <[email protected]> Signed-off-by: zhangbaojun <[email protected]> Signed-off-by: zhufengwei <[email protected]> Co-authored-by: 张宝军 <[email protected]> Co-authored-by: zhufengwei <[email protected]>
1 parent 2533cc6 commit cee315f

File tree

11 files changed

+52
-33
lines changed

11 files changed

+52
-33
lines changed

hango-api-plane-server/pom.xml

+7-9
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,26 @@
2020
<dependency>
2121
<groupId>org.springframework.boot</groupId>
2222
<artifactId>spring-boot-starter-web</artifactId>
23-
<version>1.5.8.RELEASE</version>
2423
</dependency>
2524

2625
<dependency>
2726
<groupId>org.springframework.boot</groupId>
2827
<artifactId>spring-boot-starter-aop</artifactId>
29-
<version>1.5.8.RELEASE</version>
3028
</dependency>
3129

3230
<dependency>
3331
<groupId>org.springframework.boot</groupId>
3432
<artifactId>spring-boot-starter-freemarker</artifactId>
35-
<version>1.5.8.RELEASE</version>
3633
</dependency>
3734

3835
<dependency>
3936
<groupId>org.springframework.boot</groupId>
4037
<artifactId>spring-boot-starter-jdbc</artifactId>
41-
<version>1.5.8.RELEASE</version>
4238
</dependency>
4339

4440
<dependency>
4541
<groupId>org.springframework.boot</groupId>
4642
<artifactId>spring-boot-starter-test</artifactId>
47-
<version>1.5.8.RELEASE</version>
4843
</dependency>
4944

5045
<dependency>
@@ -64,7 +59,12 @@
6459
<dependency>
6560
<groupId>org.apache.commons</groupId>
6661
<artifactId>commons-lang3</artifactId>
67-
<version>3.6</version>
62+
</dependency>
63+
64+
<dependency>
65+
<groupId>org.hibernate</groupId>
66+
<artifactId>hibernate-validator</artifactId>
67+
<version>5.3.6.Final</version>
6868
</dependency>
6969

7070
<!-- https://mvnrepository.com/artifact/commons-net/commons-net -->
@@ -84,7 +84,6 @@
8484
<dependency>
8585
<groupId>org.apache.commons</groupId>
8686
<artifactId>commons-dbcp2</artifactId>
87-
<version>2.1.1</version>
8887
<exclusions>
8988
<exclusion>
9089
<artifactId>commons-logging</artifactId>
@@ -142,7 +141,6 @@
142141
<dependency>
143142
<groupId>com.jayway.jsonpath</groupId>
144143
<artifactId>json-path</artifactId>
145-
<version>2.4.0</version>
146144
</dependency>
147145

148146
<dependency>
@@ -161,7 +159,7 @@
161159
<dependency>
162160
<groupId>net.devh</groupId>
163161
<artifactId>grpc-server-spring-boot-starter</artifactId>
164-
<version>1.4.0.RELEASE</version>
162+
<version>2.13.1.RELEASE</version>
165163
</dependency>
166164

167165
<!-- https://mvnrepository.com/artifact/org.reflections/reflections -->

hango-api-plane-server/src/main/java/org/hango/cloud/ApiPlaneApplication.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import org.springframework.boot.autoconfigure.SpringBootApplication;
66
import org.springframework.boot.builder.SpringApplicationBuilder;
77
import org.springframework.boot.context.properties.EnableConfigurationProperties;
8-
import org.springframework.boot.web.support.SpringBootServletInitializer;
8+
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
99
import org.springframework.context.annotation.EnableAspectJAutoProxy;
1010
import org.springframework.context.annotation.PropertySource;
1111
import org.springframework.scheduling.annotation.EnableAsync;

hango-api-plane-server/src/main/java/org/hango/cloud/configuration/ApiPlaneAutoBaseConfiguration.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@
2626
import org.springframework.http.client.ClientHttpRequestInterceptor;
2727
import org.springframework.http.client.InterceptingClientHttpRequestFactory;
2828
import org.springframework.http.client.SimpleClientHttpRequestFactory;
29+
import org.springframework.util.ResourceUtils;
2930
import org.springframework.web.client.RestTemplate;
3031

3132
import javax.annotation.PostConstruct;
33+
import java.io.IOException;
34+
import java.time.Duration;
3235
import java.util.List;
3336

3437

@@ -46,7 +49,7 @@ RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) {
4649

4750
return restTemplateBuilder
4851
.interceptors(interceptors)
49-
.requestFactory(new InterceptingClientHttpRequestFactory(
52+
.requestFactory(() -> new InterceptingClientHttpRequestFactory(
5053
new BufferingClientHttpRequestFactory(new SimpleClientHttpRequestFactory()), interceptors))
5154
.build();
5255
}
@@ -57,9 +60,9 @@ RestTemplate shortTimeoutRestTemplate(RestTemplateBuilder restTemplateBuilder) {
5760
List<ClientHttpRequestInterceptor> interceptors = ImmutableList.of(new RestTemplateLogInterceptor());
5861

5962
return restTemplateBuilder
60-
.setConnectTimeout(1000)
63+
.setConnectTimeout(Duration.ofSeconds(1))
6164
.interceptors(interceptors)
62-
.requestFactory(new InterceptingClientHttpRequestFactory(
65+
.requestFactory(() -> new InterceptingClientHttpRequestFactory(
6366
new BufferingClientHttpRequestFactory(new SimpleClientHttpRequestFactory()), interceptors))
6467
.build();
6568
}
@@ -88,7 +91,8 @@ ObjectMapper jsonObjectMapper() {
8891
}
8992

9093
@PostConstruct
91-
void configureFreemarkerConfig() {
94+
void configureFreemarkerConfig() throws IOException {
95+
freemarkerConfig.setDirectoryForTemplateLoading(ResourceUtils.getFile("classpath:template"));
9296
freemarkerConfig.setNumberFormat("#");
9397
freemarkerConfig.setSharedVariable("indent", new IndentationDirective());
9498
freemarkerConfig.setSharedVariable("ignore", new IgnoreDirective());

hango-api-plane-server/src/main/java/org/hango/cloud/configuration/env/NonK8sConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.hango.cloud.configuration.env;
22

3+
import io.grpc.netty.shaded.io.grpc.netty.NettyServerBuilder;
34
import org.hango.cloud.configuration.ext.K8sMultiClusterProperties;
45
import org.hango.cloud.core.GlobalConfig;
56
import org.hango.cloud.core.editor.EditorContext;
@@ -36,7 +37,6 @@
3637
import org.hango.cloud.service.GatewayService;
3738
import org.hango.cloud.service.impl.GatewayServiceImpl;
3839
import io.grpc.Server;
39-
import io.grpc.netty.NettyServerBuilder;
4040
import istio.mcp.nsf.SnapshotOuterClass;
4141
import istio.mcp.v1alpha1.Mcp;
4242
import istio.mcp.v1alpha1.ResourceOuterClass;
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
package org.hango.cloud.configuration.ext;
22

3-
import org.springframework.boot.env.YamlPropertySourceLoader;
3+
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
4+
import org.springframework.core.env.PropertiesPropertySource;
5+
import org.springframework.core.env.PropertySource;
46
import org.springframework.core.io.support.DefaultPropertySourceFactory;
57
import org.springframework.core.io.support.EncodedResource;
68

79
import java.io.IOException;
10+
import java.util.Properties;
811

912
public class YamlPropertyLoaderFactory extends DefaultPropertySourceFactory {
1013
@Override
11-
public org.springframework.core.env.PropertySource<?> createPropertySource(String name, EncodedResource resource) throws IOException {
12-
return new YamlPropertySourceLoader().load(resource.getResource().getFilename(), resource.getResource(), null);
14+
public PropertySource<?> createPropertySource(String name, EncodedResource resource) throws IOException {
15+
YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
16+
factory.setResources(resource.getResource());
17+
Properties properties = factory.getObject();
18+
return new PropertiesPropertySource(resource.getResource().getFilename(), properties);
1319
}
14-
}
20+
}

hango-api-plane-server/src/main/java/org/hango/cloud/configuration/mode/GatewayAutoConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.hango.cloud.configuration.mode;
22

3+
import net.devh.boot.grpc.server.serverfactory.GrpcServerLifecycle;
34
import org.hango.cloud.configuration.ApiPlaneAutoBaseConfiguration;
4-
import net.devh.springboot.autoconfigure.grpc.server.GrpcServerLifecycle;
55
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
66
import org.springframework.context.annotation.Bean;
77
import org.springframework.context.annotation.Configuration;

hango-api-plane-server/src/main/java/org/hango/cloud/core/istio/PilotHttpClient.java

+14-10
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@
1010
import com.google.common.collect.ImmutableMap;
1111
import io.fabric8.kubernetes.api.model.Service;
1212
import io.fabric8.kubernetes.api.model.ServicePort;
13-
import net.minidev.json.JSONObject;
13+
import org.apache.commons.lang3.ArrayUtils;
14+
import org.apache.commons.lang3.StringUtils;
1415
import org.hango.cloud.core.k8s.K8sResourceEnum;
1516
import org.hango.cloud.core.k8s.KubernetesClient;
1617
import org.hango.cloud.meta.Endpoint;
17-
import org.hango.cloud.meta.dto.PortalServiceDTO;
1818
import org.hango.cloud.util.Const;
1919
import org.hango.cloud.util.exception.ApiPlaneException;
20-
import org.apache.commons.lang3.ArrayUtils;
21-
import org.apache.commons.lang3.StringUtils;
2220
import org.hango.cloud.util.exception.ExceptionConst;
2321
import org.slf4j.Logger;
2422
import org.slf4j.LoggerFactory;
@@ -31,7 +29,10 @@
3129
import org.springframework.web.client.RestTemplate;
3230

3331
import javax.annotation.PostConstruct;
34-
import java.util.*;
32+
import java.util.ArrayList;
33+
import java.util.HashMap;
34+
import java.util.List;
35+
import java.util.Map;
3536
import java.util.concurrent.ExecutionException;
3637
import java.util.concurrent.TimeUnit;
3738
import java.util.stream.Collectors;
@@ -51,7 +52,7 @@ public class PilotHttpClient {
5152
@Value(value = "${istioName:istiod}")
5253
private String ISTIO_NAME;
5354

54-
@Value(value = "${meshRegistryName:galley}")
55+
@Value(value = "${meshRegistryName:slime}")
5556
private String MESH_REGISTRY_NAME;
5657

5758
private static final String GET_ENDPOINTZ_PATH = "/debug/endpointz?brief=true&servicePort=true";
@@ -87,6 +88,9 @@ public class PilotHttpClient {
8788

8889
public static final Integer ERROR_PORT = -1;
8990

91+
private static final String ISTIOD_DEBUG_PORT_NAME = "http-legacy-discovery";
92+
private static final String MESH_REGISTRY_DEBUG_PORT_NAME = "aux-port";
93+
9094
@PostConstruct
9195
void cacheInit() {
9296
endpointsCache = CacheBuilder.newBuilder()
@@ -104,12 +108,12 @@ public Object load(String key) throws Exception {
104108

105109
private String getIstioUrl() {
106110
if (!StringUtils.isEmpty(istioHttpUrl)) return istioHttpUrl;
107-
return getSvcUrl(ISTIO_NAME);
111+
return getSvcUrl(ISTIO_NAME, ISTIOD_DEBUG_PORT_NAME);
108112
}
109113

110114
private String getMeshRegistryUrl() {
111115
if (!StringUtils.isEmpty(meshRegistryHttpUrl)) return meshRegistryHttpUrl;
112-
return getSvcUrl(MESH_REGISTRY_NAME);
116+
return getSvcUrl(MESH_REGISTRY_NAME, MESH_REGISTRY_DEBUG_PORT_NAME);
113117
}
114118

115119
public List<Endpoint> getDubboEndpoints(String igv){
@@ -266,15 +270,15 @@ public <T> ResponseEntity<T> getForEntity(String str, Class<T> clz) {
266270
return entity;
267271
}
268272

269-
public String getSvcUrl(String svcName) {
273+
public String getSvcUrl(String svcName, String portName) {
270274
List<Service> pilotServices = client.getObjectList(K8sResourceEnum.Service.name(), NAMESPACE, ImmutableMap.of("app", svcName));
271275
if (CollectionUtils.isEmpty(pilotServices)) throw new ApiPlaneException(ExceptionConst.PILOT_SERVICE_NON_EXIST);
272276
Service service = pilotServices.get(0);
273277
String ip = service.getSpec().getClusterIP();
274278
List<ServicePort> ports = service.getSpec().getPorts();
275279
//get port by name equal http-legacy-discovery
276280
for (ServicePort port : ports) {
277-
if ("http-legacy-discovery".equalsIgnoreCase(port.getName())) {
281+
if (StringUtils.equalsIgnoreCase(portName, port.getName())){
278282
return String.format("http://%s:%s", ip, port.getPort());
279283
}
280284
}

hango-api-plane-server/src/main/java/org/hango/cloud/mcp/ratelimit/RlsClusterClient.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public RlsClusterClient(McpOptions mcpOptions, ResourceDao resourceDao, McpMarsh
3333
for (String address : mcpOptions.getRegisteredRlsCluster()) {
3434
String[] hostPort = StringUtils.split(address, ":");
3535
if (hostPort.length == 2) {
36-
ManagedChannel channel = ManagedChannelBuilder.forAddress(hostPort[0], Integer.parseInt(hostPort[1])).usePlaintext(true).build();
36+
ManagedChannel channel = ManagedChannelBuilder.forAddress(hostPort[0], Integer.parseInt(hostPort[1])).usePlaintext().build();
3737
stubs.add(RatelimitConfigServiceGrpc.newStub(channel));
3838
}
3939
}

hango-api-plane-server/src/main/java/org/hango/cloud/util/freemarker/SupplyDirective.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void execute(Environment environment, Map parameters, TemplateModel[] loo
6868
gen.createOrUpdateValue("$[?]", "name", Keyword.API.replacement, Criteria.where("name").exists(false));
6969

7070
String yaml = gen.yamlString();
71-
yaml = yaml.replaceAll("(?m)^(-?\\s*)nsf-template-.*?:(?:\\s*)(<.*>)", "$1$2");
71+
yaml = yaml.replaceAll("(?m)^(-?\\s*)nsf-template-.*?:(?:\\s*)\"(<.*>)\"", "$1$2");
7272

7373
environment.getOut().write(yaml);
7474
writer.close();

hango-api-plane-server/src/test/java/org/hango/cloud/core/BaseConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.hango.cloud.core;
22

3-
import net.devh.springboot.autoconfigure.grpc.server.GrpcServerLifecycle;
3+
import net.devh.boot.grpc.server.serverfactory.GrpcServerLifecycle;
44
import org.springframework.context.annotation.Bean;
55
import org.springframework.context.annotation.Configuration;
66

pom.xml

+7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
<sonar.jacoco.reportPath>${project.basedir}/../target/jacoco.exec</sonar.jacoco.reportPath>
1717
<sonar.language>java</sonar.language>
1818
</properties>
19+
20+
<parent>
21+
<groupId>org.springframework.boot</groupId>
22+
<artifactId>spring-boot-starter-parent</artifactId>
23+
<version>2.5.14</version>
24+
</parent>
25+
1926
<modules>
2027
<module>hango-proto</module>
2128
<module>hango-api-plane-server</module>

0 commit comments

Comments
 (0)