Skip to content

Commit

Permalink
Merge pull request #6494 from alibaba/develop
Browse files Browse the repository at this point in the history
Upgrade to 2.0.3
  • Loading branch information
KomachiSion authored Jul 28, 2021
2 parents 1fac5c8 + fab5ae5 commit 5a4d433
Show file tree
Hide file tree
Showing 415 changed files with 14,183 additions and 2,686 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
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
42 changes: 42 additions & 0 deletions .github/workflows/it.yml
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

23 changes: 0 additions & 23 deletions .github/workflows/maven.yml

This file was deleted.

4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (properties) the power, direct or indirect, to cause the
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
Expand Down Expand Up @@ -198,4 +198,4 @@
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.
limitations under the License.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Contributors are welcomed to join Nacos project. Please check [CONTRIBUTING](./C
* commits-nacos@googlegroups.com: Commits notice, very high frequency.
* Join us from DingDing(Group 1: 21708933(full), Group 2: 30438813).

![Nacos](https://img.alicdn.com/tfs/TB1TBKEzpP7gK0jSZFjXXc5aXXa-199-220.png)
![Nacos](https://nacos.io/img/nacos_dingding.jpg)

## Download

Expand Down Expand Up @@ -175,5 +175,6 @@ These are only part of the companies using Nacos, for reference only. If you are
![天阙](https://img.alicdn.com/tfs/TB1rNq4EwHqK1RjSZFgXXa7JXXa-200-200.jpg)
![联合永道](https://img.alicdn.com/tfs/TB1CRAxDxYaK1RjSZFnXXa80pXa-190-190.jpg)
![明源云](https://img.alicdn.com/tfs/TB1.q14ErrpK1RjSZTEXXcWAVXa-219-219.jpg)
![三诺生物](http://www.sinocare.com/public/static/images/logored6000321.png)


Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import com.alibaba.nacos.api.common.Constants;
import com.alibaba.nacos.common.utils.InternetAddressUtil;
import com.alibaba.nacos.naming.core.Instance;
import org.apache.commons.lang3.StringUtils;
import com.alibaba.nacos.common.utils.StringUtils;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
Expand Down Expand Up @@ -103,8 +103,8 @@ public String generateResponseIps(List<Instance> instanceList) {

StringBuilder ips = new StringBuilder();
instanceList.forEach(instance -> {
ips.append(instance.getIp()).append(":").append(instance.getPort());
ips.append("\n");
ips.append(instance.getIp()).append(':').append(instance.getPort());
ips.append('\n');
});

return ips.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import com.alibaba.nacos.address.constant.AddressServerConstants;
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
import org.apache.commons.lang3.StringUtils;
import com.alibaba.nacos.common.utils.StringUtils;
import org.springframework.stereotype.Component;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.alibaba.nacos.naming.core.Instance;
import com.alibaba.nacos.naming.core.Service;
import com.alibaba.nacos.naming.core.ServiceManager;
import org.apache.commons.lang3.StringUtils;
import com.alibaba.nacos.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ private static String doExecute(String reqUrl, Map<String, String> paramMap, Str
if (paramMap != null) {
for (Map.Entry<String, String> element : paramMap.entrySet()) {
params.append(element.getKey());
params.append("=");
params.append('=');
params.append(URLEncoder.encode(element.getValue(), REQUEST_ENCODING));
params.append("&");
params.append('&');
}

if (params.length() > 0) {
Expand Down
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();
}
}
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;
}
}
Loading

0 comments on commit 5a4d433

Please sign in to comment.