Skip to content

Commit

Permalink
Merge pull request #4 from alibaba/develop
Browse files Browse the repository at this point in the history
merge
  • Loading branch information
IanCao authored Jun 24, 2019
2 parents df6f3a8 + c7fe374 commit 09f5b84
Show file tree
Hide file tree
Showing 188 changed files with 3,371 additions and 1,066 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
.project
.settings
target
.project
.idea
.vscode
.DS_Store
Expand Down
19 changes: 12 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,22 @@ language: java

matrix:
include:
# On OSX, run with default JDK only.
# - os: osx
# On Linux, run with specific JDKs only.
- os: linux
env: CUSTOM_JDK="oraclejdk8"
# On OSX, run with default JDK only.
# - os: osx
# On Linux, run with specific JDKs only.
- os: linux
env: CUSTOM_JDK="oraclejdk8"

jdk:
- openjdk10
- openjdk9
- openjdk8

before_install:
- echo 'MAVEN_OPTS="$MAVEN_OPTS -Xmx1024m -XX:MaxPermSize=512m -XX:+BytecodeVerificationLocal"' >> ~/.mavenrc
- cat ~/.mavenrc
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then export JAVA_HOME=$(/usr/libexec/java_home); fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then jdk_switcher use "$CUSTOM_JDK"; fi
# - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export JAVA_HOME=$(/usr/libexec/java_home); fi
# - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then jdk_switcher use "$CUSTOM_JDK"; fi

script:
- mvn -B clean package apache-rat:check findbugs:findbugs -Dmaven.test.skip=true
Expand Down
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</version>
<version>1.0.1</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
14 changes: 14 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_CLOUD_NAMESPACE_PARSING = "isUseCloudNamespaceParsing";

public final static String IS_USE_ENDPOINT_PARSING_RULE = "isUseEndpointParsingRule";

