Skip to content

Commit

Permalink
Merge pull request #12 from alibaba/develop
Browse files Browse the repository at this point in the history
拉代码
  • Loading branch information
KeRan213539 committed Jan 14, 2020
2 parents df279e4 + 2da88de commit 89760cd
Show file tree
Hide file tree
Showing 150 changed files with 5,554 additions and 973 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
notifications:
email:
recipients:
- xchaos8@126.com
- nacos_dev@linux.alibaba.com
- dev-nacos@googlegroups.com
- mw_configcenter@list.alibaba-inc.com
on_success: change
Expand Down Expand Up @@ -30,7 +28,7 @@ before_install:

script:
- mvn -B clean package apache-rat:check findbugs:findbugs -Dmaven.test.skip=true
- mvn -Prelease-nacos clean install -U
- mvn -Prelease-nacos -Dmaven.test.skip=true clean install -U
- mvn clean package -Pit-test
after_success:
- mvn clean package -Pit-test
Expand Down
2 changes: 1 addition & 1 deletion BUILDING
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ Build Instructions for NACOS
Execute the following command in order to build the tar.gz packages and install JAR into local repository:

#build nacos
$ mvn -Prelease-nacos -DskipTests clean install -U
$ mvn -Prelease-nacos -Dmaven.test.skip=true clean install -U
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ These are only part of the companies using Nacos, for reference only. If you are
![时代光华](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)
![chigua](https://img.alicdn.com/tfs/TB1aUe5EpzqK1RjSZSgXXcpAVXa-248-124.png)
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 @@ -32,6 +32,10 @@ public class PropertyKeyConst {

public final static String NAMESPACE = "namespace";

public final static String USERNAME = "username";

public final static String PASSWORD = "password";

public final static String ACCESS_KEY = "accessKey";

public final static String SECRET_KEY = "secretKey";
Expand Down
14 changes: 14 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 @@ -62,6 +62,8 @@ public class Constants {

public static final String CONFIG_VERSION = "Config-Version";

public static final String CONFIG_TYPE = "Config-Type";

public static final String IF_MODIFIED_SINCE = "If-Modified-Since";

public static final String SPACING_INTERVAL = "client-spacing-interval";
Expand All @@ -70,6 +72,16 @@ public class Constants {

public static final String CONFIG_CONTROLLER_PATH = BASE_PATH + "/configs";

public static final String TOKEN = "token";

public static final String ACCESS_TOKEN = "accessToken";

public static final String TOKEN_TTL = "tokenTtl";

public static final String GLOBAL_ADMIN = "globalAdmin";

public static final String TOKEN_REFRESH_WINDOW = "tokenRefreshWindow";

/**
* second
*/
Expand Down Expand Up @@ -169,4 +181,6 @@ public class Constants {

public static final String SNOWFLAKE_INSTANCE_ID_GENERATOR = "snowflake";

public static final String HTTP_PREFIX = "http";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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.config;

import com.alibaba.nacos.api.config.ConfigChangeItem;

import java.util.Collection;
import java.util.Map;

/**
* ConfigChangeEvent
*
* @author rushsky518
*/
public class ConfigChangeEvent {
private Map<String, ConfigChangeItem> data;

public ConfigChangeEvent(Map<String, ConfigChangeItem> data) {
this.data = data;
}

public ConfigChangeItem getChangeItem(String key) {
return data.get(key);
}

public Collection<ConfigChangeItem> getChangeItems() {
return data.values();
}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* 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.config;

/**
* ConfigChangeItem
*
* @author rushsky518
*/
public class ConfigChangeItem {
private String key;
private String oldValue;
private String newValue;

private PropertyChangeType type;

public ConfigChangeItem(String key, String oldValue, String newValue) {
this.key = key;
this.oldValue = oldValue;
this.newValue = newValue;
}

public String getKey() {
return key;
}

public void setKey(String key) {
this.key = key;
}

public String getOldValue() {
return oldValue;
}

public void setOldValue(String oldValue) {
this.oldValue = oldValue;
}

public String getNewValue() {
return newValue;
}

public void setNewValue(String newValue) {
this.newValue = newValue;
}

public PropertyChangeType getType() {
return type;
}

public void setType(PropertyChangeType type) {
this.type = type;
}

@Override
public String toString() {
return "ConfigChangeItem{" +
"key='" + key + '\'' +
", oldValue='" + oldValue + '\'' +
", newValue='" + newValue + '\'' +
", type=" + type +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +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.config;

/**
* Property Change Type
*
* @author rushsky518
*/
public enum PropertyChangeType {
/** add */
ADDED,
/** modified */
MODIFIED,
/** deleted */
DELETED
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* 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.config.listener;

import com.alibaba.nacos.api.config.ConfigChangeItem;

import java.io.IOException;
import java.util.Map;

/**
* ConfigChangeParser
*
* @author rushsky518
*/
public interface ConfigChangeParser {
/**
* judge type
* @param type
* @return
*/
boolean isResponsibleFor(String type);

/**
* compare old and new data
* @param oldContent
* @param newContent
* @param type
* @return
* @throws IOException
*/
Map<String, ConfigChangeItem> doParse(String oldContent, String newContent, String type) throws IOException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.alibaba.nacos.api.naming.utils;

import com.alibaba.nacos.api.common.Constants;
import org.apache.commons.lang3.StringUtils;

/**
* @author nkorange
Expand All @@ -32,13 +33,19 @@ public static String getGroupedName(String serviceName, String groupName) {
}

public static String getServiceName(String serviceNameWithGroup) {
if (StringUtils.isBlank(serviceNameWithGroup)) {
return StringUtils.EMPTY;
}
if (!serviceNameWithGroup.contains(Constants.SERVICE_INFO_SPLITER)) {
return serviceNameWithGroup;
}
return serviceNameWithGroup.split(Constants.SERVICE_INFO_SPLITER)[1];
}

public static String getGroupName(String serviceNameWithGroup) {
if (StringUtils.isBlank(serviceNameWithGroup)) {
return StringUtils.EMPTY;
}
if (!serviceNameWithGroup.contains(Constants.SERVICE_INFO_SPLITER)) {
return Constants.DEFAULT_GROUP;
}
Expand Down
4 changes: 4 additions & 0 deletions client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
</dependency>

</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package com.alibaba.nacos.client.config;

import com.alibaba.nacos.api.PropertyKeyConst;
import com.alibaba.nacos.api.SystemPropertyKeyConst;
import com.alibaba.nacos.api.common.Constants;
import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.api.config.listener.Listener;
Expand All @@ -33,8 +32,7 @@
import com.alibaba.nacos.client.config.utils.ContentUtils;
import com.alibaba.nacos.client.config.utils.ParamUtils;
import com.alibaba.nacos.client.utils.LogUtils;
import com.alibaba.nacos.client.utils.TemplateUtils;
import com.alibaba.nacos.client.utils.TenantUtil;
import com.alibaba.nacos.client.utils.ParamUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;

Expand All @@ -44,7 +42,6 @@
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.Callable;

/**
* Config Impl
Expand Down Expand Up @@ -86,34 +83,7 @@ public NacosConfigService(Properties properties) throws NacosException {
}

private void initNamespace(Properties properties) {
String namespaceTmp = null;

String isUseCloudNamespaceParsing =
properties.getProperty(PropertyKeyConst.IS_USE_CLOUD_NAMESPACE_PARSING,
System.getProperty(SystemPropertyKeyConst.IS_USE_CLOUD_NAMESPACE_PARSING,
String.valueOf(Constants.DEFAULT_USE_CLOUD_NAMESPACE_PARSING)));

if (Boolean.parseBoolean(isUseCloudNamespaceParsing)) {
namespaceTmp = TemplateUtils.stringBlankAndThenExecute(namespaceTmp, new Callable<String>() {
@Override
public String call() {
return TenantUtil.getUserTenantForAcm();
}
});

namespaceTmp = TemplateUtils.stringBlankAndThenExecute(namespaceTmp, new Callable<String>() {
@Override
public String call() {
String namespace = System.getenv(PropertyKeyConst.SystemEnv.ALIBABA_ALIWARE_NAMESPACE);
return StringUtils.isNotBlank(namespace) ? namespace : EMPTY;
}
});
}

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

Expand Down Expand Up @@ -170,9 +140,8 @@ private String getConfigInner(String tenant, String dataId, String group, long t
}

try {
content = worker.getServerConfig(dataId, group, tenant, timeoutMs);

cr.setContent(content);
String[] ct = worker.getServerConfig(dataId, group, tenant, timeoutMs);
cr.setContent(ct[0]);

configFilterChainManager.doFilter(null, cr);
content = cr.getContent();
Expand Down
Loading

0 comments on commit 89760cd

Please sign in to comment.