Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gdyjdao
SkyWalking
提交
5d7da1ae
S
SkyWalking
项目概览
gdyjdao
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyWalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
5d7da1ae
编写于
7月 29, 2020
作者:
A
Ax1an
提交者:
GitHub
7月 29, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add internalComHost and internalComPort config to Nacos. (#5192)
上级
15b30009
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
82 addition
and
1 deletion
+82
-1
docs/en/setup/backend/backend-cluster.md
docs/en/setup/backend/backend-cluster.md
+13
-1
docs/en/setup/backend/configuration-vocabulary.md
docs/en/setup/backend/configuration-vocabulary.md
+2
-0
oap-server/server-cluster-plugin/cluster-nacos-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/ClusterModuleNacosConfig.java
...server/cluster/plugin/nacos/ClusterModuleNacosConfig.java
+6
-0
oap-server/server-cluster-plugin/cluster-nacos-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/NacosCoordinator.java
...ing/oap/server/cluster/plugin/nacos/NacosCoordinator.java
+9
-0
oap-server/server-cluster-plugin/cluster-nacos-plugin/src/test/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/ITClusterModuleNacosProviderFunctionalTest.java
...gin/nacos/ITClusterModuleNacosProviderFunctionalTest.java
+43
-0
oap-server/server-cluster-plugin/cluster-nacos-plugin/src/test/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/NacosCoordinatorTest.java
...oap/server/cluster/plugin/nacos/NacosCoordinatorTest.java
+9
-0
未找到文件。
docs/en/setup/backend/backend-cluster.md
浏览文件 @
5d7da1ae
...
...
@@ -92,6 +92,12 @@ cluster:
# other configurations
```
Same as Zookeeper coordinator,
in some cases, oap default gRPC host and port in core are not suitable for internal communication among the oap nodes.
The following setting are provided to set the host and port manually, based on your own LAN env.
-
internalComHost, the host registered and other oap node use this to communicate with current node.
-
internalComPort, the port registered and other oap node use this to communicate with current node.
## Nacos
Set the
**cluster/selector**
to
**nacos**
in the yml to enable.
...
...
@@ -99,4 +105,10 @@ Set the **cluster/selector** to **nacos** in the yml to enable.
cluster
:
selector
:
${SW_CLUSTER:nacos}
# other configurations
```
\ No newline at end of file
```
Same as Zookeeper coordinator,
in some cases, oap default gRPC host and port in core are not suitable for internal communication among the oap nodes.
The following setting are provided to set the host and port manually, based on your own LAN env.
-
internalComHost, the host registered and other oap node use this to communicate with current node.
-
internalComPort, the port registered and other oap node use this to communicate with current node.
\ No newline at end of file
docs/en/setup/backend/configuration-vocabulary.md
浏览文件 @
5d7da1ae
...
...
@@ -63,6 +63,8 @@ core|default|role|Option values, `Mixed/Receiver/Aggregator`. **Receiver** mode
| - | Nacos| serviceName| Service name used for SkyWalking cluster. |SW_SERVICE_NAME|SkyWalking_OAP_Cluster|
| - | - | hostPort| hosts and ports used of Nacos cluster.| SW_CLUSTER_NACOS_HOST_PORT|localhost:8848|
| - | - | namespace| Namespace used by SkyWalking node coordination.| SW_CLUSTER_NACOS_NAMESPACE|public|
| - | - | internalComHost| The hostname registered in the Nacos for the internal communication of OAP cluster.| - | -|
| - | - | internalComPort| The port registered in the Nacos for the internal communication of OAP cluster.| - | -1|
| storage|elasticsearch| - | ElasticSearch 6 storage implementation | - | - |
| - | - | nameSpace | Prefix of indexes created and used by SkyWalking. | SW_NAMESPACE | - |
| - | - | clusterNodes | ElasticSearch cluster nodes for client connection.| SW_STORAGE_ES_CLUSTER_NODES |localhost|
...
...
oap-server/server-cluster-plugin/cluster-nacos-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/ClusterModuleNacosConfig.java
浏览文件 @
5d7da1ae
...
...
@@ -32,4 +32,10 @@ public class ClusterModuleNacosConfig extends ModuleConfig {
@Setter
@Getter
private
String
namespace
=
"public"
;
@Setter
@Getter
private
String
internalComHost
;
@Setter
@Getter
private
int
internalComPort
=
-
1
;
}
oap-server/server-cluster-plugin/cluster-nacos-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/NacosCoordinator.java
浏览文件 @
5d7da1ae
...
...
@@ -23,6 +23,8 @@ import com.alibaba.nacos.api.naming.NamingService;
import
com.alibaba.nacos.api.naming.pojo.Instance
;
import
java.util.ArrayList
;
import
java.util.List
;
import
com.google.common.base.Strings
;
import
org.apache.skywalking.oap.server.core.cluster.ClusterNodesQuery
;
import
org.apache.skywalking.oap.server.core.cluster.ClusterRegister
;
import
org.apache.skywalking.oap.server.core.cluster.RemoteInstance
;
...
...
@@ -65,6 +67,9 @@ public class NacosCoordinator implements ClusterRegister, ClusterNodesQuery {
@Override
public
void
registerRemote
(
RemoteInstance
remoteInstance
)
throws
ServiceRegisterException
{
if
(
needUsingInternalAddr
())
{
remoteInstance
=
new
RemoteInstance
(
new
Address
(
config
.
getInternalComHost
(),
config
.
getInternalComPort
(),
true
));
}
String
host
=
remoteInstance
.
getAddress
().
getHost
();
int
port
=
remoteInstance
.
getAddress
().
getPort
();
try
{
...
...
@@ -75,4 +80,8 @@ public class NacosCoordinator implements ClusterRegister, ClusterNodesQuery {
this
.
selfAddress
=
remoteInstance
.
getAddress
();
TelemetryRelatedContext
.
INSTANCE
.
setId
(
selfAddress
.
toString
());
}
private
boolean
needUsingInternalAddr
()
{
return
!
Strings
.
isNullOrEmpty
(
config
.
getInternalComHost
())
&&
config
.
getInternalComPort
()
>
0
;
}
}
oap-server/server-cluster-plugin/cluster-nacos-plugin/src/test/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/ITClusterModuleNacosProviderFunctionalTest.java
浏览文件 @
5d7da1ae
...
...
@@ -21,6 +21,7 @@ package org.apache.skywalking.oap.server.cluster.plugin.nacos;
import
com.alibaba.nacos.api.naming.NamingService
;
import
java.util.Collections
;
import
java.util.List
;
import
org.apache.skywalking.apm.util.StringUtil
;
import
org.apache.skywalking.oap.server.core.cluster.ClusterNodesQuery
;
import
org.apache.skywalking.oap.server.core.cluster.ClusterRegister
;
...
...
@@ -62,6 +63,25 @@ public class ITClusterModuleNacosProviderFunctionalTest {
assertTrue
(
queryAddress
.
isSelf
());
}
@Test
public
void
registerRemoteOfInternal
()
throws
Exception
{
final
String
serviceName
=
"register_remote_internal"
;
ModuleProvider
provider
=
createProvider
(
serviceName
,
"127.0.1.2"
,
1000
);
Address
selfAddress
=
new
Address
(
"127.0.0.2"
,
1000
,
true
);
RemoteInstance
instance
=
new
RemoteInstance
(
selfAddress
);
getClusterRegister
(
provider
).
registerRemote
(
instance
);
List
<
RemoteInstance
>
remoteInstances
=
queryRemoteNodes
(
provider
,
1
);
ClusterModuleNacosConfig
config
=
(
ClusterModuleNacosConfig
)
provider
.
createConfigBeanIfAbsent
();
assertEquals
(
1
,
remoteInstances
.
size
());
Address
queryAddress
=
remoteInstances
.
get
(
0
).
getAddress
();
assertEquals
(
config
.
getInternalComHost
(),
queryAddress
.
getHost
());
assertEquals
(
config
.
getInternalComPort
(),
queryAddress
.
getPort
());
assertTrue
(
queryAddress
.
isSelf
());
}
@Test
public
void
registerRemoteOfReceiver
()
throws
Exception
{
final
String
serviceName
=
"register_remote_receiver"
;
...
...
@@ -151,6 +171,29 @@ public class ITClusterModuleNacosProviderFunctionalTest {
return
provider
;
}
private
ClusterModuleNacosProvider
createProvider
(
String
serviceName
,
String
internalComHost
,
int
internalComPort
)
throws
Exception
{
ClusterModuleNacosProvider
provider
=
new
ClusterModuleNacosProvider
();
ClusterModuleNacosConfig
config
=
(
ClusterModuleNacosConfig
)
provider
.
createConfigBeanIfAbsent
();
config
.
setHostPort
(
nacosAddress
);
config
.
setServiceName
(
serviceName
);
if
(!
StringUtil
.
isEmpty
(
internalComHost
))
{
config
.
setInternalComHost
(
internalComHost
);
}
if
(
internalComPort
>
0
)
{
config
.
setInternalComPort
(
internalComPort
);
}
provider
.
prepare
();
provider
.
start
();
provider
.
notifyAfterCompleted
();
return
provider
;
}
private
ClusterRegister
getClusterRegister
(
ModuleProvider
provider
)
{
return
provider
.
getService
(
ClusterRegister
.
class
);
}
...
...
oap-server/server-cluster-plugin/cluster-nacos-plugin/src/test/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/NacosCoordinatorTest.java
浏览文件 @
5d7da1ae
...
...
@@ -45,6 +45,8 @@ public class NacosCoordinatorTest {
private
Address
remoteAddress
=
new
Address
(
"10.0.0.1"
,
1000
,
false
);
private
Address
selfRemoteAddress
=
new
Address
(
"10.0.0.2"
,
1001
,
true
);
private
Address
internalAddress
=
new
Address
(
"10.0.0.3"
,
1002
,
false
);
private
static
final
String
SERVICE_NAME
=
"test-service"
;
@Before
...
...
@@ -93,6 +95,13 @@ public class NacosCoordinatorTest {
registerRemote
(
selfRemoteAddress
);
}
@Test
public
void
registerRemoteUsingInternal
()
throws
NacosException
{
nacosConfig
.
setInternalComHost
(
internalAddress
.
getHost
());
nacosConfig
.
setInternalComPort
(
internalAddress
.
getPort
());
registerRemote
(
internalAddress
);
}
private
void
validate
(
Address
originArress
,
RemoteInstance
instance
)
{
Address
instanceAddress
=
instance
.
getAddress
();
assertEquals
(
originArress
.
getHost
(),
instanceAddress
.
getHost
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录