Skip to content

Commit 7f27ebf

Browse files
committed
[fit] 修改文件的格式问题以及增加必要的注释
1 parent 55cef74 commit 7f27ebf

File tree

12 files changed

+217
-214
lines changed

12 files changed

+217
-214
lines changed

examples/fit-example/08-nacos-complicated-apps/app-assistant/pom.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55

66
<groupId>org.fitframework.example</groupId>
7-
<artifactId>assistant-for-complicated</artifactId>
7+
<artifactId>nacos-assistant-for-complicated</artifactId>
88
<version>1.0-SNAPSHOT</version>
99

1010
<properties>
@@ -21,7 +21,7 @@
2121
<dependencies>
2222
<dependency>
2323
<groupId>org.fitframework.example</groupId>
24-
<artifactId>weather-for-complicated</artifactId>
24+
<artifactId>nacos-weather-for-complicated</artifactId>
2525
<version>1.0-SNAPSHOT</version>
2626
</dependency>
2727
<dependency>
@@ -81,7 +81,6 @@
8181
<version>${fit.version}</version>
8282
<scope>runtime</scope>
8383
</dependency>
84-
8584
</dependencies>
8685

8786
<build>

examples/fit-example/08-nacos-complicated-apps/app-default-weather/pom.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55

66
<groupId>org.fitframework.example</groupId>
7-
<artifactId>default-weather-for-complicated</artifactId>
7+
<artifactId>nacos-default-weather-for-complicated</artifactId>
88
<version>1.0-SNAPSHOT</version>
99

1010
<properties>
@@ -21,7 +21,7 @@
2121
<dependencies>
2222
<dependency>
2323
<groupId>org.fitframework.example</groupId>
24-
<artifactId>weather-for-complicated</artifactId>
24+
<artifactId>nacos-weather-for-complicated</artifactId>
2525
<version>1.0-SNAPSHOT</version>
2626
</dependency>
2727
<dependency>
@@ -74,7 +74,6 @@
7474
<version>${fit.version}</version>
7575
<scope>runtime</scope>
7676
</dependency>
77-
<!-- 注册中心的内nacos版实现 -->
7877
<dependency>
7978
<groupId>org.fitframework.plugin</groupId>
8079
<artifactId>fit-service-coordination-nacos</artifactId>

examples/fit-example/08-nacos-complicated-apps/service/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55

66
<groupId>org.fitframework.example</groupId>
7-
<artifactId>weather-for-complicated</artifactId>
7+
<artifactId>nacos-weather-for-complicated</artifactId>
88
<version>1.0-SNAPSHOT</version>
99

1010
<properties>

framework/fit/java/fit-builtin/plugins/fit-service-coordination-locator/src/main/java/modelengine/fit/service/locator/AddressRepository.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
package modelengine.fit.service.locator;
88

9+
import static modelengine.fitframework.inspection.Validation.greaterThan;
910
import static modelengine.fitframework.inspection.Validation.notNull;
1011

