fix(nacos-api/nacos-client): Fix setting parameter acquisition problem and nacos properties add new

This commit is contained in:
chuntaojun 2019-06-14 17:06:50 +08:00
parent ac846dfe08
commit 75868623b2
4 changed files with 19 additions and 19 deletions

View File

@ -132,19 +132,19 @@ public @interface NacosProperties {
String ENCODE_PLACEHOLDER = "${" + PREFIX + ENCODE + ":UTF-8}";
/**
* The placeholder of {@link NacosProperties#CONFIG_LONG_POLL_TIMEOUT config.long-poll.timeout}, the value is <code>"${nacos.config.long-poll.timeout:30000}"</code>
* The placeholder of {@link NacosProperties#CONFIG_LONG_POLL_TIMEOUT config.long-poll.timeout}, the value is <code>"${nacos.config.long-poll.timeout:}"</code>
*/
String CONFIG_LONG_POLL_TIMEOUT_PLACEHOLDER = "${" + PREFIX + CONFIG_LONG_POLL_TIMEOUT + ":30000}";
String CONFIG_LONG_POLL_TIMEOUT_PLACEHOLDER = "${" + PREFIX + CONFIG_LONG_POLL_TIMEOUT + ":}";
/**
* The placeholder of {@link NacosProperties#CONFIG_RETRY_TIME config.retry.time}, the value is <code>"${nacos.config.retry.time:2000}"</code>
* The placeholder of {@link NacosProperties#CONFIG_RETRY_TIME config.retry.time}, the value is <code>"${nacos.config.retry.time:}"</code>
*/
String CONFIG_RETRY_TIME_PLACEHOLDER = "${" + PREFIX + CONFIG_RETRY_TIME + ":2000}";
String CONFIG_RETRY_TIME_PLACEHOLDER = "${" + PREFIX + CONFIG_RETRY_TIME + ":}";
/**
* The placeholder of {@link NacosProperties#MAX_RETRY maxRetry}, the value is <code>"${nacos.maxRetry:3}"</code>
* The placeholder of {@link NacosProperties#MAX_RETRY maxRetry}, the value is <code>"${nacos.maxRetry:}"</code>
*/
String MAX_RETRY_PLACEHOLDER = "${" + PREFIX + MAX_RETRY + ":3}";
String MAX_RETRY_PLACEHOLDER = "${" + PREFIX + MAX_RETRY + ":}";
/**
* The property of "endpoint"
@ -213,7 +213,7 @@ public @interface NacosProperties {
/**
* The property of "config.long-poll.timeout"
*
* @return "30000ms" as default value
* @return empty as default value
* @see #CONFIG_LONG_POLL_TIMEOUT_PLACEHOLDER
*/
String configLongPollTimeout() default CONFIG_LONG_POLL_TIMEOUT_PLACEHOLDER;
@ -221,7 +221,7 @@ public @interface NacosProperties {
/**
* The property of "config.retry.time"
*
* @return "2000ms" as default value
* @return empty as default value
* @see #CONFIG_RETRY_TIME_PLACEHOLDER
*/
String configRetryTime() default CONFIG_RETRY_TIME_PLACEHOLDER;
@ -229,7 +229,7 @@ public @interface NacosProperties {
/**
* The property of "maxRetry"
*
* @return "3" as default value
* @return empty as default value
* @see #MAX_RETRY
*/
String maxRetry() default MAX_RETRY_PLACEHOLDER;

View File

@ -91,9 +91,9 @@ public class ServerHttpAgent implements HttpAgent {
return result;
}
} catch (ConnectException ce) {
LOGGER.error("[NACOS ConnectException httpGet] currentServerAddr:{}", serverListMgr.getCurrentServerAddr());
LOGGER.error("[NACOS ConnectException httpDelete] currentServerAddr:{}, err : {}", serverListMgr.getCurrentServerAddr(), ce.getMessage());
} catch (SocketTimeoutException stoe) {
LOGGER.error("[NACOS SocketTimeoutException httpGet] currentServerAddr:{}", serverListMgr.getCurrentServerAddr());
LOGGER.error("[NACOS SocketTimeoutException httpDelete] currentServerAddr:{} err : {}", serverListMgr.getCurrentServerAddr(), stoe.getMessage());
} catch (IOException ioe) {
LOGGER.error("[NACOS IOException httpGet] currentServerAddr: " + serverListMgr.getCurrentServerAddr(), ioe);
throw ioe;
@ -146,10 +146,9 @@ public class ServerHttpAgent implements HttpAgent {
return result;
}
} catch (ConnectException ce) {
LOGGER.error("[NACOS ConnectException httpPost] currentServerAddr: {}", currentServerAddr);
LOGGER.error("[NACOS ConnectException httpPost] currentServerAddr: {}, err : {}", currentServerAddr, ce.getMessage());
} catch (SocketTimeoutException stoe) {
LOGGER.error("[NACOS SocketTimeoutException httpPost] currentServerAddr: {} err : {}",
currentServerAddr, stoe.getMessage());
LOGGER.error("[NACOS SocketTimeoutException httpPost] currentServerAddr: {} err : {}", currentServerAddr, stoe.getMessage());
} catch (IOException ioe) {
LOGGER.error("[NACOS IOException httpPost] currentServerAddr: " + currentServerAddr, ioe);
throw ioe;
@ -200,9 +199,9 @@ public class ServerHttpAgent implements HttpAgent {
return result;
}
} 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) {
LOGGER.error("[NACOS SocketTimeoutException httpDelete] currentServerAddr:{}", serverListMgr.getCurrentServerAddr());
LOGGER.error("[NACOS SocketTimeoutException httpDelete] currentServerAddr:{} err : {}", serverListMgr.getCurrentServerAddr(), stoe.getMessage());
} catch (IOException ioe) {
LOGGER.error("[NACOS IOException httpDelete] currentServerAddr: " + serverListMgr.getCurrentServerAddr(), ioe);
throw ioe;

View File

@ -457,10 +457,10 @@ public class ClientWorker {
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);
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);
}
class LongPollingRunnable implements Runnable {

View File

@ -51,7 +51,8 @@ public class ConfigLongPoll_ITCase {
Properties properties = new Properties();
properties.put(PropertyKeyConst.SERVER_ADDR, "127.0.0.1:" + port);
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);
}