Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
57aedb80
S
SkyWalking
项目概览
apache
/
SkyWalking
上一次同步 1 年多
通知
302
Star
21345
Fork
6091
代码
文件
提交
分支
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,体验更适合开发者的 AI 搜索 >>
提交
57aedb80
编写于
6月 07, 2019
作者:
K
kezhenxu94
提交者:
wu-sheng
6月 07, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor ConfigWatcherRegister to only read interested configs. fixes #2834 (#2835)
上级
a763f8a8
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
17 addition
and
6 deletion
+17
-6
oap-server/server-configuration/configuration-api/src/main/java/org/apache/skywalking/oap/server/configuration/api/ConfigWatcherRegister.java
...g/oap/server/configuration/api/ConfigWatcherRegister.java
+7
-3
oap-server/server-configuration/configuration-api/src/test/java/org/apache/skywalking/oap/server/configuration/api/ConfigWatcherRegisterTest.java
...p/server/configuration/api/ConfigWatcherRegisterTest.java
+3
-1
oap-server/server-configuration/grpc-configuration-sync/src/main/java/org/apache/skywalking/oap/server/configuration/grpc/GRPCConfigWatcherRegister.java
.../server/configuration/grpc/GRPCConfigWatcherRegister.java
+7
-2
未找到文件。
oap-server/server-configuration/configuration-api/src/main/java/org/apache/skywalking/oap/server/configuration/api/ConfigWatcherRegister.java
浏览文件 @
57aedb80
...
...
@@ -64,12 +64,12 @@ public abstract class ConfigWatcherRegister implements DynamicConfigurationServi
logger
.
info
(
"Current configurations after the bootstrap sync."
+
LINE_SEPARATOR
+
register
.
toString
());
Executors
.
newSingleThreadScheduledExecutor
().
scheduleAtFixedRate
(
new
RunnableWithExceptionProtection
(
()
->
configSync
()
,
new
RunnableWithExceptionProtection
(
this
::
configSync
,
t
->
logger
.
error
(
"Sync config center error."
,
t
)),
syncPeriod
,
syncPeriod
,
TimeUnit
.
SECONDS
);
}
void
configSync
()
{
ConfigTable
configTable
=
readConfig
();
ConfigTable
configTable
=
readConfig
(
register
.
keys
()
);
configTable
.
getItems
().
forEach
(
item
->
{
String
itemName
=
item
.
getName
();
...
...
@@ -99,7 +99,7 @@ public abstract class ConfigWatcherRegister implements DynamicConfigurationServi
logger
.
trace
(
"Current configurations after the sync."
+
LINE_SEPARATOR
+
register
.
toString
());
}
public
abstract
ConfigTable
readConfig
();
public
abstract
ConfigTable
readConfig
(
Set
<
String
>
keys
);
public
class
Register
{
private
Map
<
String
,
WatcherHolder
>
register
=
new
HashMap
<>();
...
...
@@ -116,6 +116,10 @@ public abstract class ConfigWatcherRegister implements DynamicConfigurationServi
return
register
.
get
(
name
);
}
public
Set
<
String
>
keys
()
{
return
register
.
keySet
();
}
@Override
public
String
toString
()
{
StringBuilder
registerTableDescription
=
new
StringBuilder
();
registerTableDescription
.
append
(
"Following dynamic config items are available."
).
append
(
LINE_SEPARATOR
);
...
...
oap-server/server-configuration/configuration-api/src/test/java/org/apache/skywalking/oap/server/configuration/api/ConfigWatcherRegisterTest.java
浏览文件 @
57aedb80
...
...
@@ -22,6 +22,8 @@ import org.apache.skywalking.oap.server.library.module.*;
import
org.junit.*
;
import
org.powermock.reflect.Whitebox
;
import
java.util.Set
;
/**
* @author wusheng
*/
...
...
@@ -80,7 +82,7 @@ public class ConfigWatcherRegisterTest {
public
static
class
MockConfigWatcherRegister
extends
ConfigWatcherRegister
{
@Override
public
ConfigTable
readConfig
()
{
@Override
public
ConfigTable
readConfig
(
Set
<
String
>
keys
)
{
ConfigTable
.
ConfigItem
item1
=
new
ConfigTable
.
ConfigItem
(
"module.provider.prop1"
,
"abc"
);
ConfigTable
.
ConfigItem
item2
=
new
ConfigTable
.
ConfigItem
(
"MockModule.provider.prop2"
,
"abc2"
);
...
...
oap-server/server-configuration/grpc-configuration-sync/src/main/java/org/apache/skywalking/oap/server/configuration/grpc/GRPCConfigWatcherRegister.java
浏览文件 @
57aedb80
...
...
@@ -23,6 +23,8 @@ import org.apache.skywalking.oap.server.configuration.api.*;
import
org.apache.skywalking.oap.server.configuration.service.*
;
import
org.slf4j.*
;
import
java.util.Set
;
/**
* @author wusheng
*/
...
...
@@ -38,12 +40,15 @@ public class GRPCConfigWatcherRegister extends ConfigWatcherRegister {
stub
=
ConfigurationServiceGrpc
.
newBlockingStub
(
NettyChannelBuilder
.
forAddress
(
settings
.
getHost
(),
settings
.
getPort
()).
usePlaintext
().
build
());
}
@Override
public
ConfigTable
readConfig
()
{
@Override
public
ConfigTable
readConfig
(
Set
<
String
>
keys
)
{
ConfigTable
table
=
new
ConfigTable
();
try
{
ConfigurationResponse
response
=
stub
.
call
(
ConfigurationRequest
.
newBuilder
().
setClusterName
(
settings
.
getClusterName
()).
build
());
response
.
getConfigTableList
().
forEach
(
config
->
{
table
.
add
(
new
ConfigTable
.
ConfigItem
(
config
.
getName
(),
config
.
getValue
()));
final
String
name
=
config
.
getName
();
if
(
keys
.
contains
(
name
))
{
table
.
add
(
new
ConfigTable
.
ConfigItem
(
name
,
config
.
getValue
()));
}
});
}
catch
(
Exception
e
)
{
logger
.
error
(
"Remote config center ["
+
settings
+
"] is not available."
,
e
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录