Skip to content

feature: init Namingserver #6537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 32 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
50c77dc
add signature
ggbocoder Jan 2, 2024
b36f5b2
Merge remote-tracking branch 'upstream/2.x' into 2.x
ggbocoder Jan 20, 2024
e15537d
Merge remote-tracking branch 'upstream/2.x' into 2.x
ggbocoder Jan 25, 2024
85398ec
Merge remote-tracking branch 'upstream/2.x' into 2.x
ggbocoder Jan 31, 2024
e049125
Merge remote-tracking branch 'upstream/2.x' into 2.x
ggbocoder Mar 7, 2024
2939f59
Merge remote-tracking branch 'upstream/2.x' into 2.x
ggbocoder May 12, 2024
6c96366
init namingserver
ggbocoder May 12, 2024
d022017
fix ci
ggbocoder May 13, 2024
de90149
fix ci
ggbocoder May 13, 2024
95c935f
remove auth infos
ggbocoder Jun 25, 2024
726f7f8
Update namingserver/pom.xml
ggbocoder Jun 25, 2024
eac2ade
Update namingserver/pom.xml
ggbocoder Jun 25, 2024
4941f57
Update namingserver/pom.xml
ggbocoder Jun 25, 2024
f553880
Update namingserver/pom.xml
ggbocoder Jun 25, 2024
7aec384
fix
ggbocoder Jun 25, 2024
33ab214
Merge remote-tracking branch 'origin/namingserver' into namingserver
ggbocoder Jun 25, 2024
7caf526
change to jackson
ggbocoder Jun 26, 2024
e52747a
fix
ggbocoder Jun 27, 2024
311bb12
replace with constants
ggbocoder Jun 28, 2024
1ef041b
simplify controller
ggbocoder Jun 28, 2024
1359144
reformat code
ggbocoder Jun 28, 2024
572932c
opt
ggbocoder Jun 28, 2024
7807b32
Update namingserver/pom.xml
ggbocoder Jun 28, 2024
8760059
fix
ggbocoder Jun 30, 2024
440a53b
Merge remote-tracking branch 'origin/namingserver' into namingserver
ggbocoder Jul 2, 2024
50f8703
register
ggbocoder Jul 4, 2024
3eb13dc
Merge remote-tracking branch 'upstream/2.x' into namingserver
ggbocoder Jul 5, 2024
8c11f7c
Merge remote-tracking branch 'origin/namingserver' into namingserver
ggbocoder Jul 5, 2024
9b809ef
update
ggbocoder Jul 5, 2024
16b705c
update
ggbocoder Jul 5, 2024
efd93d7
Update changes/zh-cn/2.x.md
funky-eyes Jul 5, 2024
577d66f
Update changes/en-us/2.x.md
funky-eyes Jul 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions changes/en-us/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Add changes here for all PR submitted to the 2.x branch.

