Skip to content

Commit

Permalink
Merge pull request alibaba#6052 from alibaba/develop
Browse files Browse the repository at this point in the history
Upgrade to 2.0.2
  • Loading branch information
KomachiSion authored Jun 11, 2021
2 parents 11be620 + 70f7216 commit 1fac5c8
Show file tree
Hide file tree
Showing 958 changed files with 70,293 additions and 10,232 deletions.
16 changes: 0 additions & 16 deletions .editorconfig

This file was deleted.

4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ script:
- mvn clean -Premove-test-data
- mvn -Prelease-nacos -Dmaven.test.skip=true clean install -U
- mvn clean -Premove-test-data
- mvn clean install -Pcit-test
- mvn clean package -Pcit-test
- mvn clean -Premove-test-data
- mvn clean package -Pit-test
- mvn clean package -Pnit-test
- mvn clean -Premove-test-data
after_success:
- mvn clean package -Pit-test
Expand Down
50 changes: 50 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,53 @@ under the License.
Also, please refer to each LICENSE.<component>.txt file, which is located in
the 'license' directory of the distribution file, for the license terms of the
components that this product depends on.


------
com.alibaba.nacos.common.utils.InetAddressValidator.java in this product is
copied from com.dynatrace.openkit.core.util.InetAddressValidator.java of openkit-java project.
https://github.com/Dynatrace/openkit-java
openkit-java
======================

Copyright 2018-2021 Dynatrace LLC

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.

------
This product has a bundle Protocol Buffers��
Protocol Buffers
=======================
Protocol Buffers for Go with Gadgets

Copyright (c) 2013, The GoGo Authors. All rights reserved.
http://github.com/gogo/protobuf

------
This product has a bundle Istio��
Istio
=======================

Copyright 2018 Istio Authors

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.
15 changes: 0 additions & 15 deletions address/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>nacos-naming</artifactId>
Expand All @@ -51,16 +46,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public User login(Object request) throws AccessException {
return result;
}

@Override
public User loginRemote(Object request) throws AccessException {
return null;
}

@Override
public void auth(Permission permission, User user) throws AccessException {
}
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.api.common.Constants;
import com.alibaba.nacos.common.utils.IPUtil;
import com.alibaba.nacos.common.utils.InternetAddressUtil;
import com.alibaba.nacos.naming.core.Instance;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -86,8 +86,8 @@ public List<Instance> generateInstancesByIps(String serviceName, String rawProdu
}