1112
import modelengine.fit.server.FitServer;
@@ -52,25 +53,23 @@ public AddressRepository(List<FitServer> servers, WorkerConfig worker, MatataCon
5253
int port = matata.registry().port();
5354
int protocolCode = matata.registry().protocolCode();
5455
CommunicationProtocol protocol = matata.registry().protocol();
55-
if(0 == port){
56-
Endpoint endpoint = fitServer.endpoints().stream().findFirst().orElse(null);
57-
notNull(endpoint, "The fit server must have at least one endpoint.");
56+
if (port == 0) {
57+
log.debug("The registry port is not set, using the first endpoint of the fit server.");
58+
int size = fitServer.endpoints().size();
59+
greaterThan(size, 0, "The fit server must have at least one endpoint.");
60+
Endpoint endpoint = fitServer.endpoints().get(0);
5861
port = endpoint.port();
5962
protocolCode = endpoint.protocolCode();
6063
protocol = CommunicationProtocol.from(endpoint.protocol());
6164
}
6265
String host = matata.registry().host();
63-
if(StringUtils.isBlank(matata.registry().host())) {
66+
if (StringUtils.isBlank(matata.registry().host())) {
67+
log.debug("The registry host is not set, using the worker host.");
6468
host = worker.host();
6569
}
66-
boolean isRegistryLocalhost = isRegistryLocalhost(actualServers,
67-
worker.host(),
68-
worker.domain(),
69-
host,
70-
port,
71-
protocolCode);
72-
String registryWorkerId =
73-
isRegistryLocalhost ? worker.id() : host + ":" + port;
70+
boolean isRegistryLocalhost =
71+
isRegistryLocalhost(actualServers, worker.host(), worker.domain(), host, port, protocolCode);
72+
String registryWorkerId = isRegistryLocalhost ? worker.id() : host + ":" + port;
7473
this.registryTarget = Target.custom()
7574
.workerId(registryWorkerId)
7675
.host(host)
@@ -85,7 +84,7 @@ public AddressRepository(List<FitServer> servers, WorkerConfig worker, MatataCon
8584
}
8685

8786
private static boolean isRegistryLocalhost(List<FitServer> servers, String localHost, String localDomain,
88-
String registryHost, int registryPort, int registryProtocol) {
87+
String registryHost, int registryPort, int registryProtocol) {
8988
if (!isRegistryHost(localHost, localDomain, registryHost)) {
9089
return false;
9190
}

framework/fit/java/fit-builtin/plugins/fit-service-coordination-nacos/pom.xml

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<!--
3-
~ Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
4-
~ This file is a part of the ModelEngine Project.
5-
~ Licensed under the MIT License. See License.txt in the project root for license information.
6-
-->
7-
8-
<project xmlns="http://maven.apache.org/POM/4.0.0"
9-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
103
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
114
<modelVersion>4.0.0</modelVersion>
5+
126
<parent>
137
<groupId>org.fitframework.plugin</groupId>
148
<artifactId>fit-plugin-parent</artifactId>
@@ -18,18 +12,12 @@
1812
<artifactId>fit-service-coordination-nacos</artifactId>
1913

2014
<name>FIT Service Coordination Nacos</name>
21-
<description>FIT Framework Service Coordination Nacos Plugin module provides a nacos-based implementation of FIT service
22-
registry center.
15+
<description>FIT Framework Service Coordination Nacos Plugin module provides a nacos-based implementation of FIT
16+
service registry center.
2317
</description>
2418
<url>https://github.com/ModelEngine-Group/fit-framework</url>
2519

2620
<dependencies>
27-
<!-- nacos-client -->
28-
<dependency>
29-
<groupId>com.alibaba.nacos</groupId>
30-
<artifactId>nacos-client</artifactId>
31-
<version>3.0.1</version>
32-
</dependency>
3321
<!-- FIT core -->
3422
<dependency>
3523
<groupId>org.fitframework</groupId>
@@ -54,6 +42,16 @@
5442
<artifactId>fit-http-classic</artifactId>
5543
</dependency>
5644

45+
<!-- Third-party -->
46+
<dependency>
47+
<groupId>org.projectlombok</groupId>
48+
<artifactId>lombok</artifactId>
49+
</dependency>
50+
<dependency>
51+
<groupId>com.alibaba.nacos</groupId>
52+
<artifactId>nacos-client</artifactId>
53+
</dependency>
54+
5755
<!-- Test -->
5856
<dependency>
5957
<groupId>org.junit.jupiter</groupId>
@@ -70,11 +68,6 @@
7068
<artifactId>assertj-core</artifactId>
7169
<scope>test</scope>
7270
</dependency>
73-
<!-- tool -->
74-
<dependency>
75-
<groupId>org.projectlombok</groupId>
76-
<artifactId>lombok</artifactId>
77-
</dependency>
7871
</dependencies>
7972

8073
<build>
@@ -99,5 +92,4 @@
9992
</plugin>
10093
</plugins>
10194
</build>
102-
10395
</project>

framework/fit/java/fit-builtin/plugins/fit-service-coordination-nacos/src/main/java/modelengine/fit/heartbeat/server/HeartbeatConfig.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import lombok.Data;
1010
import modelengine.fitframework.annotation.AcceptConfigValues;
1111
import modelengine.fitframework.annotation.Component;
12-
import modelengine.fitframework.conf.Config;
1312

1413
/**
1514
* 表示配置项 {@code 'nacos.heartbeat'} 下的配置。
@@ -21,7 +20,6 @@
2120
@AcceptConfigValues("nacos.heartbeat")
2221
@Data
2322
public class HeartbeatConfig {
24-
2523
/**
2624
* 是否为临时实例,默认为 true。
2725
* 临时实例在服务注销后会自动从注册中心移除。
@@ -35,14 +33,14 @@ public class HeartbeatConfig {
3533
private Float weight = 1.0F;
3634

3735
/**
38-
* 心跳间隔时间(单位:)。
36+
* 心跳间隔时间(单位:毫秒)。
3937
* 定义服务发送心跳的时间间隔。
4038
*/
4139
private Integer heartBeatInterval;
4240

4341
/**
44-
* 心跳超时时间(单位:)。
42+
* 心跳超时时间(单位:毫秒)。
4543
* 定义服务在未收到心跳后判定为超时的时间。
4644
*/
4745
private Integer heartBeatTimeout;
48-
}
46+
}

framework/fit/java/fit-builtin/plugins/fit-service-coordination-nacos/src/main/java/modelengine/fit/heartbeat/server/HeartbeatServer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* 用于提供心跳相关的服务。
1717
*
1818
* @author 董智豪
19-
* @since 2025/6/4
19+
* @since 2025-06-04
2020
*/
2121
@Component
2222
public class HeartbeatServer implements HeartbeatService {
@@ -30,4 +30,4 @@ public Boolean sendHeartbeat(List<HeartbeatInfo> heartbeatInfo, Address address)
3030
public Boolean stopHeartbeat(List<HeartbeatInfo> heartbeatInfo, Address address) {
3131
return true;
3232
}
33-
}
33+
}

framework/fit/java/fit-builtin/plugins/fit-service-coordination-nacos/src/main/java/modelengine/fit/service/server/NacosConfig.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66

77
package modelengine.fit.service.server;
88

9-
import lombok.AllArgsConstructor;
10-
import lombok.Builder;
119
import lombok.Data;
12-
import lombok.NoArgsConstructor;
1310
import modelengine.fitframework.annotation.AcceptConfigValues;
1411
import modelengine.fitframework.annotation.Component;
1512

@@ -52,5 +49,4 @@ public class NacosConfig {
5249
* 命名空间
5350
*/
5451
private String namespace;
55-
}
56-
52+
}

0 commit comments

Comments
 (0)