Skip to content

Commit 522d46e

Browse files
authored
feature:init Namingserver server (#6538)
1 parent a3aa11b commit 522d46e

File tree

29 files changed

+1119
-26
lines changed

29 files changed

+1119
-26
lines changed

build/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
<kafka-appender.version>0.2.0-RC2</kafka-appender.version>
8989
<kafka-clients.version>3.6.1</kafka-clients.version>
9090
<snakeyaml.version>2.0</snakeyaml.version>
91+
<jackson-mapper.version>1.9.13</jackson-mapper.version>
9192

9293
<!-- For test -->
9394
<junit-jupiter.version>5.8.2</junit-jupiter.version>

changes/en-us/2.x.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Add changes here for all PR submitted to the 2.x branch.
55
### feature:
66
- [[#6226](https://github.com/apache/incubator-seata/pull/6226)] multi-version seata protocol support
77
- [[#6537](https://github.com/apache/incubator-seata/pull/6537)] support Namingserver
8-
8+
- [[#6538](https://github.com/apache/incubator-seata/pull/6538)] Integration of naming server on the Seata server side
99
### bugfix:
1010
- [[#6592](https://github.com/apache/incubator-seata/pull/6592)] fix @Async annotation not working in ClusterWatcherManager
1111
- [[#6624](https://github.com/apache/incubator-seata/pull/6624)] fix Alibaba Dubbo convert error

changes/zh-cn/2.x.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### feature:
66
- [[#6226](https://github.com/apache/incubator-seata/pull/6226)] 支持seata私有协议多版本兼容
77
- [[#6537](https://github.com/apache/incubator-seata/pull/6537)] 支持 Namingserver
8+
- [[#6538](https://github.com/apache/incubator-seata/pull/6538)] seata server端集成naming server
89

910
### bugfix:
1011
- [[#6592](https://github.com/apache/incubator-seata/pull/6592)] fix @Async注解ClusterWatcherManager中不生效的问题
@@ -49,6 +50,7 @@
4950

5051

5152

53+
5254
非常感谢以下 contributors 的代码贡献。若有无意遗漏,请报告。
5355

5456
<!-- 请确保您的 GitHub ID 在以下列表中 -->

common/src/main/java/org/apache/seata/common/ConfigurationKeys.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,11 @@ public interface ConfigurationKeys {
811811
*/
812812
String SERVER_ENABLE_CHECK_AUTH = SERVER_PREFIX + "enableCheckAuth";
813813

814+
/**
815+
* The constant NAMING_SERVER
816+
*/
817+
String NAMING_SERVER = "namingserver";
818+
814819
/**
815820
* The constant APPLICATION_ID.
816821
*/
@@ -1011,4 +1016,39 @@ public interface ConfigurationKeys {
10111016
* The constant ROCKET_MQ_MSG_TIMEOUT
10121017
*/
10131018
String ROCKET_MQ_MSG_TIMEOUT = SERVER_PREFIX + "rocketmqMsgTimeout";
1019+
1020+
/**
1021+
*
1022+
*/
1023+
String NAMINGSERVER_REGISTRY_PREFIX = FILE_ROOT_REGISTRY + FILE_CONFIG_SPLIT_CHAR + NAMING_SERVER + FILE_CONFIG_SPLIT_CHAR;
1024+
1025+
/**
1026+
*
1027+
*/
1028+
String SEATA_NAMINGSERVER_REGISTRY_PREFIX = SEATA_FILE_ROOT_CONFIG + FILE_CONFIG_SPLIT_CHAR + NAMINGSERVER_REGISTRY_PREFIX;
1029+
1030+
/**
1031+
* The constant REGISTRY_NAMINGSERVER_CLUSTER
1032+
*/
1033+
String REGISTRY_NAMINGSERVER_CLUSTER = NAMINGSERVER_REGISTRY_PREFIX + "cluster";
1034+
1035+
/**
1036+
* The constant MAPPING_TABLE_NAME
1037+
*/
1038+
String MAPPING_TABLE_NAME = STORE_DB_PREFIX + FILE_CONFIG_SPLIT_CHAR + "mapping-table";
1039+
1040+
/**
1041+
* The constant NAMESPACE_KEY
1042+
*/
1043+
String NAMESPACE_KEY = SEATA_NAMINGSERVER_REGISTRY_PREFIX + "namespace";
1044+
1045+
/**
1046+
* The constant CLUSTER_NAME_KEY
1047+
*/
1048+
String CLUSTER_NAME_KEY = SEATA_FILE_ROOT_CONFIG + FILE_CONFIG_SPLIT_CHAR + REGISTRY_NAMINGSERVER_CLUSTER;
1049+
1050+
/**
1051+
* The constant META_PREFIX
1052+
*/
1053+
String META_PREFIX = SEATA_FILE_ROOT_CONFIG + FILE_CONFIG_SPLIT_CHAR + FILE_ROOT_REGISTRY + FILE_CONFIG_SPLIT_CHAR + "metadata.";
10141054
}
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
package org.apache.seata.namingserver.constants;
17+
package org.apache.seata.common;
1818

1919
public interface NamingServerConstants {
2020
/**
@@ -46,4 +46,10 @@ public interface NamingServerConstants {
4646
* The constant IP_PORT_SPLIT_CHAR
4747
*/
4848
String IP_PORT_SPLIT_CHAR = ":";
49+
50+
/**
51+
* The constant DEFAULT_VGROUP_MAPPING
52+
*/
53+
String DEFAULT_VGROUP_MAPPING = "vgroup_table";
54+
4955
}

common/src/main/java/org/apache/seata/common/exception/ErrorCode.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,18 @@ public enum ErrorCode {
2929
/**
3030
* 0100 ~ 0199 Security related errors
3131
*/
32-
ERR_DESERIALIZATION_SECURITY(ErrorType.Security, 0156);
32+
ERR_DESERIALIZATION_SECURITY(ErrorType.Security, 0156),
3333

3434
/**
3535
* The error code of the transaction exception.
3636
*/
37+
38+
39+
/**
40+
* The error code of the sql exception
41+
*/
42+
ERROR_SQL(ErrorType.Datasource, 0201);
43+
3744
private int code;
3845
private ErrorType type;
3946

@@ -82,10 +89,6 @@ enum ErrorType {
8289
* Network error type.
8390
*/
8491
Network,
85-
/**
86-
* Security related error type.
87-
*/
88-
Security,
8992
/**
9093
* Tm error type.
9194
*/
@@ -102,6 +105,10 @@ enum ErrorType {
102105
* Datasource error type.
103106
*/
104107
Datasource,
108+
/**
109+
* Security error type.
110+
*/
111+
Security,
105112
/**
106113
* Other error type.
107114
*/

common/src/main/java/org/apache/seata/common/metadata/Cluster.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class Cluster {
2626
private String clusterType;
2727
private List<Unit> unitData = new ArrayList<>();
2828

29+
2930
public Cluster() {
3031
}
3132

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
package org.apache.seata.core.store;
18+
19+
public class MappingDO {
20+
private String namespace;
21+
22+
private String cluster;
23+
24+
private String unit;
25+
26+
private String vGroup;
27+
28+
29+
public String getNamespace() {
30+
return namespace;
31+
}
32+
33+
public void setNamespace(String namespace) {
34+
this.namespace = namespace;
35+
}
36+
37+
public String getCluster() {
38+
return cluster;
39+
}
40+
41+
public void setCluster(String cluster) {
42+
this.cluster = cluster;
43+
}
44+
45+
public String getUnit() {
46+
return unit;
47+
}
48+
49+
public void setUnit(String unit) {
50+
this.unit = unit;
51+
}
52+
53+
public String getVGroup() {
54+
return vGroup;
55+
}
56+
57+
public void setVGroup(String vGroup) {
58+
this.vGroup = vGroup;
59+
}
60+
61+
}

namingserver/src/main/java/org/apache/seata/namingserver/manager/NamingManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.apache.seata.common.metadata.namingserver.Unit;
2727
import org.apache.seata.common.result.Result;
2828
import org.apache.seata.common.util.HttpClientUtil;
29-
import org.apache.seata.namingserver.constants.NamingServerConstants;
29+
import org.apache.seata.common.NamingServerConstants;
3030
import org.apache.seata.namingserver.listener.ClusterChangeEvent;
3131
import org.apache.seata.namingserver.entity.pojo.ClusterData;
3232
import org.apache.seata.namingserver.entity.vo.monitor.ClusterVO;
@@ -55,7 +55,7 @@
5555
import javax.annotation.PostConstruct;
5656

5757

58-
import static org.apache.seata.namingserver.constants.NamingServerConstants.CONSTANT_GROUP;
58+
import static org.apache.seata.common.NamingServerConstants.CONSTANT_GROUP;
5959

6060
@Component
6161
public class NamingManager {

namingserver/src/test/java/org/apache/seata/namingserver/NamingControllerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import java.util.UUID;
3636

3737

38-
import static org.apache.seata.namingserver.constants.NamingServerConstants.CONSTANT_GROUP;
38+
import static org.apache.seata.common.NamingServerConstants.CONSTANT_GROUP;
3939
import static org.junit.jupiter.api.Assertions.*;
4040

4141

script/server/db/dm.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,12 @@ INSERT INTO "SEATA"."DISTRIBUTED_LOCK" ("LOCK_KEY", "LOCK_VALUE", "EXPIRE") VALU
9191
INSERT INTO "SEATA"."DISTRIBUTED_LOCK" ("LOCK_KEY", "LOCK_VALUE", "EXPIRE") VALUES ('RetryCommitting', ' ', 0);
9292
INSERT INTO "SEATA"."DISTRIBUTED_LOCK" ("LOCK_KEY", "LOCK_VALUE", "EXPIRE") VALUES ('RetryRollbacking', ' ', 0);
9393
INSERT INTO "SEATA"."DISTRIBUTED_LOCK" ("LOCK_KEY", "LOCK_VALUE", "EXPIRE") VALUES ('TxTimeoutCheck', ' ', 0);
94+
95+
96+
CREATE TABLE "SEATA"."VGROUP_TABLE"
97+
(
98+
`VGROUP` VARCHAR2(255),
99+
`NAMESPACE` VARCHAR2(255),
100+
`CLUSTER` VARCHAR2(255),
101+
PRIMARY KEY (`VGROUP`)
102+
);

script/server/db/mysql.sql

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,14 @@ CREATE TABLE IF NOT EXISTS `distributed_lock`
8787
INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('AsyncCommitting', ' ', 0);
8888
INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('RetryCommitting', ' ', 0);
8989
INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('RetryRollbacking', ' ', 0);
90-
INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('TxTimeoutCheck', ' ', 0);
90+
INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('TxTimeoutCheck', ' ', 0);
91+
92+
93+
CREATE TABLE IF NOT EXISTS `vgroup_table`
94+
(
95+
`vGroup` VARCHAR(255),
96+
`namespace` VARCHAR(255),
97+
`cluster` VARCHAR(255),
98+
primary key (`vGroup`)
99+
) ENGINE = InnoDB
100+
DEFAULT CHARSET = utf8mb4;

script/server/db/oracle.sql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,10 @@ INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('AsyncCommit
8787
INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('RetryCommitting', ' ', 0);
8888
INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('RetryRollbacking', ' ', 0);
8989
INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('TxTimeoutCheck', ' ', 0);
90+
91+
CREATE TABLE vgroup_table
92+
(
93+
vGroup VARCHAR2(255) PRIMARY KEY,
94+
namespace VARCHAR2(255),
95+
cluster VARCHAR2(255)
96+
);

script/server/db/postgresql.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,11 @@ INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('AsyncCommit
8787
INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('RetryCommitting', ' ', 0);
8888
INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('RetryRollbacking', ' ', 0);
8989
INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('TxTimeoutCheck', ' ', 0);
90+
91+
CREATE TABLE IF NOT EXISTS vgroup_table
92+
(
93+
vGroup VARCHAR(255),
94+
namespace VARCHAR(255),
95+
cluster VARCHAR(255),
96+
PRIMARY KEY (vGroup)
97+
);

script/server/db/sqlserver.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,12 @@ INSERT INTO [distributed_lock] (lock_key, lock_value, expire) VALUES ('RetryComm
117117
INSERT INTO [distributed_lock] (lock_key, lock_value, expire) VALUES ('RetryRollbacking', ' ', 0);
118118
INSERT INTO [distributed_lock] (lock_key, lock_value, expire) VALUES ('TxTimeoutCheck', ' ', 0);
119119
INSERT INTO [distributed_lock] (lock_key, lock_value, expire) VALUES ('UndologDelete', ' ', 0);
120+
121+
CREATE TABLE [vgroup_table]
122+
(
123+
[vGroup] nvarchar(255) NOT NULL,
124+
[namespace] nvarchar(255) NOT NULL,
125+
[cluster] nvarchar(255) NOT NULL,
126+
PRIMARY KEY CLUSTERED ([vGroup])
127+
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
128+
)

server/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,12 @@
282282
<groupId>org.apache.tomcat.embed</groupId>
283283
<artifactId>tomcat-embed-core</artifactId>
284284
</dependency>
285+
286+
<dependency>
287+
<groupId>org.codehaus.jackson</groupId>
288+
<artifactId>jackson-mapper-asl</artifactId>
289+
<version>${jackson-mapper.version}</version>
290+
</dependency>
285291
</dependencies>
286292

287293
<build>

0 commit comments

Comments
 (0)