public final static String ENDPOINT = "endpoint";
Expand All @@ -44,12 +46,23 @@ public class PropertyKeyConst {

public final static String ENCODE = "encode";

public final static String CONFIG_LONG_POLL_TIMEOUT = "configLongPollTimeout";

public final static String CONFIG_RETRY_TIME = "configRetryTime";

public final static String MAX_RETRY = "maxRetry";

public final static String ENABLE_REMOTE_SYNC_CONFIG = "enableRemoteSyncConfig";

public final static String NAMING_LOAD_CACHE_AT_START = "namingLoadCacheAtStart";

public final static String NAMING_CLIENT_BEAT_THREAD_COUNT = "namingClientBeatThreadCount";

public final static String NAMING_POLLING_THREAD_COUNT = "namingPollingThreadCount";

/**
* Get the key value of some variable value from the system property
*/
public static class SystemEnv {

public static final String ALIBABA_ALIWARE_ENDPOINT_PORT = "ALIBABA_ALIWARE_ENDPOINT_PORT";
Expand All @@ -58,4 +71,5 @@ public static class SystemEnv {

public static final String ALIBABA_ALIWARE_ENDPOINT_URL = "ALIBABA_ALIWARE_ENDPOINT_URL";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
package com.alibaba.nacos.api;

/**
* <p>
* Support for reading the value of the specified variable from the -D parameter
* </P>
* Properties that are preferred to which in {@link PropertyKeyConst}
*
* @author pbting
Expand All @@ -27,5 +30,23 @@ public interface SystemPropertyKeyConst {

String NAMING_WEB_CONTEXT = "nacos.naming.web.context";

String NACOS_NAMING_REQUEST_MODULE = "nacos.naming.request.module";
/**
* In the cloud (Alibaba Cloud or other cloud vendors) environment,
* whether to enable namespace resolution in the cloud environment.
* <p>
* The default is on.
* </p>
*/
String IS_USE_CLOUD_NAMESPACE_PARSING = "nacos.use.cloud.namespace.parsing";

/**
* In the cloud environment, if the process level requires a globally uniform namespace,
* it can be specified with the -D parameter.
*/
String ANS_NAMESPACE = "ans.namespace";

/**
* It is also supported by the -D parameter.
*/
String IS_USE_ENDPOINT_PARSING_RULE = "nacos.use.endpoint.parsing.rule";
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,26 @@
*/
String ENCODE = "encode";

/**
* The property name of "long-poll.timeout"
*/
String CONFIG_LONG_POLL_TIMEOUT = "configLongPollTimeout";

/**
* The property name of "config.retry.time"
*/
String CONFIG_RETRY_TIME = "configRetryTime";

/**
* The property name of "maxRetry"
*/
String MAX_RETRY = "maxRetry";

/**
* The property name of "enableRemoteSyncConfig"
*/
String ENABLE_REMOTE_SYNC_CONFIG = "enableRemoteSyncConfig";

/**
* The placeholder of endpoint, the value is <code>"${nacos.endpoint:}"</code>
*/
Expand Down Expand Up @@ -116,6 +136,26 @@
*/
String ENCODE_PLACEHOLDER = "${" + PREFIX + ENCODE + ":UTF-8}";

/**
* The placeholder of {@link NacosProperties#CONFIG_LONG_POLL_TIMEOUT configLongPollTimeout}, the value is <code>"${nacos.configLongPollTimeout:}"</code>
*/
String CONFIG_LONG_POLL_TIMEOUT_PLACEHOLDER = "${" + PREFIX + CONFIG_LONG_POLL_TIMEOUT + ":}";

/**
* The placeholder of {@link NacosProperties#CONFIG_RETRY_TIME configRetryTime}, the value is <code>"${nacos.configRetryTime:}"</code>
*/
String CONFIG_RETRY_TIME_PLACEHOLDER = "${" + PREFIX + CONFIG_RETRY_TIME + ":}";

/**
* The placeholder of {@link NacosProperties#MAX_RETRY maxRetry}, the value is <code>"${nacos.maxRetry:}"</code>
*/
String MAX_RETRY_PLACEHOLDER = "${" + PREFIX + MAX_RETRY + ":}";

/**
* The placeholder of {@link NacosProperties#ENABLE_REMOTE_SYNC_CONFIG enableRemoteSyncConfig}, the value is <code>"${nacos.enableRemoteSyncConfig:}"</code>
*/
String ENABLE_REMOTE_SYNC_CONFIG_PLACEHOLDER = "${" + PREFIX + ENABLE_REMOTE_SYNC_CONFIG + "}";

/**
* The property of "endpoint"
*
Expand Down Expand Up @@ -180,4 +220,36 @@
*/
String encode() default ENCODE_PLACEHOLDER;

/**
* The property of "configLongPollTimeout"
*
* @return empty as default value
* @see #CONFIG_LONG_POLL_TIMEOUT_PLACEHOLDER
*/
String configLongPollTimeout() default CONFIG_LONG_POLL_TIMEOUT_PLACEHOLDER;

/**
* The property of "configRetryTime"
*
* @return empty as default value
* @see #CONFIG_RETRY_TIME_PLACEHOLDER
*/
String configRetryTime() default CONFIG_RETRY_TIME_PLACEHOLDER;

/**
* The property of "maxRetry"
*
* @return empty as default value
* @see #MAX_RETRY
*/
String maxRetry() default MAX_RETRY_PLACEHOLDER;

/**
* The property of "enableRemoteSyncConfig"
*
* @return empty as default value
* @see #ENABLE_REMOTE_SYNC_CONFIG
*/
String enableRemoteSyncConfig() default ENABLE_REMOTE_SYNC_CONFIG_PLACEHOLDER;

}
36 changes: 34 additions & 2 deletions api/src/main/java/com/alibaba/nacos/api/common/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package com.alibaba.nacos.api.common;

import java.util.concurrent.TimeUnit;

/**
* Constant
*
Expand Down Expand Up @@ -88,6 +90,26 @@ public class Constants {
*/
public static final int SO_TIMEOUT = 60000;

/**
* millisecond
*/
public static final int CONFIG_LONG_POLL_TIMEOUT = 30000;

/**
* millisecond
*/
public static final int MIN_CONFIG_LONG_POLL_TIMEOUT = 10000;

/**
* millisecond
*/
public static final int CONFIG_RETRY_TIME = 2000;

/**
* Maximum number of retries
*/
public static final int MAX_RETRY = 3;

/**
* millisecond
*/
Expand All @@ -105,9 +127,9 @@ public class Constants {

public static final float DEFAULT_PROTECT_THRESHOLD = 0.0F;

public static final String LINE_SEPARATOR = Character.toString((char)1);
public static final String LINE_SEPARATOR = Character.toString((char) 1);

public static final String WORD_SEPARATOR = Character.toString((char)2);
public static final String WORD_SEPARATOR = Character.toString((char) 2);

public static final String LONGPOLLING_LINE_SEPARATOR = "\r\n";

Expand All @@ -123,11 +145,21 @@ public class Constants {

public static final String DEFAULT_CLUSTER_NAME = "DEFAULT";

public static final long DEFAULT_HEART_BEAT_TIMEOUT = TimeUnit.SECONDS.toMillis(15);

public static final long DEFAULT_IP_DELETE_TIMEOUT = TimeUnit.SECONDS.toMillis(30);

public static final long DEFAULT_HEART_BEAT_INTERVAL = TimeUnit.SECONDS.toMillis(5);

public static final String DEFAULT_NAMESPACE_ID = "public";

public static final boolean DEFAULT_USE_CLOUD_NAMESPACE_PARSING = true;

public static final int WRITE_REDIRECT_CODE = 307;

public static final String SERVICE_INFO_SPLITER = "@@";

public static final String NULL_STRING = "null";

public static final String NUMBER_PATTERN = "^\\d+$";
}
17 changes: 17 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 @@ -36,6 +36,23 @@ public interface ConfigService {
*/
String getConfig(String dataId, String group, long timeoutMs) throws NacosException;

/**
* Get config and register Listener
*
* If you want to pull it yourself when the program starts to get the configuration for the first time,
* and the registered Listener is used for future configuration updates, you can keep the original
* code unchanged, just add the system parameter: enableRemoteSyncConfig = "true" ( But there is network overhead);
* therefore we recommend that you use this interface directly
*
* @param dataId dataId
* @param group group
* @param timeoutMs read timeout
* @param listener {@link Listener}
* @return config value
* @throws NacosException NacosException
*/
String getConfigAndSignListener(String dataId, String group, long timeoutMs, Listener listener) throws NacosException;

/**
* Add a listener to the configuration, after the server modified the
* configuration, the client will use the incoming listener callback.
Expand Down
64 changes: 64 additions & 0 deletions api/src/main/java/com/alibaba/nacos/api/config/ConfigType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* 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;

/**
* @author liaochuntao
* @date 2019-06-14 21:12
**/
public enum ConfigType {

/**
* config type is "properties"
*/
PROPERTIES("properties"),

/**
* config type is "xml"
*/
XML("xml"),

/**
* config type is "json"
*/
JSON("json"),

/**
* config type is "text"
*/
TEXT("text"),

/**
* config type is "html"
*/
HTML("html"),

/**
* config type is "yaml"
*/
YAML("yaml");

String type;

ConfigType(String type) {
this.type = type;
}

public String getType() {
return type;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import com.alibaba.nacos.api.annotation.NacosProperties;
import com.alibaba.nacos.api.common.Constants;
import com.alibaba.nacos.api.config.ConfigType;
import com.alibaba.nacos.api.config.convert.NacosConfigConverter;

import java.lang.annotation.*;
Expand Down Expand Up @@ -48,6 +49,13 @@
*/
String dataId();

/**
* Nacos Config type
*
* @return "properties"
*/
ConfigType type() default ConfigType.PROPERTIES;

/**
* Specify {@link NacosConfigConverter Nacos configuraion convertor} class to convert target type instance.
*
Expand Down
Loading

0 comments on commit 09f5b84

Please sign in to comment.