Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gdyjdao
SkyWalking
提交
224ef659
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,发现更多精彩内容 >>
提交
224ef659
编写于
9月 27, 2017
作者:
P
peng-yongsheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed #438, catch null point exception when collector start up with standalone mode.
上级
02f939a4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
79 addition
and
2 deletion
+79
-2
apm-collector/apm-collector-cluster/src/main/java/org/skywalking/apm/collector/cluster/standalone/ClusterStandaloneDataMonitor.java
...ctor/cluster/standalone/ClusterStandaloneDataMonitor.java
+71
-0
apm-collector/apm-collector-cluster/src/main/java/org/skywalking/apm/collector/cluster/standalone/ClusterStandaloneModuleDefine.java
...tor/cluster/standalone/ClusterStandaloneModuleDefine.java
+8
-2
未找到文件。
apm-collector/apm-collector-cluster/src/main/java/org/skywalking/apm/collector/cluster/standalone/ClusterStandaloneDataMonitor.java
0 → 100644
浏览文件 @
224ef659
package
org.skywalking.apm.collector.cluster.standalone
;
import
java.util.Iterator
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
org.skywalking.apm.collector.client.h2.H2Client
;
import
org.skywalking.apm.collector.client.zookeeper.util.PathUtils
;
import
org.skywalking.apm.collector.core.CollectorException
;
import
org.skywalking.apm.collector.core.client.Client
;
import
org.skywalking.apm.collector.core.client.ClientException
;
import
org.skywalking.apm.collector.core.client.DataMonitor
;
import
org.skywalking.apm.collector.core.cluster.ClusterDataListener
;
import
org.skywalking.apm.collector.core.module.ModuleRegistration
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author pengys5
*/
public
class
ClusterStandaloneDataMonitor
implements
DataMonitor
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ClusterStandaloneDataMonitor
.
class
);
private
H2Client
client
;
private
Map
<
String
,
ClusterDataListener
>
listeners
;
private
Map
<
String
,
ModuleRegistration
>
registrations
;
public
ClusterStandaloneDataMonitor
()
{
listeners
=
new
LinkedHashMap
<>();
registrations
=
new
LinkedHashMap
<>();
}
@Override
public
void
setClient
(
Client
client
)
{
this
.
client
=
(
H2Client
)
client
;
}
@Override
public
void
addListener
(
ClusterDataListener
listener
,
ModuleRegistration
registration
)
throws
ClientException
{
String
path
=
PathUtils
.
convertKey2Path
(
listener
.
path
());
logger
.
info
(
"listener path: {}"
,
path
);
listeners
.
put
(
path
,
listener
);
registrations
.
put
(
path
,
registration
);
}
@Override
public
ClusterDataListener
getListener
(
String
path
)
{
path
=
PathUtils
.
convertKey2Path
(
path
);
return
listeners
.
get
(
path
);
}
@Override
public
void
createPath
(
String
path
)
throws
ClientException
{
}
@Override
public
void
setData
(
String
path
,
String
value
)
throws
ClientException
{
if
(
listeners
.
containsKey
(
path
))
{
listeners
.
get
(
path
).
addAddress
(
value
);
listeners
.
get
(
path
).
serverJoinNotify
(
value
);
}
}
@Override
public
void
start
()
throws
CollectorException
{
Iterator
<
Map
.
Entry
<
String
,
ModuleRegistration
>>
entryIterator
=
registrations
.
entrySet
().
iterator
();
while
(
entryIterator
.
hasNext
())
{
Map
.
Entry
<
String
,
ModuleRegistration
>
next
=
entryIterator
.
next
();
ModuleRegistration
.
Value
value
=
next
.
getValue
().
buildValue
();
String
contextPath
=
value
.
getContextPath
()
==
null
?
""
:
value
.
getContextPath
();
setData
(
next
.
getKey
(),
value
.
getHostPort
()
+
contextPath
);
}
}
}
apm-collector/apm-collector-cluster/src/main/java/org/skywalking/apm/collector/cluster/standalone/ClusterStandaloneModuleDefine.java
浏览文件 @
224ef659
...
...
@@ -15,6 +15,12 @@ public class ClusterStandaloneModuleDefine extends ClusterModuleDefine {
public
static
final
String
MODULE_NAME
=
"standalone"
;
private
final
ClusterStandaloneDataMonitor
dataMonitor
;
public
ClusterStandaloneModuleDefine
()
{
this
.
dataMonitor
=
new
ClusterStandaloneDataMonitor
();
}
@Override
public
String
group
()
{
return
ClusterModuleGroupDefine
.
GROUP_NAME
;
}
...
...
@@ -32,7 +38,7 @@ public class ClusterStandaloneModuleDefine extends ClusterModuleDefine {
}
@Override
public
DataMonitor
dataMonitor
()
{
return
null
;
return
dataMonitor
;
}
@Override
protected
Client
createClient
()
{
...
...
@@ -40,6 +46,6 @@ public class ClusterStandaloneModuleDefine extends ClusterModuleDefine {
}
@Override
public
ClusterModuleRegistrationReader
registrationReader
()
{
return
n
ull
;
return
n
ew
ClusterStandaloneModuleRegistrationReader
(
dataMonitor
)
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录