### feature:
- [[#6226](https://github.com/apache/incubator-seata/pull/6226)] multi-version seata protocol support
- [[#6537](https://github.com/apache/incubator-seata/pull/6537)] support Namingserver

### bugfix:
- [[#6592](https://github.com/apache/incubator-seata/pull/6592)] fix @Async annotation not working in ClusterWatcherManager
Expand All @@ -12,7 +13,6 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#6626](https://github.com/apache/incubator-seata/pull/6626)] fix hsf ConsumerModel convert error
- [[#6642](https://github.com/apache/incubator-seata/pull/6642)] codecov token not found


### optimize:
- [[#6499](https://github.com/apache/incubator-seata/pull/6499)] split the task thread pool for committing and rollbacking statuses
- [[#6208](https://github.com/apache/incubator-seata/pull/6208)] optimize : load SeataSerializer by version
Expand Down Expand Up @@ -43,5 +43,6 @@ Thanks to these contributors for their code commits. Please report an unintended
- [funky-eyes](https://github.com/funky-eyes)
- [tanyaofei](https://github.com/tanyaofei)
- [wanghongzhou](https://github.com/wanghongzhou)
- [ggbocoder](https://github.com/ggbocoder)

Also, we receive many valuable issues, questions and advices from our community. Thanks for you all.
Also, we receive many valuable issues, questions and advices from our community. Thanks for you all.
5 changes: 3 additions & 2 deletions changes/zh-cn/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### feature:
- [[#6226](https://github.com/apache/incubator-seata/pull/6226)] 支持seata私有协议多版本兼容
- [[#6537](https://github.com/apache/incubator-seata/pull/6537)] 支持 Namingserver

### bugfix:
- [[#6592](https://github.com/apache/incubator-seata/pull/6592)] fix @Async注解ClusterWatcherManager中不生效的问题
Expand All @@ -13,7 +14,6 @@
- [[#6640](https://github.com/apache/incubator-seata/pull/6640)] 优化codecov相关配置
- [[#6642](https://github.com/apache/incubator-seata/pull/6642)] 修复codecov token找不到导致无法提交单测覆盖度报告


### optimize:
- [[#6499](https://github.com/apache/incubator-seata/pull/6499)] 拆分 committing 和 rollbacking 状态的任务线程池
- [[#6208](https://github.com/apache/incubator-seata/pull/6208)] 支持多版本的Seata序列化
Expand Down Expand Up @@ -43,6 +43,7 @@
- [funky-eyes](https://github.com/funky-eyes)
- [tanyaofei](https://github.com/tanyaofei)
- [wanghongzhou](https://github.com/wanghongzhou)
- [ggbocoder](https://github.com/ggbocoder)


同时,我们收到了社区反馈的很多有价值的issue和建议,非常感谢大家。
同时,我们收到了社区反馈的很多有价值的issue和建议,非常感谢大家。
25 changes: 25 additions & 0 deletions common/src/main/java/org/apache/seata/common/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,29 @@ public interface Constants {
* The constant JACKSON_JSON_TEXT_PREFIX
*/
String JACKSON_JSON_TEXT_PREFIX = "{\"@class\":";

/**
* The constant HTTP_PREFIX
*/
String HTTP_PREFIX = "http://";

/**
* The constant HTTP_ADD_GROUP_SUFFIX
*/
String HTTP_ADD_GROUP_SUFFIX = "/naming/v1/addVGroup?";

/**
* The constant CONSTANT_UNIT
*/
String CONSTANT_UNIT = "unit";

/**
* The constant CONSTANT_GROUP
*/
String CONSTANT_GROUP = "vGroup";

/**
* The constant HTTP_REMOVE_GROUP_SUFFIX
*/
String HTTP_REMOVE_GROUP_SUFFIX = "/naming/v1/removeVGroup?";
}
59 changes: 59 additions & 0 deletions common/src/main/java/org/apache/seata/common/metadata/Cluster.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* 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.
*/
package org.apache.seata.common.metadata;

import org.apache.seata.common.metadata.namingserver.Unit;

import java.util.ArrayList;
import java.util.List;

public class Cluster {
private String clusterName;
private String clusterType;
private List<Unit> unitData = new ArrayList<>();

public Cluster() {
}

public String getClusterName() {
return clusterName;
}

public void setClusterName(String clusterName) {
this.clusterName = clusterName;
}

public String getClusterType() {
return clusterType;
}

public void setClusterType(String clusterType) {
this.clusterType = clusterType;
}

public List<Unit> getUnitData() {
return unitData;
}

public void setUnitData(List<Unit> unitData) {
this.unitData = unitData;
}


}


Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ public Endpoint(String host, int port) {
this.port = port;
}

public Endpoint(String host, int port, String protocol) {
this.host = host;
this.port = port;
this.protocol = protocol;
}

public String getHost() {
return host;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
/*
* 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.
*/
package org.apache.seata.common.metadata.namingserver;



import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.seata.common.metadata.ClusterRole;
import org.apache.seata.common.metadata.Node;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

import static org.apache.seata.common.util.CollectionUtils.mapToJsonString;


public class Instance {
private String namespace;
private String clusterName;
private String unit;
private Node.Endpoint controlEndpoint = new Node.Endpoint();
private Node.Endpoint transactionEndpoint = new Node.Endpoint();
private double weight = 1.0;
private boolean healthy = true;
private long term;
private ClusterRole role = ClusterRole.MEMBER;
private Map<String, Object> metadata = new HashMap<>();


private Instance() {
}

public static Instance getInstance() {
return SingletonHolder.SERVER_INSTANCE;
}


public String getNamespace() {
return namespace;
}

public void setNamespace(String namespace) {
this.namespace = namespace;
}

public String getClusterName() {
return clusterName;
}

public void setClusterName(String clusterName) {
this.clusterName = clusterName;
}

public String getUnit() {
return unit;
}

public void setUnit(String unit) {
this.unit = unit;
}

public ClusterRole getRole() {
return role;
}

public void setRole(ClusterRole role) {
this.role = role;
}

public Node.Endpoint getControlEndpoint() {
return controlEndpoint;
}

public void setControlEndpoint(Node.Endpoint controlEndpoint) {
this.controlEndpoint = controlEndpoint;
}

public Node.Endpoint getTransactionEndpoint() {
return transactionEndpoint;
}

public void setTransactionEndpoint(Node.Endpoint transactionEndpoint) {
this.transactionEndpoint = transactionEndpoint;
}

public double getWeight() {
return weight;
}

public void setWeight(double weight) {
this.weight = weight;
}

public boolean isHealthy() {
return healthy;
}

public void setHealthy(boolean healthy) {
this.healthy = healthy;
}

public long getTerm() {
return term;
}


public void setTerm(long term) {
this.term = term;
}

public void addMetadata(String key, Object value) {
this.metadata.put(key, value);
}

public void setMetadata(Map<String, Object> metadata) {
this.metadata = metadata;
}

@Override
public int hashCode() {
return Objects.hash(controlEndpoint, transactionEndpoint);
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Instance instance = (Instance) o;
return Objects.equals(controlEndpoint, instance.controlEndpoint) && Objects.equals(transactionEndpoint, instance.transactionEndpoint);
}


// Recursively convert metadata to JSON
public String toJsonString() {
ObjectMapper objectMapper = new ObjectMapper();
try {
return objectMapper.writeValueAsString(this);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}


public Map<String, String> toMap() {
Map<String, String> resultMap = new HashMap<>();


resultMap.put("namespace", namespace);
resultMap.put("clusterName", clusterName);
resultMap.put("unit", unit);
resultMap.put("controlEndpoint", controlEndpoint.toString());
resultMap.put("transactionEndpoint", transactionEndpoint.toString());
resultMap.put("weight", String.valueOf(weight));
resultMap.put("healthy", String.valueOf(healthy));
resultMap.put("term", String.valueOf(term));
resultMap.put("metadata", mapToJsonString(metadata));

return resultMap;
}

private static class SingletonHolder {
private static final Instance SERVER_INSTANCE = new Instance();
}


}

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* 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.
*/
package org.apache.seata.common.metadata.namingserver;

import org.apache.seata.common.metadata.Cluster;

import java.util.List;

public class MetaResponse {
private List<Cluster> clusterList;
private long term;

public MetaResponse() {
}

public MetaResponse(List<Cluster> clusterList, long term) {
this.clusterList = clusterList;
this.term = term;
}

public List<Cluster> getClusterList() {
return clusterList;
}

public void setClusterList(List<Cluster> clusterList) {
this.clusterList = clusterList;
}

public long getTerm() {
return term;
}

public void setTerm(long term) {
this.term = term;
}
}
Loading
Loading