Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
zsq6662003
nacos
提交
eca7a9a4
N
nacos
项目概览
zsq6662003
/
nacos
与 Fork 源项目一致
从无法访问的项目Fork
通知
6
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
nacos
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
eca7a9a4
编写于
4月 03, 2019
作者:
得
得少
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support parsing endpoint rule
上级
acaee3ff
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
104 addition
and
39 deletion
+104
-39
CHANGELOG.md
CHANGELOG.md
+1
-1
api/pom.xml
api/pom.xml
+1
-1
api/src/main/java/com/alibaba/nacos/api/PropertyKeyConst.java
...src/main/java/com/alibaba/nacos/api/PropertyKeyConst.java
+2
-0
client/pom.xml
client/pom.xml
+2
-1
client/src/main/java/com/alibaba/nacos/client/config/NacosConfigService.java
...a/com/alibaba/nacos/client/config/NacosConfigService.java
+5
-1
client/src/main/java/com/alibaba/nacos/client/config/impl/ServerListManager.java
...m/alibaba/nacos/client/config/impl/ServerListManager.java
+21
-13
client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingService.java
...a/com/alibaba/nacos/client/naming/NacosNamingService.java
+16
-12
client/src/main/java/com/alibaba/nacos/client/utils/ParamUtil.java
...c/main/java/com/alibaba/nacos/client/utils/ParamUtil.java
+46
-0
cmdb/pom.xml
cmdb/pom.xml
+1
-1
common/pom.xml
common/pom.xml
+1
-1
config/pom.xml
config/pom.xml
+1
-1
console/pom.xml
console/pom.xml
+1
-1
core/pom.xml
core/pom.xml
+1
-1
distribution/pom.xml
distribution/pom.xml
+1
-1
example/pom.xml
example/pom.xml
+1
-1
naming/pom.xml
naming/pom.xml
+1
-1
pom.xml
pom.xml
+1
-1
test/pom.xml
test/pom.xml
+1
-1
未找到文件。
CHANGELOG.md
浏览文件 @
eca7a9a4
## 1.0.0-RC
2
(Mar 22, 2019)
## 1.0.0-RC
4
(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
...
...
api/pom.xml
浏览文件 @
eca7a9a4
...
...
@@ -16,7 +16,7 @@
<parent>
<groupId>
com.alibaba.nacos
</groupId>
<artifactId>
nacos-all
</artifactId>
<version>
1.0.0-RC
2
</version>
<version>
1.0.0-RC
4
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
api/src/main/java/com/alibaba/nacos/api/PropertyKeyConst.java
浏览文件 @
eca7a9a4
...
...
@@ -22,6 +22,8 @@ package com.alibaba.nacos.api;
*/
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"
;
...
...
client/pom.xml
浏览文件 @
eca7a9a4
...
...
@@ -16,7 +16,7 @@
<parent>
<groupId>
com.alibaba.nacos
</groupId>
<artifactId>
nacos-all
</artifactId>
<version>
1.0.0-RC
2
</version>
<version>
1.0.0-RC
4
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
...
...
@@ -113,6 +113,7 @@
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
...
...
client/src/main/java/com/alibaba/nacos/client/config/NacosConfigService.java
浏览文件 @
eca7a9a4
...
...
@@ -82,7 +82,7 @@ public class NacosConfigService implements ConfigService {
}
private
void
initNamespace
(
Properties
properties
)
{
String
namespaceTmp
=
properties
.
getProperty
(
PropertyKeyConst
.
NAMESPACE
)
;
String
namespaceTmp
=
null
;
namespaceTmp
=
TemplateUtils
.
stringBlankAndThenExecute
(
namespaceTmp
,
new
Callable
<
String
>()
{
@Override
...
...
@@ -98,6 +98,10 @@ public class NacosConfigService implements ConfigService {
return
StringUtils
.
isNotBlank
(
namespace
)
?
namespace
:
""
;
}
});
if
(
StringUtils
.
isBlank
(
namespaceTmp
))
{
namespaceTmp
=
properties
.
getProperty
(
PropertyKeyConst
.
NAMESPACE
);
}
namespace
=
namespaceTmp
;
properties
.
put
(
PropertyKeyConst
.
NAMESPACE
,
namespace
);
}
...
...
client/src/main/java/com/alibaba/nacos/client/config/impl/ServerListManager.java
浏览文件 @
eca7a9a4
...
...
@@ -20,14 +20,16 @@ import com.alibaba.nacos.api.exception.NacosException;
import
com.alibaba.nacos.client.config.impl.EventDispatcher.ServerlistChangeEvent
;
import
com.alibaba.nacos.client.config.impl.HttpSimpleClient.HttpResult
;
import
com.alibaba.nacos.client.config.utils.IOUtils
;
import
com.alibaba.nacos.client.utils.*
;
import
com.alibaba.nacos.client.utils.EnvUtil
;
import
com.alibaba.nacos.client.utils.LogUtils
;
import
com.alibaba.nacos.client.utils.ParamUtil
;
import
com.alibaba.nacos.client.utils.StringUtils
;
import
org.slf4j.Logger
;
import
java.io.IOException
;
import
java.io.StringReader
;
import
java.net.HttpURLConnection
;
import
java.util.*
;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.TimeUnit
;
/**
...
...
@@ -85,7 +87,9 @@ public class ServerListManager {
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"
);
...
...
@@ -108,7 +112,7 @@ public class ServerListManager {
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
))
{
...
...
@@ -152,7 +156,7 @@ public class ServerListManager {
}
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
))
{
...
...
@@ -164,19 +168,22 @@ public class ServerListManager {
}
}
private
String
initEndpoint
(
String
endpointTmp
)
{
private
String
initEndpoint
(
Properties
properties
)
{
String
endpointPortTmp
=
System
.
getenv
(
PropertyKeyConst
.
SystemEnv
.
ALIBABA_ALIWARE_ENDPOINT_PORT
);
if
(
StringUtils
.
isNotBlank
(
endpointPortTmp
))
{
endpointPort
=
Integer
.
parseInt
(
endpointPortTmp
);
}
return
TemplateUtils
.
stringBlankAndThenExecute
(
endpointTmp
,
new
Callable
<
String
>()
{
@Override
public
String
call
()
{
String
endpointUrl
=
System
.
getenv
(
PropertyKeyConst
.
SystemEnv
.
ALIBABA_ALIWARE_ENDPOINT_URL
);
return
StringUtils
.
isNotBlank
(
endpointUrl
)
?
endpointUrl
:
""
;
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
(
endpointPortTmp
);
if
(
StringUtils
.
isNotBlank
(
endpointUrl
))
{
serverAddrsStr
=
""
;
}
});
return
endpointUrl
;
}
return
StringUtils
.
isNotBlank
(
endpointTmp
)
?
endpointTmp
:
""
;
}
public
synchronized
void
start
()
throws
NacosException
{
...
...
@@ -368,6 +375,7 @@ public class ServerListManager {
public
String
addressServerUrl
;
private
String
serverAddrsStr
;
}
/**
...
...
client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingService.java
浏览文件 @
eca7a9a4
...
...
@@ -37,6 +37,7 @@ import com.alibaba.nacos.client.naming.utils.CollectionUtils;
import
com.alibaba.nacos.client.naming.utils.StringUtils
;
import
com.alibaba.nacos.client.naming.utils.UtilAndComs
;
import
com.alibaba.nacos.client.utils.LogUtils
;
import
com.alibaba.nacos.client.utils.ParamUtil
;
import
com.alibaba.nacos.client.utils.TemplateUtils
;
import
org.apache.commons.lang3.BooleanUtils
;
import
org.apache.commons.lang3.math.NumberUtils
;
...
...
@@ -86,9 +87,7 @@ public class NacosNamingService implements NamingService {
}
private
void
init
(
Properties
properties
)
{
serverList
=
properties
.
getProperty
(
PropertyKeyConst
.
SERVER_ADDR
);
initNamespace
(
properties
);
initEndpoint
(
properties
);
initWebRootContext
();
...
...
@@ -160,13 +159,17 @@ public class NacosNamingService implements NamingService {
return
;
}
String
endpointUrl
=
TemplateUtils
.
stringEmptyAndThenExecute
(
properties
.
getProperty
(
PropertyKeyConst
.
ENDPOINT
),
new
Callable
<
String
>()
{
@Override
public
String
call
()
{
return
System
.
getenv
(
PropertyKeyConst
.
SystemEnv
.
ALIBABA_ALIWARE_ENDPOINT_URL
);
//这里通过 dubbo/sca 侧来初始化默认传入的是 true
boolean
isUseEndpointParsingRule
=
Boolean
.
valueOf
(
properties
.
getProperty
(
PropertyKeyConst
.
IS_USE_ENDPOINT_PARSING_RULE
,
ParamUtil
.
USE_ENDPOINT_PARSING_RULE_DEFAULT_VALUE
));
String
endpointUrl
;
if
(
isUseEndpointParsingRule
)
{
endpointUrl
=
ParamUtil
.
parsingEndpointRule
(
properties
.
getProperty
(
PropertyKeyConst
.
ENDPOINT
));
if
(
com
.
alibaba
.
nacos
.
client
.
utils
.
StringUtils
.
isNotBlank
(
endpointUrl
))
{
serverList
=
""
;
}
});
}
else
{
endpointUrl
=
properties
.
getProperty
(
PropertyKeyConst
.
ENDPOINT
);
}
if
(
com
.
alibaba
.
nacos
.
client
.
utils
.
StringUtils
.
isBlank
(
endpointUrl
))
{
return
;
...
...
@@ -179,6 +182,7 @@ public class NacosNamingService implements NamingService {
return
System
.
getenv
(
PropertyKeyConst
.
SystemEnv
.
ALIBABA_ALIWARE_ENDPOINT_PORT
);
}
});
endpointPort
=
TemplateUtils
.
stringEmptyAndThenExecute
(
endpointPort
,
new
Callable
<
String
>()
{
@Override
public
String
call
()
{
...
...
@@ -192,10 +196,6 @@ public class NacosNamingService implements NamingService {
private
void
initNamespace
(
Properties
properties
)
{
String
tmpNamespace
=
null
;
if
(
properties
!=
null
)
{
tmpNamespace
=
properties
.
getProperty
(
PropertyKeyConst
.
NAMESPACE
);
}
tmpNamespace
=
TemplateUtils
.
stringEmptyAndThenExecute
(
tmpNamespace
,
new
Callable
<
String
>()
{
@Override
public
String
call
()
{
...
...
@@ -224,6 +224,10 @@ public class NacosNamingService implements NamingService {
}
});
if
(
StringUtils
.
isEmpty
(
tmpNamespace
)
&&
properties
!=
null
)
{
tmpNamespace
=
properties
.
getProperty
(
PropertyKeyConst
.
NAMESPACE
);
}
tmpNamespace
=
TemplateUtils
.
stringEmptyAndThenExecute
(
tmpNamespace
,
new
Callable
<
String
>()
{
@Override
public
String
call
()
{
...
...
client/src/main/java/com/alibaba/nacos/client/utils/ParamUtil.java
浏览文件 @
eca7a9a4
...
...
@@ -15,11 +15,13 @@
*/
package
com.alibaba.nacos.client.utils
;
import
com.alibaba.nacos.api.PropertyKeyConst
;
import
com.alibaba.nacos.client.config.impl.HttpSimpleClient
;
import
org.slf4j.Logger
;
import
java.io.InputStream
;
import
java.util.Properties
;
import
java.util.regex.Pattern
;
/**
* manage param tool
...
...
@@ -27,8 +29,12 @@ import java.util.Properties;
* @author nacos
*/
public
class
ParamUtil
{
private
final
static
Logger
LOGGER
=
LogUtils
.
logger
(
ParamUtil
.
class
);
public
final
static
String
USE_ENDPOINT_PARSING_RULE_DEFAULT_VALUE
=
"false"
;
private
static
final
Pattern
PATTERN
=
Pattern
.
compile
(
"\\$\\{[^}]+\\}"
);
private
static
String
defaultContextPath
=
"nacos"
;
private
static
String
defaultNodesPath
=
"serverlist"
;
private
static
String
appKey
;
...
...
@@ -143,4 +149,44 @@ public class ParamUtil {
ParamUtil
.
defaultNodesPath
=
defaultNodesPath
;
}
public
static
String
parsingEndpointRule
(
String
endpointUrl
)
{
// 配置文件中输入的话,以 ENV 中的优先,
if
(
endpointUrl
==
null
||
!
PATTERN
.
matcher
(
endpointUrl
).
find
())
{
// skip retrieve from system property and retrieve directly from system env
String
endpointUrlSource
=
System
.
getenv
(
PropertyKeyConst
.
SystemEnv
.
ALIBABA_ALIWARE_ENDPOINT_URL
);
if
(
com
.
alibaba
.
nacos
.
client
.
utils
.
StringUtils
.
isNotBlank
(
endpointUrlSource
))
{
endpointUrl
=
endpointUrlSource
;
}
return
StringUtils
.
isNotBlank
(
endpointUrl
)
?
endpointUrl
:
""
;
}
endpointUrl
=
endpointUrl
.
substring
(
endpointUrl
.
indexOf
(
"${"
)
+
2
,
endpointUrl
.
lastIndexOf
(
"}"
));
int
defStartOf
=
endpointUrl
.
indexOf
(
":"
);
String
defaultEndpointUrl
=
null
;
if
(
defStartOf
!=
-
1
)
{
defaultEndpointUrl
=
endpointUrl
.
substring
(
defStartOf
+
1
);
endpointUrl
=
endpointUrl
.
substring
(
0
,
defStartOf
);
}
String
endpointUrlSource
=
System
.
getProperty
(
endpointUrl
,
System
.
getenv
(
endpointUrl
));
if
(
com
.
alibaba
.
nacos
.
client
.
utils
.
StringUtils
.
isBlank
(
endpointUrlSource
))
{
endpointUrlSource
=
System
.
getenv
(
PropertyKeyConst
.
SystemEnv
.
ALIBABA_ALIWARE_ENDPOINT_URL
);
}
if
(
com
.
alibaba
.
nacos
.
client
.
utils
.
StringUtils
.
isBlank
(
endpointUrlSource
))
{
if
(
com
.
alibaba
.
nacos
.
client
.
utils
.
StringUtils
.
isNotBlank
(
defaultEndpointUrl
))
{
endpointUrl
=
defaultEndpointUrl
;
}
}
else
{
endpointUrl
=
endpointUrlSource
;
}
return
StringUtils
.
isNotBlank
(
endpointUrl
)
?
endpointUrl
:
""
;
}
}
cmdb/pom.xml
浏览文件 @
eca7a9a4
...
...
@@ -18,7 +18,7 @@
<parent>
<artifactId>
nacos-all
</artifactId>
<groupId>
com.alibaba.nacos
</groupId>
<version>
1.0.0-RC
2
</version>
<version>
1.0.0-RC
4
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
common/pom.xml
浏览文件 @
eca7a9a4
...
...
@@ -18,7 +18,7 @@
<parent>
<groupId>
com.alibaba.nacos
</groupId>
<artifactId>
nacos-all
</artifactId>
<version>
1.0.0-RC
2
</version>
<version>
1.0.0-RC
4
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
config/pom.xml
浏览文件 @
eca7a9a4
...
...
@@ -17,7 +17,7 @@
<parent>
<groupId>
com.alibaba.nacos
</groupId>
<artifactId>
nacos-all
</artifactId>
<version>
1.0.0-RC
2
</version>
<version>
1.0.0-RC
4
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
console/pom.xml
浏览文件 @
eca7a9a4
...
...
@@ -18,7 +18,7 @@
<parent>
<groupId>
com.alibaba.nacos
</groupId>
<artifactId>
nacos-all
</artifactId>
<version>
1.0.0-RC
2
</version>
<version>
1.0.0-RC
4
</version>
</parent>
<artifactId>
nacos-console
</artifactId>
<!--<packaging>war</packaging>-->
...
...
core/pom.xml
浏览文件 @
eca7a9a4
...
...
@@ -18,7 +18,7 @@
<parent>
<groupId>
com.alibaba.nacos
</groupId>
<artifactId>
nacos-all
</artifactId>
<version>
1.0.0-RC
2
</version>
<version>
1.0.0-RC
4
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
...
...
distribution/pom.xml
浏览文件 @
eca7a9a4
...
...
@@ -18,7 +18,7 @@
<parent>
<groupId>
com.alibaba.nacos
</groupId>
<artifactId>
nacos-all
</artifactId>
<version>
1.0.0-RC
2
</version>
<version>
1.0.0-RC
4
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
...
...
example/pom.xml
浏览文件 @
eca7a9a4
...
...
@@ -18,7 +18,7 @@
<parent>
<groupId>
com.alibaba.nacos
</groupId>
<artifactId>
nacos-all
</artifactId>
<version>
1.0.0-RC
2
</version>
<version>
1.0.0-RC
4
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
...
...
naming/pom.xml
浏览文件 @
eca7a9a4
...
...
@@ -18,7 +18,7 @@
<parent>
<groupId>
com.alibaba.nacos
</groupId>
<artifactId>
nacos-all
</artifactId>
<version>
1.0.0-RC
2
</version>
<version>
1.0.0-RC
4
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
...
...
pom.xml
浏览文件 @
eca7a9a4
...
...
@@ -21,7 +21,7 @@
<inceptionYear>
2018
</inceptionYear>
<groupId>
com.alibaba.nacos
</groupId>
<artifactId>
nacos-all
</artifactId>
<version>
1.0.0-RC
2
</version>
<version>
1.0.0-RC
4
</version>
<packaging>
pom
</packaging>
<name>
Alibaba NACOS ${project.version}
</name>
...
...
test/pom.xml
浏览文件 @
eca7a9a4
...
...
@@ -17,7 +17,7 @@
<parent>
<groupId>
com.alibaba.nacos
</groupId>
<artifactId>
nacos-all
</artifactId>
<version>
1.0.0-RC
2
</version>
<version>
1.0.0-RC
4
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录