private String[] generateIpAndPort(String ip) {
String[] result = IPUtil.splitIPPortStr(ip);
if (result.length != IPUtil.SPLIT_IP_PORT_RESULT_LENGTH) {
String[] result = InternetAddressUtil.splitIPPortStr(ip);
if (result.length != InternetAddressUtil.SPLIT_IP_PORT_RESULT_LENGTH) {
return new String[] {result[0], String.valueOf(AddressServerConstants.DEFAULT_SERVER_PORT)};
}
return result;
Expand All @@ -103,7 +103,7 @@ public String generateResponseIps(List<Instance> instanceList) {

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

Expand All @@ -118,7 +118,7 @@ public String generateResponseIps(List<Instance> instanceList) {
*/
public String generateNacosServiceName(String rawServiceName) {

if (rawServiceName.indexOf(Constants.DEFAULT_GROUP) != -1) {
if (rawServiceName.contains(Constants.DEFAULT_GROUP)) {
return rawServiceName;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.alibaba.nacos.address.misc.Loggers;
import com.alibaba.nacos.api.common.Constants;
import com.alibaba.nacos.api.naming.pojo.healthcheck.AbstractHealthChecker;
import com.alibaba.nacos.common.utils.IPUtil;
import com.alibaba.nacos.common.utils.InternetAddressUtil;
import com.alibaba.nacos.naming.core.Cluster;
import com.alibaba.nacos.naming.core.Instance;
import com.alibaba.nacos.naming.core.Service;
Expand Down Expand Up @@ -66,7 +66,7 @@ public class AddressServerClusterController {
* @return result of create new cluster
*/
@RequestMapping(value = "", method = RequestMethod.POST)
public ResponseEntity postCluster(@RequestParam(required = false) String product,
public ResponseEntity<String> postCluster(@RequestParam(required = false) String product,
@RequestParam(required = false) String cluster, @RequestParam(name = "ips") String ips) {

//1. prepare the storage name for product and cluster
Expand All @@ -78,7 +78,7 @@ public ResponseEntity postCluster(@RequestParam(required = false) String product
String rawClusterName = addressServerManager.getRawClusterName(cluster);
Loggers.ADDRESS_LOGGER.info("put cluster node,the cluster name is " + cluster + "; the product name=" + product
+ "; the ip list=" + ips);
ResponseEntity responseEntity;
ResponseEntity<String> responseEntity;
try {
String serviceName = addressServerGeneratorManager.generateNacosServiceName(productName);

Expand All @@ -87,8 +87,8 @@ public ResponseEntity postCluster(@RequestParam(required = false) String product
clusterObj.setHealthChecker(new AbstractHealthChecker.None());
serviceManager.createServiceIfAbsent(Constants.DEFAULT_NAMESPACE_ID, serviceName, false, clusterObj);
String[] ipArray = addressServerManager.splitIps(ips);
String checkResult = IPUtil.checkIPs(ipArray);
if (IPUtil.checkOK(checkResult)) {
String checkResult = InternetAddressUtil.checkIPs(ipArray);
if (InternetAddressUtil.checkOK(checkResult)) {
List<Instance> instanceList = addressServerGeneratorManager
.generateInstancesByIps(serviceName, rawProductName, clusterName, ipArray);
for (Instance instance : instanceList) {
Expand Down Expand Up @@ -133,26 +133,22 @@ public ResponseEntity deleteCluster(@RequestParam(required = false) String produ
Service service = serviceManager.getService(Constants.DEFAULT_NAMESPACE_ID, serviceName);

if (service == null) {
responseEntity = ResponseEntity.status(HttpStatus.NOT_FOUND)
.body("product=" + rawProductName + " not found.");
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("product=" + rawProductName + " not found.");
}
if (StringUtils.isBlank(ips)) {
// delete all ips from the cluster
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("ips must not be empty.");
}
// delete specified ip list
String[] ipArray = addressServerManager.splitIps(ips);
String checkResult = InternetAddressUtil.checkIPs(ipArray);
if (InternetAddressUtil.checkOK(checkResult)) {
List<Instance> instanceList = addressServerGeneratorManager
.generateInstancesByIps(serviceName, rawProductName, clusterName, ipArray);
serviceManager.removeInstance(Constants.DEFAULT_NAMESPACE_ID, serviceName, false,
instanceList.toArray(new Instance[instanceList.size()]));
} else {

if (StringUtils.isBlank(ips)) {
// delete all ips from the cluster
responseEntity = ResponseEntity.status(HttpStatus.BAD_REQUEST).body("ips must not be empty.");
} else {
// delete specified ip list
String[] ipArray = addressServerManager.splitIps(ips);
String checkResult = IPUtil.checkIPs(ipArray);
if (IPUtil.checkOK(checkResult)) {
List<Instance> instanceList = addressServerGeneratorManager
.generateInstancesByIps(serviceName, rawProductName, clusterName, ipArray);
serviceManager.removeInstance(Constants.DEFAULT_NAMESPACE_ID, serviceName, false,
instanceList.toArray(new Instance[instanceList.size()]));
} else {
responseEntity = ResponseEntity.status(HttpStatus.BAD_REQUEST).body(checkResult);
}
}
responseEntity = ResponseEntity.status(HttpStatus.BAD_REQUEST).body(checkResult);
}
} catch (Exception e) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class ServerListController {
* @return result of get
*/
@RequestMapping(value = "/{product}/{cluster}", method = RequestMethod.GET)
public ResponseEntity getCluster(@PathVariable String product, @PathVariable String cluster) {
public ResponseEntity<String> getCluster(@PathVariable String product, @PathVariable String cluster) {

String productName = addressServerBuilderManager.generateProductName(product);
String serviceName = addressServerBuilderManager.generateNacosServiceName(productName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@

package com.alibaba.nacos.address;

import org.junit.Ignore;
import org.junit.Test;

import java.util.HashMap;

@Ignore
public class AddressServerControllerTests {

private static final String PRODUCT_NACOS = "nacos";
Expand Down
63 changes: 61 additions & 2 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,32 @@
<url>http://nacos.io</url>
<build>
<plugins>
<!-- reuse when you need to update grpc model -->
<!--<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.5.0</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:3.8.0:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.14.0:exe:${os.detected.classifier}</pluginArtifact>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>-->

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>6</source>
<target>6</target>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
Expand All @@ -55,6 +75,10 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -69,5 +93,40 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>

<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty-shaded</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-common-protos</artifactId>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>protoc-gen-grpc-java</artifactId>
<type>pom</type>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</dependency>

</dependencies>
</project>
2 changes: 2 additions & 0 deletions api/src/main/java/com/alibaba/nacos/api/PropertyKeyConst.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public class PropertyKeyConst {

public static final String NAMING_LOAD_CACHE_AT_START = "namingLoadCacheAtStart";

public static final String NAMING_CACHE_REGISTRY_DIR = "namingCacheRegistryDir";

public static final String NAMING_CLIENT_BEAT_THREAD_COUNT = "namingClientBeatThreadCount";

public static final String NAMING_POLLING_THREAD_COUNT = "namingPollingThreadCount";
Expand Down
Loading

0 comments on commit 1fac5c8

Please sign in to comment.