-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6494 from alibaba/develop
Upgrade to 2.0.3
- Loading branch information
Showing
415 changed files
with
14,183 additions
and
2,686 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# This workflow will build a Java project with Maven | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven | ||
|
||
name: Continuous Integration | ||
|
||
on: | ||
push: | ||
branches: [ master, develop, v1.x-develop, v1.X ] | ||
pull_request: | ||
branches: [ develop, v1.x-develop ] | ||
|
||
jobs: | ||
unix: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
java: [8] | ||
steps: | ||
- name: Cache Maven Repos | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: | | ||
${{ runner.os }}-maven- | ||
- uses: actions/checkout@v2 | ||
- name: Set up JDK ${{ matrix.java }} | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: ${{ matrix.java }} | ||
- name: Check with Maven | ||
run: mvn -B clean package apache-rat:check findbugs:findbugs -Dmaven.test.skip=true | ||
- name: Build with Maven | ||
run: mvn -Prelease-nacos -Dmaven.test.skip=true clean install -U | ||
- name: Test With Maven | ||
run: mvn -Prelease-nacos clean test -DforkCount=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# This workflow will build a Java project with Maven | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven | ||
|
||
name: Integration Test | ||
|
||
on: | ||
push: | ||
branches: [ master, develop, v1.x-develop, v1.X ] | ||
pull_request: | ||
branches: [ develop, v1.x-develop ] | ||
|
||
jobs: | ||
unix: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
java: [8, 11] | ||
steps: | ||
- name: Cache Maven Repos | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: | | ||
${{ runner.os }}-maven- | ||
- uses: actions/checkout@v2 | ||
- name: Set up JDK ${{ matrix.java }} | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: ${{ matrix.java }} | ||
distribution: 'adopt' | ||
architecture: x64 | ||
- name: Test Config | ||
run: mvn clean package -Pcit-test | ||
- name: Clean Env | ||
run: mvn clean -Premove-test-data | ||
- name: Test Naming | ||
run: mvn clean package -Pnit-test | ||
- name: Clean Env | ||
run: mvn clean -Premove-test-data | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
151 changes: 151 additions & 0 deletions
151
api/src/main/java/com/alibaba/nacos/api/naming/pojo/builder/InstanceBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
/* | ||
* Copyright 1999-2020 Alibaba Group Holding Ltd. | ||
* | ||
* Licensed 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 com.alibaba.nacos.api.naming.pojo.builder; | ||
|
||
import com.alibaba.nacos.api.naming.pojo.Instance; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
/** | ||
* Builder for {@link Instance}. | ||
* | ||
* @author xiweng.yy | ||
*/ | ||
public class InstanceBuilder { | ||
|
||
private String instanceId; | ||
|
||
private String ip; | ||
|
||
private Integer port; | ||
|
||
private Double weight; | ||
|
||
private Boolean healthy; | ||
|
||
private Boolean enabled; | ||
|
||
private Boolean ephemeral; | ||
|
||
private String clusterName; | ||
|
||
private String serviceName; | ||
|
||
private Map<String, String> metadata = new HashMap<>(); | ||
|
||
private InstanceBuilder() { | ||
} | ||
|
||
public InstanceBuilder setInstanceId(String instanceId) { | ||
this.instanceId = instanceId; | ||
return this; | ||
} | ||
|
||
public InstanceBuilder setIp(String ip) { | ||
this.ip = ip; | ||
return this; | ||
} | ||
|
||
public InstanceBuilder setPort(Integer port) { | ||
this.port = port; | ||
return this; | ||
} | ||
|
||
public InstanceBuilder setWeight(Double weight) { | ||
this.weight = weight; | ||
return this; | ||
} | ||
|
||
public InstanceBuilder setHealthy(Boolean healthy) { | ||
this.healthy = healthy; | ||
return this; | ||
} | ||
|
||
public InstanceBuilder setEnabled(Boolean enabled) { | ||
this.enabled = enabled; | ||
return this; | ||
} | ||
|
||
public InstanceBuilder setEphemeral(Boolean ephemeral) { | ||
this.ephemeral = ephemeral; | ||
return this; | ||
} | ||
|
||
public InstanceBuilder setClusterName(String clusterName) { | ||
this.clusterName = clusterName; | ||
return this; | ||
} | ||
|
||
public InstanceBuilder setServiceName(String serviceName) { | ||
this.serviceName = serviceName; | ||
return this; | ||
} | ||
|
||
public InstanceBuilder setMetadata(Map<String, String> metadata) { | ||
this.metadata = metadata; | ||
return this; | ||
} | ||
|
||
public InstanceBuilder addMetadata(String metaKey, String metaValue) { | ||
this.metadata.put(metaKey, metaValue); | ||
return this; | ||
} | ||
|
||
/** | ||
* Build a new {@link Instance}. | ||
* | ||
* @return new instance | ||
*/ | ||
public Instance build() { | ||
Instance result = new Instance(); | ||
if (!Objects.isNull(instanceId)) { | ||
result.setInstanceId(instanceId); | ||
} | ||
if (!Objects.isNull(ip)) { | ||
result.setIp(ip); | ||
} | ||
if (!Objects.isNull(port)) { | ||
result.setPort(port); | ||
} | ||
if (!Objects.isNull(weight)) { | ||
result.setWeight(weight); | ||
} | ||
if (!Objects.isNull(healthy)) { | ||
result.setHealthy(healthy); | ||
} | ||
if (!Objects.isNull(enabled)) { | ||
result.setEnabled(enabled); | ||
} | ||
if (!Objects.isNull(ephemeral)) { | ||
result.setEphemeral(ephemeral); | ||
} | ||
if (!Objects.isNull(clusterName)) { | ||
result.setClusterName(clusterName); | ||
} | ||
if (!Objects.isNull(serviceName)) { | ||
result.setServiceName(serviceName); | ||
} | ||
result.setMetadata(metadata); | ||
return result; | ||
} | ||
|
||
public static InstanceBuilder newBuilder() { | ||
return new InstanceBuilder(); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
api/src/main/java/com/alibaba/nacos/api/naming/selector/AbstractCmdbSelector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright 1999-2021 Alibaba Group Holding Ltd. | ||
* | ||
* Licensed 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 com.alibaba.nacos.api.naming.selector; | ||
|
||
import com.alibaba.nacos.api.naming.pojo.Instance; | ||
import com.alibaba.nacos.api.naming.selector.context.CmdbContext; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* {@link AbstractCmdbSelector} will provide one default implement of {@link Selector}, users can implement it to use the {@link CmdbContext}. | ||
* And return the result as default subclass of {@link Instance}. | ||
* | ||
* @author chenglu | ||
* @date 2021-07-09 21:29 | ||
*/ | ||
public abstract class AbstractCmdbSelector<T extends Instance> implements Selector<List<T>, CmdbContext<T>, String> { | ||
|
||
private static final String DEFAULT_CONTEXT_TYPE = "CMDB"; | ||
|
||
@Override | ||
public List<T> select(CmdbContext<T> context) { | ||
return doSelect(context); | ||
} | ||
|
||
/** | ||
* The real select implement by subclass. | ||
* | ||
* @param context selector context {@link CmdbContext}. | ||
* @return the select result. | ||
*/ | ||
protected abstract List<T> doSelect(CmdbContext<T> context); | ||
|
||
@Override | ||
public String getContextType() { | ||
return DEFAULT_CONTEXT_TYPE; | ||
} | ||
} |
Oops, something went wrong.