Skip to content

Commit

Permalink
Merge pull request alibaba#4696 from alibaba/develop
Browse files Browse the repository at this point in the history
Upgrade to 1.4.1
  • Loading branch information
KomachiSion authored Jan 14, 2021
2 parents 023f50c + 67eb369 commit 1d88d5d
Show file tree
Hide file tree
Showing 577 changed files with 5,928 additions and 7,629 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ derby.log
work
test/logs
derby.log
yarn.lock
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ before_install:

script:
- mvn -B clean package apache-rat:check findbugs:findbugs -Dmaven.test.skip=true
- 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 -Premove-test-data
- mvn clean package -Pit-test
- mvn clean -Premove-test-data
after_success:
- mvn clean package -Pit-test
- mvn sonar:sonar -Psonar-apache
2 changes: 1 addition & 1 deletion address/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<parent>
<artifactId>nacos-all</artifactId>
<groupId>com.alibaba.nacos</groupId>
<version>1.4.0</version>
<version>1.4.1</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +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.naming.core.Instance;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -85,14 +86,11 @@ public List<Instance> generateInstancesByIps(String serviceName, String rawProdu
}

private String[] generateIpAndPort(String ip) {

int index = ip.indexOf(AddressServerConstants.IP_PORT_SEPARATOR);
if (index != -1) {

return new String[] {ip.substring(0, index), ip.substring(index + 1)};
String[] result = IPUtil.splitIPPortStr(ip);
if (result.length != IPUtil.SPLIT_IP_PORT_RESULT_LENGTH) {
return new String[] {result[0], String.valueOf(AddressServerConstants.DEFAULT_SERVER_PORT)};
}

return new String[] {ip, String.valueOf(AddressServerConstants.DEFAULT_SERVER_PORT)};
return result;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ public interface AddressServerConstants {
*/
String DEFAULT_PRODUCT = "nacos";

/**
* the separator between ip and port.
*/
String IP_PORT_SEPARATOR = ":";

/**
* the separator for service name between raw service name and group.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import com.alibaba.nacos.address.component.AddressServerManager;
import com.alibaba.nacos.address.constant.AddressServerConstants;
import com.alibaba.nacos.address.misc.Loggers;
import com.alibaba.nacos.address.util.AddressServerParamCheckUtil;
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.naming.core.Cluster;
import com.alibaba.nacos.naming.core.Instance;
import com.alibaba.nacos.naming.core.Service;
Expand Down Expand Up @@ -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 = AddressServerParamCheckUtil.checkIps(ipArray);
if (AddressServerParamCheckUtil.CHECK_OK.equals(checkResult)) {
String checkResult = IPUtil.checkIPs(ipArray);
if (IPUtil.checkOK(checkResult)) {
List<Instance> instanceList = addressServerGeneratorManager
.generateInstancesByIps(serviceName, rawProductName, clusterName, ipArray);
for (Instance instance : instanceList) {
Expand Down Expand Up @@ -143,8 +143,8 @@ public ResponseEntity deleteCluster(@RequestParam(required = false) String produ
} else {
// delete specified ip list
String[] ipArray = addressServerManager.splitIps(ips);
String checkResult = AddressServerParamCheckUtil.checkIps(ipArray);
if (AddressServerParamCheckUtil.CHECK_OK.equals(checkResult)) {
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,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@

package com.alibaba.nacos.address;

import com.alibaba.nacos.address.util.AddressServerParamCheckUtil;
import com.alibaba.nacos.common.utils.IPUtil;
import org.junit.Test;

public class ParamCheckUtilTests {

@Test
public void checkIps() {
public void checkIPs() {
String[] ips = {"127.0.0.1"};
System.out.println(AddressServerParamCheckUtil.checkIps(ips));
System.out.println(IPUtil.checkIPs(ips));

String[] illlegalIps = {"127.100.19", "127.0.0.1"};
System.err.println(AddressServerParamCheckUtil.checkIps(illlegalIps));
System.err.println(IPUtil.checkIPs(illlegalIps));
}
}
6 changes: 1 addition & 5 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<parent>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-all</artifactId>
<version>1.4.0</version>
<version>1.4.1</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -55,10 +55,6 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
4 changes: 4 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 @@ -64,7 +64,11 @@ public class PropertyKeyConst {
public static final String NAMING_CLIENT_BEAT_THREAD_COUNT = "namingClientBeatThreadCount";

public static final String NAMING_POLLING_THREAD_COUNT = "namingPollingThreadCount";

public static final String NAMING_REQUEST_DOMAIN_RETRY_COUNT = "namingRequestDomainMaxRetryCount";

public static final String NAMING_PUSH_EMPTY_PROTECTION = "namingPushEmptyProtection";

/**
* Get the key value of some variable value from the system property.
*/
Expand Down
2 changes: 2 additions & 0 deletions api/src/main/java/com/alibaba/nacos/api/common/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,6 @@ public class Constants {

public static final String HTTP_PREFIX = "http";

public static final String ALL_PATTERN = "*";

}
12 changes: 12 additions & 0 deletions api/src/main/java/com/alibaba/nacos/api/config/ConfigService.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ String getConfigAndSignListener(String dataId, String group, long timeoutMs, Lis
*/
boolean publishConfig(String dataId, String group, String content) throws NacosException;

/**
* Publish config.
*
* @param dataId dataId
* @param group group
* @param content content
* @param type config type {@link ConfigType}
* @return Whether publish
* @throws NacosException NacosException
*/
boolean publishConfig(String dataId, String group, String content, String type) throws NacosException;

/**
* Remove config.
*
Expand Down
31 changes: 30 additions & 1 deletion api/src/main/java/com/alibaba/nacos/api/config/ConfigType.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package com.alibaba.nacos.api.config;

import com.alibaba.nacos.api.utils.StringUtils;

/**
* Config data type.
*
Expand Down Expand Up @@ -51,7 +53,12 @@ public enum ConfigType {
/**
* config type is "yaml".
*/
YAML("yaml");
YAML("yaml"),

/**
* not a real type.
*/
UNSET("unset");

String type;

Expand All @@ -62,4 +69,26 @@ public enum ConfigType {
public String getType() {
return type;
}

public static ConfigType getDefaultType() {
return TEXT;
}

/**
* check input type is valid.
*
* @param type config type
* @return it the type valid
*/
public static Boolean isValidType(String type) {
if (StringUtils.isBlank(type)) {
return false;
}
for (ConfigType value : values()) {
if (value.type.equals(type)) {
return true;
}
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
/**
* Nacos Config type.
*
* @return "properties"
* @return default value is {@link ConfigType#UNSET}
*/
ConfigType type() default ConfigType.PROPERTIES;
ConfigType type() default ConfigType.UNSET;

/**
* Specify {@link NacosConfigConverter Nacos configuraion convertor} class to convert target type instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@
/**
* config style.
*
* @return default value is {@link ConfigType#PROPERTIES}
* @return default value is {@link ConfigType#UNSET}
*/
ConfigType type() default ConfigType.PROPERTIES;
ConfigType type() default ConfigType.UNSET;

/**
* It indicates the properties of current doBind bean is auto-refreshed when Nacos configuration is changed.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright 1999-2018 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.listener;

import java.util.concurrent.Executor;

/**
* Abstract event listener, to support handle event by user custom executor.
*
* @author horizonzy
* @since 1.4.1
*/
public abstract class AbstractEventListener implements EventListener {

/**
* Get executor for execute this receive.
*
* @return Executor
*/
public Executor getExecutor() {
return null;
}

}
Loading

0 comments on commit 1d88d5d

Please sign in to comment.