Skip to content

Commit

Permalink
Merge pull request alibaba#11 from alibaba/master
Browse files Browse the repository at this point in the history
pull latest code
  • Loading branch information
paderlol authored May 20, 2019
2 parents 795515e + 63c98e1 commit 0b0e1e2
Show file tree
Hide file tree
Showing 115 changed files with 1,749 additions and 610 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 1.0.0-RC4(Mar 22, 2019)
* [#923] Nacos 1.0.0 compatible with nacos-client 0.6.2
* [#938] Client beat processor task lost
* [#946] Change default server mode to AP



## 1.0.0-RC1(Mar 15, 2019)

* [#870] About Nacos's namespace and tenant design
Expand Down
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ Contributors are welcomed to join Nacos project. Please check [CONTRIBUTING](./C
* [email protected]: Nacos usage general discussion.
* [email protected]: Nacos developer discussion (APIs, feature design, etc).
* [email protected]: Commits notice, very high frequency.
* Join us from wechat. Welcome words: Nacos.
* Join us from DingDing.

![cwex](http://acm-public.oss-cn-hangzhou.aliyuncs.com/xuc.png)
![cwex](https://img.alicdn.com/tfs/TB1bpBlQmrqK1RjSZK9XXXyypXa-830-972.png_288x480q80.jpg)


## Who is using
Expand Down Expand Up @@ -143,6 +143,26 @@ These are only part of the companies using Nacos, for reference only. If you are
![云帐房](http://www.yunzhangfang.com/yzf-pc/img/logo.png)
![知氏教育](https://www.chyeth.com/622e88980a5d091eaa6449f82d48ca43.png)
![中化信息](http://www.sinochem.com/Portals/0/xinlogo.png)
![一点车](https://img.alicdn.com/tfs/TB1DXerNgDqK1RjSZSyXXaxEVXa-333-103.png)
![明传无线](https://img.alicdn.com/tfs/TB1VfOANgHqK1RjSZFPXXcwapXa-313-40.png)
![妙优车](https://img.alicdn.com/tfs/TB1lvCyNhTpK1RjSZFMXXbG_VXa-130-60.png)
![蜂巢](https://img.alicdn.com/tfs/TB1kY9qNgTqK1RjSZPhXXXfOFXa-120-50.png)
![华存数据](https://img.alicdn.com/tfs/TB1G.GBNbrpK1RjSZTEXXcWAVXa-234-65.png)
![数云](https://img.alicdn.com/tfs/TB1qsurNgDqK1RjSZSyXXaxEVXa-300-90.png)
![广通软件](https://img.alicdn.com/tfs/TB13aywNhTpK1RjSZR0XXbEwXXa-98-38.png)
![菜菜](https://img.alicdn.com/tfs/TB1xqmBNjTpK1RjSZKPXXa3UpXa-162-70.png)
![科蓝公司](https://img.alicdn.com/tfs/TB18DmINcfpK1RjSZFOXXa6nFXa-200-200.png)
![浩鲸](https://img.alicdn.com/tfs/TB15uqANXzqK1RjSZFoXXbfcXXa-188-86.png)
![未名天日语](https://img.alicdn.com/tfs/TB1mvmyNkvoK1RjSZPfXXXPKFXa-238-46.png)
![金联创](https://img.alicdn.com/tfs/TB1PSWsNmrqK1RjSZK9XXXyypXa-195-130.jpg)
![同窗链](https://img.alicdn.com/tfs/TB1k1qzNbvpK1RjSZFqXXcXUVXa-160-69.png)
![顺能](https://img.alicdn.com/tfs/TB1HdyvNmzqK1RjSZFLXXcn2XXa-143-143.jpg)
![百世快递](https://img.alicdn.com/tfs/TB1UdaGNgHqK1RjSZJnXXbNLpXa-277-62.png)
![汽车之家](https://img.alicdn.com/tfs/TB17OqENbrpK1RjSZTEXXcWAVXa-240-113.jpg)
![鲸打卡](https://img.alicdn.com/tfs/TB1q71ANkvoK1RjSZPfXXXPKFXa-257-104.png)
![时代光华](https://img.alicdn.com/tfs/TB1UzuyNhTpK1RjSZR0XXbEwXXa-201-86.jpg)
![康美](https://img.alicdn.com/tfs/TB19RCANgHqK1RjSZFPXXcwapXa-180-180.jpg)
![环球易购](https://img.alicdn.com/tfs/TB1iCGyNb2pK1RjSZFsXXaNlXXa-143-143.jpg)
![海格管家](https://img.alicdn.com/tfs/TB1FNq4EwHqK1RjSZFgXXa7JXXa-232-232.jpg)
![Nepxion](https://avatars0.githubusercontent.com/u/16344119?s=200&v=4)
![东莞最佳拍档](https://img.alicdn.com/tfs/TB11ugsDzTpK1RjSZKPXXa3UpXa-300-300.png)
Expand All @@ -152,3 +172,4 @@ These are only part of the companies using Nacos, for reference only. If you are
![联合永道](https://img.alicdn.com/tfs/TB1CRAxDxYaK1RjSZFnXXa80pXa-190-190.jpg)
![明源云](https://img.alicdn.com/tfs/TB1.q14ErrpK1RjSZTEXXcWAVXa-219-219.jpg)


2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<parent>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-all</artifactId>
<version>1.0.0-RC1</version>
<version>1.0.0</version>
</parent>

<modelVersion>4.0.0</modelVersion>
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 @@ -22,6 +22,8 @@
*/
public class PropertyKeyConst {

public final static String IS_USE_ENDPOINT_PARSING_RULE = "isUseEndpointParsingRule";

public final static String ENDPOINT = "endpoint";

public final static String ENDPOINT_PORT = "endpointPort";
Expand All @@ -32,6 +34,8 @@ public class PropertyKeyConst {

public final static String SECRET_KEY = "secretKey";

public final static String RAM_ROLE_NAME = "ramRoleName";

public final static String SERVER_ADDR = "serverAddr";

public final static String CONTEXT_PATH = "contextPath";
Expand Down
10 changes: 10 additions & 0 deletions api/src/main/java/com/alibaba/nacos/api/naming/NamingService.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@ public interface NamingService {
*/
void deregisterInstance(String serviceName, String groupName, String ip, int port, String clusterName) throws NacosException;

/**
* deregister instance with full instance information
*
* @param serviceName name of service
* @param groupName group of service
* @param instance instance information
* @throws NacosException
*/
void deregisterInstance(String serviceName, String groupName, Instance instance) throws NacosException;

/**
* get all instances of a service
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,30 @@
/*
* 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;

{
"editor.tabSize": 2,
"editor.formatOnSave": true,
"[javascript]": {
"editor.formatOnSave": true,
"editor.formatOnPaste": false
},
"[javascriptreact]": {
"editor.formatOnSave": true,
"editor.formatOnPaste": false
},
"[typescript]": {
"editor.formatOnSave": true,
"editor.formatOnPaste": false
},
"[typescriptreact]": {
"editor.formatOnSave": true,
"editor.formatOnPaste": false
},
"[html]": {
"editor.formatOnSave": false
}
/**
* Some keys of metadata that are recognized by Nacos
*
* @author nkorange
* @since 1.0.0
*/
public class PreservedMetadataKeys {

/**
* The key to indicate the registry source of service instance, such as Dubbo, SpringCloud, etc.
*/
public static final String REGISTER_SOURCE = "preserved.register.source";
}
17 changes: 9 additions & 8 deletions client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<parent>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-all</artifactId>
<version>1.0.0-RC1</version>
<version>1.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -85,18 +85,18 @@
</dependency>

<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-lgpl</artifactId>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>

<dependency>
<groupId>net.jcip</groupId>
<artifactId>jcip-annotations</artifactId>
<optional>true</optional>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>

<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-annotations</artifactId>
<groupId>net.jcip</groupId>
<artifactId>jcip-annotations</artifactId>
<optional>true</optional>
</dependency>

Expand All @@ -113,6 +113,7 @@
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public class NacosConfigService implements ConfigService {
private static final Logger LOGGER = LogUtils.logger(NacosConfigService.class);

private final long POST_TIMEOUT = 3000L;

private static final String EMPTY = "";

/**
* http agent
*/
Expand All @@ -82,7 +85,7 @@ public NacosConfigService(Properties properties) throws NacosException {
}

private void initNamespace(Properties properties) {
String namespaceTmp = properties.getProperty(PropertyKeyConst.NAMESPACE);
String namespaceTmp = null;

namespaceTmp = TemplateUtils.stringBlankAndThenExecute(namespaceTmp, new Callable<String>() {
@Override
Expand All @@ -95,10 +98,14 @@ public String call() {
@Override
public String call() {
String namespace = System.getenv(PropertyKeyConst.SystemEnv.ALIBABA_ALIWARE_NAMESPACE);
return StringUtils.isNotBlank(namespace) ? namespace : "";
return StringUtils.isNotBlank(namespace) ? namespace : EMPTY;
}
});
namespace = namespaceTmp;

if (StringUtils.isBlank(namespaceTmp)) {
namespaceTmp = properties.getProperty(PropertyKeyConst.NAMESPACE);
}
namespace = StringUtils.isNotBlank(namespaceTmp) ? namespaceTmp.trim() : EMPTY;
properties.put(PropertyKeyConst.NAMESPACE, namespace);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@
import com.alibaba.nacos.client.utils.LogUtils;
import com.alibaba.nacos.client.utils.ParamUtil;
import com.alibaba.nacos.client.utils.StringUtils;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.type.TypeReference;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import org.slf4j.Logger;

import java.io.IOException;
import java.net.ConnectException;
import java.net.HttpURLConnection;
Expand Down Expand Up @@ -222,6 +221,11 @@ public String call() throws Exception {
}

private void initAkSk(Properties properties) {
String ramRoleName = properties.getProperty(PropertyKeyConst.RAM_ROLE_NAME);
if (!StringUtils.isBlank(ramRoleName)) {
STSConfig.getInstance().setRamRoleName(ramRoleName);
}

String ak = properties.getProperty(PropertyKeyConst.ACCESS_KEY);
if (StringUtils.isBlank(ak)) {
accessKey = SpasAdapter.getAk();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import com.alibaba.nacos.client.utils.LogUtils;
import com.alibaba.nacos.client.utils.ParamUtil;
import com.alibaba.nacos.client.utils.StringUtils;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.slf4j.Logger;

import java.io.File;
Expand Down Expand Up @@ -102,7 +101,6 @@ public void removeTenantListener(String dataId, String group, Listener listener)
}
}

@SuppressFBWarnings("JLM_JSR166_UTILCONCURRENT_MONITORENTER")
void removeCache(String dataId, String group) {
String groupKey = GroupKey.getKey(dataId, group);
synchronized (cacheMap) {
Expand All @@ -115,7 +113,6 @@ void removeCache(String dataId, String group) {
MetricsMonitor.getListenConfigCountMonitor().set(cacheMap.get().size());
}

@SuppressFBWarnings("JLM_JSR166_UTILCONCURRENT_MONITORENTER")
void removeCache(String dataId, String group, String tenant) {
String groupKey = GroupKey.getKeyTenant(dataId, group, tenant);
synchronized (cacheMap) {
Expand All @@ -128,7 +125,6 @@ void removeCache(String dataId, String group, String tenant) {
MetricsMonitor.getListenConfigCountMonitor().set(cacheMap.get().size());
}

@SuppressFBWarnings("JLM_JSR166_UTILCONCURRENT_MONITORENTER")
public CacheData addCacheDataIfAbsent(String dataId, String group) {
CacheData cache = getCache(dataId, group);
if (null != cache) {
Expand Down Expand Up @@ -163,7 +159,6 @@ public CacheData addCacheDataIfAbsent(String dataId, String group) {
return cache;
}

@SuppressFBWarnings("JLM_JSR166_UTILCONCURRENT_MONITORENTER")
public CacheData addCacheDataIfAbsent(String dataId, String group, String tenant) {
CacheData cache = getCache(dataId, group, tenant);
if (null != cache) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.alibaba.nacos.client.config.impl.HttpSimpleClient.HttpResult;
import com.alibaba.nacos.client.config.utils.IOUtils;
import com.alibaba.nacos.client.utils.*;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.slf4j.Logger;

import java.io.IOException;
Expand Down Expand Up @@ -86,7 +85,9 @@ public ServerListManager(String endpoint) throws NacosException {
public ServerListManager(String endpoint, String namespace) throws NacosException {
isFixed = false;
isStarted = false;
endpoint = initEndpoint(endpoint);
Properties properties = new Properties();
properties.setProperty(PropertyKeyConst.ENDPOINT, endpoint);
endpoint = initEndpoint(properties);

if (StringUtils.isBlank(endpoint)) {
throw new NacosException(NacosException.CLIENT_INVALID_PARAM, "endpoint is blank");
Expand All @@ -109,7 +110,7 @@ public ServerListManager(String endpoint, String namespace) throws NacosExceptio

public ServerListManager(Properties properties) throws NacosException {
isStarted = false;
String serverAddrsStr = properties.getProperty(PropertyKeyConst.SERVER_ADDR);
serverAddrsStr = properties.getProperty(PropertyKeyConst.SERVER_ADDR);
String namespace = properties.getProperty(PropertyKeyConst.NAMESPACE);
initParam(properties);
if (StringUtils.isNotEmpty(serverAddrsStr)) {
Expand Down Expand Up @@ -153,7 +154,7 @@ public ServerListManager(Properties properties) throws NacosException {
}

private void initParam(Properties properties) {
endpoint = initEndpoint(properties.getProperty(PropertyKeyConst.ENDPOINT));
endpoint = initEndpoint(properties);

String contentPathTmp = properties.getProperty(PropertyKeyConst.CONTEXT_PATH);
if (!StringUtils.isBlank(contentPathTmp)) {
Expand All @@ -165,19 +166,29 @@ private void initParam(Properties properties) {
}
}

private String initEndpoint(String endpointTmp) {
String endpointPortTmp = System.getenv(PropertyKeyConst.SystemEnv.ALIBABA_ALIWARE_ENDPOINT_PORT);
if (StringUtils.isNotBlank(endpointPortTmp)) {
endpointPort = Integer.parseInt(endpointPortTmp);
}
private String initEndpoint(final Properties properties) {

return TemplateUtils.stringBlankAndThenExecute(endpointTmp, new Callable<String>() {
String endpointPortTmp = TemplateUtils.stringEmptyAndThenExecute(System.getenv(PropertyKeyConst.SystemEnv.ALIBABA_ALIWARE_ENDPOINT_PORT), new Callable<String>() {
@Override
public String call() {
String endpointUrl = System.getenv(PropertyKeyConst.SystemEnv.ALIBABA_ALIWARE_ENDPOINT_URL);
return StringUtils.isNotBlank(endpointUrl) ? endpointUrl : "";
return properties.getProperty(PropertyKeyConst.ENDPOINT_PORT);
}
});

if (StringUtils.isNotBlank(endpointPortTmp)) {
endpointPort = Integer.parseInt(endpointPortTmp);
}

String endpointTmp = properties.getProperty(PropertyKeyConst.ENDPOINT);
if (Boolean.valueOf(properties.getProperty(PropertyKeyConst.IS_USE_ENDPOINT_PARSING_RULE, ParamUtil.USE_ENDPOINT_PARSING_RULE_DEFAULT_VALUE))) {
String endpointUrl = ParamUtil.parsingEndpointRule(endpointTmp);
if (StringUtils.isNotBlank(endpointUrl)) {
serverAddrsStr = "";
}
return endpointUrl;
}

return StringUtils.isNotBlank(endpointTmp) ? endpointTmp : "";
}

public synchronized void start() throws NacosException {
Expand Down Expand Up @@ -369,6 +380,7 @@ public String getTenant() {

public String addressServerUrl;

private String serverAddrsStr;
}

/**
Expand Down Expand Up @@ -396,7 +408,6 @@ public RandomizedServerAddress(String ip) {
}

@Override
@SuppressFBWarnings("EQ_COMPARETO_USE_OBJECT_EQUALS")
public int compareTo(RandomizedServerAddress other) {
if (this.priority != other.priority) {
return other.priority - this.priority;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
public class TenantUtil {

static String userTenant = "";
private static String userTenant = "";

static {
userTenant = System.getProperty("tenant.id", "");
Expand Down
Loading

0 comments on commit 0b0e1e2

Please sign in to comment.