Merge pull request #1376 from chuntaojun/develop
Support more config type setting and fix travis-ci yaml bug
This commit is contained in:
commit
627e5cf460
@ -18,11 +18,16 @@ matrix:
|
|||||||
- os: linux
|
- os: linux
|
||||||
env: CUSTOM_JDK="oraclejdk8"
|
env: CUSTOM_JDK="oraclejdk8"
|
||||||
|
|
||||||
|
jdk:
|
||||||
|
- openjdk10
|
||||||
|
- openjdk9
|
||||||
|
- openjdk8
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- echo 'MAVEN_OPTS="$MAVEN_OPTS -Xmx1024m -XX:MaxPermSize=512m -XX:+BytecodeVerificationLocal"' >> ~/.mavenrc
|
- echo 'MAVEN_OPTS="$MAVEN_OPTS -Xmx1024m -XX:MaxPermSize=512m -XX:+BytecodeVerificationLocal"' >> ~/.mavenrc
|
||||||
- cat ~/.mavenrc
|
- cat ~/.mavenrc
|
||||||
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then export JAVA_HOME=$(/usr/libexec/java_home); 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
|
# - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then jdk_switcher use "$CUSTOM_JDK"; fi
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- mvn -B clean package apache-rat:check findbugs:findbugs -Dmaven.test.skip=true
|
- mvn -B clean package apache-rat:check findbugs:findbugs -Dmaven.test.skip=true
|
||||||
|
@ -46,9 +46,9 @@ public class PropertyKeyConst {
|
|||||||
|
|
||||||
public final static String ENCODE = "encode";
|
public final static String ENCODE = "encode";
|
||||||
|
|
||||||
public final static String CONFIG_LONG_POLL_TIMEOUT = "config.long-poll.timeout";
|
public final static String CONFIG_LONG_POLL_TIMEOUT = "configLongPollTimeout";
|
||||||
|
|
||||||
public final static String CONFIG_RETRY_TIME = "config.retry.time";
|
public final static String CONFIG_RETRY_TIME = "configRetryTime";
|
||||||
|
|
||||||
public final static String MAX_RETRY = "maxRetry";
|
public final static String MAX_RETRY = "maxRetry";
|
||||||
|
|
||||||
|
@ -76,6 +76,21 @@ public @interface NacosProperties {
|
|||||||
*/
|
*/
|
||||||
String ENCODE = "encode";
|
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 placeholder of endpoint, the value is <code>"${nacos.endpoint:}"</code>
|
* The placeholder of endpoint, the value is <code>"${nacos.endpoint:}"</code>
|
||||||
*/
|
*/
|
||||||
@ -116,6 +131,21 @@ public @interface NacosProperties {
|
|||||||
*/
|
*/
|
||||||
String ENCODE_PLACEHOLDER = "${" + PREFIX + ENCODE + ":UTF-8}";
|
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 property of "endpoint"
|
* The property of "endpoint"
|
||||||
*
|
*
|
||||||
@ -180,4 +210,28 @@ public @interface NacosProperties {
|
|||||||
*/
|
*/
|
||||||
String encode() default ENCODE_PLACEHOLDER;
|
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;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -17,6 +17,7 @@ package com.alibaba.nacos.api.config.annotation;
|
|||||||
|
|
||||||
import com.alibaba.nacos.api.annotation.NacosProperties;
|
import com.alibaba.nacos.api.annotation.NacosProperties;
|
||||||
import com.alibaba.nacos.api.common.Constants;
|
import com.alibaba.nacos.api.common.Constants;
|
||||||
|
import com.alibaba.nacos.api.config.ConfigType;
|
||||||
import com.alibaba.nacos.api.config.convert.NacosConfigConverter;
|
import com.alibaba.nacos.api.config.convert.NacosConfigConverter;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.*;
|
||||||
@ -48,6 +49,13 @@ public @interface NacosConfigListener {
|
|||||||
*/
|
*/
|
||||||
String dataId();
|
String dataId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Nacos Config type
|
||||||
|
*
|
||||||
|
* @return "properties"
|
||||||
|
*/
|
||||||
|
ConfigType type() default ConfigType.PROPERTIES;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify {@link NacosConfigConverter Nacos configuraion convertor} class to convert target type instance.
|
* Specify {@link NacosConfigConverter Nacos configuraion convertor} class to convert target type instance.
|
||||||
*
|
*
|
||||||
|
@ -18,6 +18,7 @@ package com.alibaba.nacos.api.config.annotation;
|
|||||||
import com.alibaba.nacos.api.PropertyKeyConst;
|
import com.alibaba.nacos.api.PropertyKeyConst;
|
||||||
import com.alibaba.nacos.api.annotation.NacosProperties;
|
import com.alibaba.nacos.api.annotation.NacosProperties;
|
||||||
import com.alibaba.nacos.api.common.Constants;
|
import com.alibaba.nacos.api.common.Constants;
|
||||||
|
import com.alibaba.nacos.api.config.ConfigType;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
@ -54,7 +55,7 @@ public @interface NacosConfigurationProperties {
|
|||||||
*
|
*
|
||||||
* @return default value is <code>false</code>
|
* @return default value is <code>false</code>
|
||||||
*/
|
*/
|
||||||
boolean yaml() default false;
|
ConfigType type() default ConfigType.PROPERTIES;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It indicates the properties of current doBind bean is auto-refreshed when Nacos configuration is changed.
|
* It indicates the properties of current doBind bean is auto-refreshed when Nacos configuration is changed.
|
||||||
|
@ -91,9 +91,9 @@ public class ServerHttpAgent implements HttpAgent {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
} catch (ConnectException ce) {
|
} catch (ConnectException ce) {
|
||||||
LOGGER.error("[NACOS ConnectException httpGet] currentServerAddr:{}", serverListMgr.getCurrentServerAddr());
|
LOGGER.error("[NACOS ConnectException httpGet] currentServerAddr:{}, err : {}", serverListMgr.getCurrentServerAddr(), ce.getMessage());
|
||||||
} catch (SocketTimeoutException stoe) {
|
} catch (SocketTimeoutException stoe) {
|
||||||
LOGGER.error("[NACOS SocketTimeoutException httpGet] currentServerAddr:{}", serverListMgr.getCurrentServerAddr());
|
LOGGER.error("[NACOS SocketTimeoutException httpGet] currentServerAddr:{}, err : {}", serverListMgr.getCurrentServerAddr(), stoe.getMessage());
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
LOGGER.error("[NACOS IOException httpGet] currentServerAddr: " + serverListMgr.getCurrentServerAddr(), ioe);
|
LOGGER.error("[NACOS IOException httpGet] currentServerAddr: " + serverListMgr.getCurrentServerAddr(), ioe);
|
||||||
throw ioe;
|
throw ioe;
|
||||||
@ -138,7 +138,7 @@ public class ServerHttpAgent implements HttpAgent {
|
|||||||
if (result.code == HttpURLConnection.HTTP_INTERNAL_ERROR
|
if (result.code == HttpURLConnection.HTTP_INTERNAL_ERROR
|
||||||
|| result.code == HttpURLConnection.HTTP_BAD_GATEWAY
|
|| result.code == HttpURLConnection.HTTP_BAD_GATEWAY
|
||||||
|| result.code == HttpURLConnection.HTTP_UNAVAILABLE) {
|
|| result.code == HttpURLConnection.HTTP_UNAVAILABLE) {
|
||||||
LOGGER.error("[NACOS ConnectException httpPost] currentServerAddr: {}, httpCode: {}",
|
LOGGER.error("[NACOS ConnectException] currentServerAddr: {}, httpCode: {}",
|
||||||
currentServerAddr, result.code);
|
currentServerAddr, result.code);
|
||||||
} else {
|
} else {
|
||||||
// Update the currently available server addr
|
// Update the currently available server addr
|
||||||
@ -146,10 +146,9 @@ public class ServerHttpAgent implements HttpAgent {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
} catch (ConnectException ce) {
|
} catch (ConnectException ce) {
|
||||||
LOGGER.error("[NACOS ConnectException httpPost] currentServerAddr: {}", currentServerAddr);
|
LOGGER.error("[NACOS ConnectException httpPost] currentServerAddr: {}, err : {}", currentServerAddr, ce.getMessage());
|
||||||
} catch (SocketTimeoutException stoe) {
|
} catch (SocketTimeoutException stoe) {
|
||||||
LOGGER.error("[NACOS SocketTimeoutException httpPost] currentServerAddr: {}, err : {}",
|
LOGGER.error("[NACOS SocketTimeoutException httpPost] currentServerAddr: {}, err : {}", currentServerAddr, stoe.getMessage());
|
||||||
currentServerAddr, stoe.getMessage());
|
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
LOGGER.error("[NACOS IOException httpPost] currentServerAddr: " + currentServerAddr, ioe);
|
LOGGER.error("[NACOS IOException httpPost] currentServerAddr: " + currentServerAddr, ioe);
|
||||||
throw ioe;
|
throw ioe;
|
||||||
@ -200,9 +199,9 @@ public class ServerHttpAgent implements HttpAgent {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
} catch (ConnectException ce) {
|
} catch (ConnectException ce) {
|
||||||
LOGGER.error("[NACOS ConnectException httpDelete] currentServerAddr:{}", serverListMgr.getCurrentServerAddr());
|
LOGGER.error("[NACOS ConnectException httpDelete] currentServerAddr:{}, err : {}", serverListMgr.getCurrentServerAddr(), ce.getMessage());
|
||||||
} catch (SocketTimeoutException stoe) {
|
} catch (SocketTimeoutException stoe) {
|
||||||
LOGGER.error("[NACOS SocketTimeoutException httpDelete] currentServerAddr:{}", serverListMgr.getCurrentServerAddr());
|
LOGGER.error("[NACOS SocketTimeoutException httpDelete] currentServerAddr:{}, err : {}", serverListMgr.getCurrentServerAddr(), stoe.getMessage());
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
LOGGER.error("[NACOS IOException httpDelete] currentServerAddr: " + serverListMgr.getCurrentServerAddr(), ioe);
|
LOGGER.error("[NACOS IOException httpDelete] currentServerAddr: " + serverListMgr.getCurrentServerAddr(), ioe);
|
||||||
throw ioe;
|
throw ioe;
|
||||||
|
@ -473,10 +473,10 @@ public class ClientWorker {
|
|||||||
|
|
||||||
private void init(Properties properties) {
|
private void init(Properties properties) {
|
||||||
|
|
||||||
timeout = Math.max(NumberUtils.toInt(String.valueOf(properties.get(PropertyKeyConst.CONFIG_LONG_POLL_TIMEOUT)),
|
timeout = Math.max(NumberUtils.toInt(properties.getProperty(PropertyKeyConst.CONFIG_LONG_POLL_TIMEOUT),
|
||||||
Constants.CONFIG_LONG_POLL_TIMEOUT), Constants.MIN_CONFIG_LONG_POLL_TIMEOUT);
|
Constants.CONFIG_LONG_POLL_TIMEOUT), Constants.MIN_CONFIG_LONG_POLL_TIMEOUT);
|
||||||
|
|
||||||
taskPenaltyTime = NumberUtils.toInt(String.valueOf(properties.get(PropertyKeyConst.CONFIG_RETRY_TIME)), Constants.CONFIG_RETRY_TIME);
|
taskPenaltyTime = NumberUtils.toInt(properties.getProperty(PropertyKeyConst.CONFIG_RETRY_TIME), Constants.CONFIG_RETRY_TIME);
|
||||||
|
|
||||||
enableRemoteSyncConfig = Boolean.parseBoolean(properties.getProperty(PropertyKeyConst.ENABLE_REMOTE_SYNC_CONFIG));
|
enableRemoteSyncConfig = Boolean.parseBoolean(properties.getProperty(PropertyKeyConst.ENABLE_REMOTE_SYNC_CONFIG));
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,8 @@ public class ConfigLongPoll_ITCase {
|
|||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
properties.put(PropertyKeyConst.SERVER_ADDR, "127.0.0.1:" + port);
|
properties.put(PropertyKeyConst.SERVER_ADDR, "127.0.0.1:" + port);
|
||||||
properties.put(PropertyKeyConst.CONFIG_LONG_POLL_TIMEOUT, "20000");
|
properties.put(PropertyKeyConst.CONFIG_LONG_POLL_TIMEOUT, "20000");
|
||||||
properties.put(PropertyKeyConst.CONFIG_RETRY_TIME, 3000);
|
properties.put(PropertyKeyConst.CONFIG_RETRY_TIME, "3000");
|
||||||
|
properties.put(PropertyKeyConst.MAX_RETRY, "5");
|
||||||
configService = NacosFactory.createConfigService(properties);
|
configService = NacosFactory.createConfigService(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user