Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
阿信在这里
SkyWalking
提交
696090b0
S
SkyWalking
项目概览
阿信在这里
/
SkyWalking
与 Fork 源项目一致
Fork自
山不在高_有仙则灵 / 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,发现更多精彩内容 >>
提交
696090b0
编写于
2月 27, 2017
作者:
Z
zhangxin
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'upstream/feature/3.0' into feature/3.0
上级
488e8a9e
70e1b266
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
208 addition
and
198 deletion
+208
-198
skywalking-commons/pom.xml
skywalking-commons/pom.xml
+0
-1
skywalking-commons/skywalking-health-report/pom.xml
skywalking-commons/skywalking-health-report/pom.xml
+0
-23
skywalking-commons/skywalking-health-report/src/main/java/com/a/eye/skywalking/health/report/HealthCollector.java
...a/com/a/eye/skywalking/health/report/HealthCollector.java
+0
-79
skywalking-commons/skywalking-health-report/src/main/java/com/a/eye/skywalking/health/report/HeathReading.java
...java/com/a/eye/skywalking/health/report/HeathReading.java
+0
-83
skywalking-commons/skywalking-logging/skywalking-logging-api/src/main/java/com/a/eye/skywalking/api/logging/api/NoopLogger.java
...java/com/a/eye/skywalking/api/logging/api/NoopLogger.java
+2
-2
skywalking-commons/skywalking-logging/skywalking-logging-api/src/test/java/com/a/eye/skywalking/api/logging/api/LogManagerTest.java
.../com/a/eye/skywalking/api/logging/api/LogManagerTest.java
+93
-0
skywalking-commons/skywalking-logging/skywalking-logging-api/src/test/java/com/a/eye/skywalking/api/logging/api/NoopLoggerTest.java
.../com/a/eye/skywalking/api/logging/api/NoopLoggerTest.java
+29
-0
skywalking-commons/skywalking-util/src/test/java/com/a/eye/skywalking/api/util/ConfigInitializerTest.java
.../com/a/eye/skywalking/api/util/ConfigInitializerTest.java
+59
-0
skywalking-commons/skywalking-util/src/test/java/com/a/eye/skywalking/api/util/StringUtilTest.java
...st/java/com/a/eye/skywalking/api/util/StringUtilTest.java
+24
-0
skywalking-sniffer/skywalking-api/pom.xml
skywalking-sniffer/skywalking-api/pom.xml
+0
-5
skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/queue/TraceSegmentProcessQueue.java
.../a/eye/skywalking/api/queue/TraceSegmentProcessQueue.java
+1
-5
未找到文件。
skywalking-commons/pom.xml
浏览文件 @
696090b0
...
...
@@ -13,7 +13,6 @@
<modules>
<module>
skywalking-trace
</module>
<module>
skywalking-logging
</module>
<module>
skywalking-health-report
</module>
<module>
skywalking-util
</module>
</modules>
...
...
skywalking-commons/skywalking-health-report/pom.xml
已删除
100644 → 0
浏览文件 @
488e8a9e
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
skywalking-commons
</artifactId>
<groupId>
com.a.eye
</groupId>
<version>
3.0-2017
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
skywalking-health-report
</artifactId>
<packaging>
jar
</packaging>
<name>
skywalking-health-report
</name>
<url>
http://maven.apache.org
</url>
<dependencies>
<dependency>
<groupId>
com.a.eye
</groupId>
<artifactId>
skywalking-logging-api
</artifactId>
<version>
${project.version}
</version>
</dependency>
</dependencies>
</project>
skywalking-commons/skywalking-health-report/src/main/java/com/a/eye/skywalking/health/report/HealthCollector.java
已删除
100644 → 0
浏览文件 @
488e8a9e
package
com.a.eye.skywalking.health.report
;
import
com.a.eye.skywalking.api.logging.api.ILog
;
import
com.a.eye.skywalking.api.logging.api.LogManager
;
import
java.util.Arrays
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
public
class
HealthCollector
extends
Thread
{
private
static
ILog
logger
=
LogManager
.
getLogger
(
HealthCollector
.
class
);
private
static
Map
<
String
,
HeathReading
>
heathReadings
=
new
ConcurrentHashMap
<
String
,
HeathReading
>();
private
static
final
long
DEFAULT_REPORT_INTERVAL
=
60
*
1000
;
private
final
long
reportInterval
;
private
String
reporterName
;
private
HealthCollector
(
String
reporterName
)
{
this
(
DEFAULT_REPORT_INTERVAL
);
this
.
reporterName
=
reporterName
;
}
private
HealthCollector
(
long
reportInterval
)
{
super
(
"HealthCollector"
);
this
.
setDaemon
(
true
);
this
.
reportInterval
=
reportInterval
;
}
public
static
void
init
(
String
reporterName
)
{
new
HealthCollector
(
reporterName
).
start
();
}
public
static
HeathReading
getCurrentHeathReading
(
String
extraId
)
{
String
id
=
getId
(
extraId
);
if
(!
heathReadings
.
containsKey
(
id
))
{
synchronized
(
heathReadings
)
{
if
(!
heathReadings
.
containsKey
(
id
))
{
if
(
heathReadings
.
keySet
().
size
()
>
5000
)
{
logger
.
warn
(
"use HealthCollector illegal. There is an overflow trend of Server Health Collector Report Data."
);
}
else
{
heathReadings
.
put
(
id
,
new
HeathReading
(
id
));
}
}
}
}
return
heathReadings
.
get
(
id
);
}
private
static
String
getId
(
String
extraId
)
{
return
"T:"
+
Thread
.
currentThread
().
getName
()
+
"("
+
Thread
.
currentThread
().
getId
()
+
")"
+
(
extraId
==
null
?
""
:
",extra:"
+
extraId
);
}
@Override
public
void
run
()
{
while
(
true
)
{
try
{
Map
<
String
,
HeathReading
>
heathReadingsSnapshot
=
heathReadings
;
heathReadings
=
new
ConcurrentHashMap
<
String
,
HeathReading
>();
String
[]
keyList
=
heathReadingsSnapshot
.
keySet
().
toArray
(
new
String
[
0
]);
Arrays
.
sort
(
keyList
);
StringBuilder
log
=
new
StringBuilder
();
log
.
append
(
"\n---------"
+
reporterName
+
" Health Report---------\n"
);
for
(
String
key
:
keyList
)
{
log
.
append
(
heathReadingsSnapshot
.
get
(
key
)).
append
(
"\n"
);
}
log
.
append
(
"------------------------------------------------\n"
);
logger
.
info
(
log
.
toString
());
try
{
Thread
.
sleep
(
reportInterval
);
}
catch
(
InterruptedException
e
)
{
}
}
catch
(
Throwable
t
)
{
logger
.
error
(
"HealthCollector report error."
,
t
);
}
}
}
}
skywalking-commons/skywalking-health-report/src/main/java/com/a/eye/skywalking/health/report/HeathReading.java
已删除
100644 → 0
浏览文件 @
488e8a9e
package
com.a.eye.skywalking.health.report
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
HeathReading
{
public
static
final
String
ERROR
=
"[ERROR]"
;
public
static
final
String
WARNING
=
"[WARNING]"
;
public
static
final
String
INFO
=
"[INFO]"
;
private
String
id
;
private
Map
<
String
,
HeathDetailData
>
datas
=
new
HashMap
<
String
,
HeathDetailData
>();
/**
* 健康读数,只应该在工作线程中创建
*/
public
HeathReading
(
String
id
)
{
this
.
id
=
id
;
}
public
void
updateData
(
String
key
,
String
message
)
{
updateData
(
key
,
message
,
new
Object
[
0
]);
}
public
void
updateData
(
String
key
,
String
newData
,
Object
...
arguments
)
{
if
(
datas
.
containsKey
(
key
))
{
datas
.
get
(
key
).
updateData
(
newData
,
arguments
);
}
else
{
datas
.
put
(
key
,
new
HeathDetailData
(
newData
,
arguments
));
}
}
@Override
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"id<"
).
append
(
this
.
id
).
append
(
">\n"
);
for
(
Map
.
Entry
<
String
,
HeathDetailData
>
data
:
datas
.
entrySet
())
{
sb
.
append
(
data
.
getKey
()).
append
(
data
.
getValue
().
toString
()).
append
(
"\n"
);
}
datas
=
new
HashMap
<
String
,
HeathReading
.
HeathDetailData
>();
return
sb
.
toString
();
}
class
HeathDetailData
{
private
String
data
;
private
long
statusTime
;
HeathDetailData
(
String
initialData
)
{
this
(
initialData
,
new
Object
[
0
]);
}
HeathDetailData
(
String
initialData
,
Object
[]
arguments
)
{
data
=
initialData
;
if
(
arguments
.
length
>
0
)
data
=
String
.
format
(
initialData
,
arguments
);
statusTime
=
System
.
currentTimeMillis
();
}
void
updateData
(
String
newData
,
Object
...
arguments
)
{
data
=
newData
;
if
(
arguments
.
length
>
0
)
data
=
String
.
format
(
newData
,
arguments
);
statusTime
=
System
.
currentTimeMillis
();
}
String
getData
()
{
return
data
;
}
long
getStatusTime
()
{
return
statusTime
;
}
@Override
public
String
toString
()
{
return
data
+
"(t:"
+
statusTime
+
")"
;
}
}
}
skywalking-commons/skywalking-logging/skywalking-logging-api/src/main/java/com/a/eye/skywalking/api/logging/api/NoopLogger.java
浏览文件 @
696090b0
...
...
@@ -7,8 +7,8 @@ package com.a.eye.skywalking.api.logging.api;
* <p>
* Created by xin on 2016/11/10.
*/
public
class
NoopLogger
implements
ILog
{
public
static
final
ILog
INSTANCE
=
new
NoopLogger
()
;
public
enum
NoopLogger
implements
ILog
{
INSTANCE
;
@Override
public
void
info
(
String
message
)
{
...
...
skywalking-commons/skywalking-logging/skywalking-logging-api/src/test/java/com/a/eye/skywalking/api/logging/api/LogManagerTest.java
0 → 100644
浏览文件 @
696090b0
package
com.a.eye.skywalking.api.logging.api
;
import
org.junit.After
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.powermock.api.support.membermodification.MemberModifier
;
/**
* Created by wusheng on 2017/2/27.
*/
public
class
LogManagerTest
{
@Test
public
void
testGetLogger
()
{
final
TestLogger
logger
=
new
TestLogger
();
LogManager
.
setLogResolver
(
new
LogResolver
()
{
@Override
public
ILog
getLogger
(
Class
<?>
clazz
)
{
return
logger
;
}
});
Assert
.
assertEquals
(
logger
,
LogManager
.
getLogger
(
LogManagerTest
.
class
));
}
@Test
public
void
testGetNoopLogger
(){
ILog
logger
=
LogManager
.
getLogger
(
LogManagerTest
.
class
);
Assert
.
assertEquals
(
NoopLogger
.
INSTANCE
,
logger
);
}
@Before
@After
public
void
clear
()
throws
IllegalAccessException
{
MemberModifier
.
field
(
LogManager
.
class
,
"resolver"
).
set
(
null
,
null
);
}
public
class
TestLogger
implements
ILog
{
@Override
public
void
info
(
String
format
)
{
}
@Override
public
void
info
(
String
format
,
Object
...
arguments
)
{
}
@Override
public
void
warn
(
String
format
,
Object
...
arguments
)
{
}
@Override
public
void
warn
(
String
format
,
Object
arguments
,
Throwable
e
)
{
}
@Override
public
void
error
(
String
format
,
Throwable
e
)
{
}
@Override
public
void
error
(
String
format
,
Object
arguments
,
Throwable
e
)
{
}
@Override
public
boolean
isDebugEnable
()
{
return
false
;
}
@Override
public
boolean
isInfoEnable
()
{
return
false
;
}
@Override
public
boolean
isWarnEnable
()
{
return
false
;
}
@Override
public
boolean
isErrorEnable
()
{
return
false
;
}
@Override
public
void
debug
(
String
format
)
{
}
@Override
public
void
debug
(
String
format
,
Object
...
arguments
)
{
}
@Override
public
void
error
(
String
format
)
{
}
}
}
skywalking-commons/skywalking-logging/skywalking-logging-api/src/test/java/com/a/eye/skywalking/api/logging/api/NoopLoggerTest.java
0 → 100644
浏览文件 @
696090b0
package
com.a.eye.skywalking.api.logging.api
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
static
com
.
a
.
eye
.
skywalking
.
api
.
logging
.
api
.
NoopLogger
.
INSTANCE
;
/**
* Created by wusheng on 2017/2/27.
*/
public
class
NoopLoggerTest
{
@Test
public
void
testOnNothing
(){
Assert
.
assertFalse
(
INSTANCE
.
isDebugEnable
());
Assert
.
assertFalse
(
INSTANCE
.
isInfoEnable
());
Assert
.
assertFalse
(
INSTANCE
.
isErrorEnable
());
Assert
.
assertFalse
(
INSTANCE
.
isWarnEnable
());
INSTANCE
.
debug
(
"Any string"
);
INSTANCE
.
debug
(
"Any string"
,
new
Object
[
0
]);
INSTANCE
.
info
(
"Any string"
);
INSTANCE
.
info
(
"Any string"
,
new
Object
[
0
]);
INSTANCE
.
warn
(
"Any string"
,
new
Object
[
0
]);
INSTANCE
.
warn
(
"Any string"
,
new
Object
[
0
],
new
NullPointerException
());
INSTANCE
.
error
(
"Any string"
);
INSTANCE
.
error
(
"Any string"
,
new
NullPointerException
());
INSTANCE
.
error
(
"Any string"
,
new
Object
[
0
],
new
NullPointerException
());
}
}
skywalking-commons/skywalking-util/src/test/java/com/a/eye/skywalking/api/util/ConfigInitializerTest.java
0 → 100644
浏览文件 @
696090b0
package
com.a.eye.skywalking.api.util
;
import
java.util.Properties
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Test
;
/**
* Created by wusheng on 2017/2/27.
*/
public
class
ConfigInitializerTest
{
@Test
public
void
testInitialize
()
throws
IllegalAccessException
{
Properties
properties
=
new
Properties
();
properties
.
put
(
"Level1Object.strAttr"
.
toLowerCase
(),
"stringValue"
);
properties
.
put
(
"Level1Object.Level2Object.intAttr"
.
toLowerCase
(),
"1000"
);
properties
.
put
(
"Level1Object.Level2Object.longAttr"
.
toLowerCase
(),
"1000"
);
properties
.
put
(
"Level1Object.Level2Object.booleanAttr"
.
toLowerCase
(),
"true"
);
ConfigInitializer
.
initialize
(
properties
,
TestPropertiesObject
.
class
);
Assert
.
assertEquals
(
"stringValue"
,
TestPropertiesObject
.
Level1Object
.
strAttr
);
Assert
.
assertEquals
(
1000
,
TestPropertiesObject
.
Level1Object
.
Level2Object
.
intAttr
);
Assert
.
assertEquals
(
1000L
,
TestPropertiesObject
.
Level1Object
.
Level2Object
.
longAttr
);
Assert
.
assertEquals
(
true
,
TestPropertiesObject
.
Level1Object
.
Level2Object
.
booleanAttr
);
}
@Test
public
void
testInitializeWithUnsupportedConfig
()
throws
IllegalAccessException
{
Properties
properties
=
new
Properties
();
properties
.
put
(
"Level1Object.noExistAttr"
.
toLowerCase
(),
"stringValue"
);
ConfigInitializer
.
initialize
(
properties
,
TestPropertiesObject
.
class
);
Assert
.
assertNull
(
TestPropertiesObject
.
Level1Object
.
strAttr
);
}
@Before
public
void
clear
(){
TestPropertiesObject
.
Level1Object
.
strAttr
=
null
;
TestPropertiesObject
.
Level1Object
.
Level2Object
.
intAttr
=
0
;
TestPropertiesObject
.
Level1Object
.
Level2Object
.
longAttr
=
0
;
TestPropertiesObject
.
Level1Object
.
Level2Object
.
booleanAttr
=
false
;
}
public
static
class
TestPropertiesObject
{
public
static
class
Level1Object
{
public
static
String
strAttr
=
null
;
public
static
class
Level2Object
{
public
static
int
intAttr
=
0
;
public
static
long
longAttr
;
public
static
boolean
booleanAttr
;
}
}
}
}
skywalking-commons/skywalking-util/src/test/java/com/a/eye/skywalking/api/util/StringUtilTest.java
0 → 100644
浏览文件 @
696090b0
package
com.a.eye.skywalking.api.util
;
import
org.junit.Assert
;
import
org.junit.Test
;
/**
* Created by wusheng on 2017/2/27.
*/
public
class
StringUtilTest
{
@Test
public
void
testIsEmpty
(){
Assert
.
assertTrue
(
StringUtil
.
isEmpty
(
null
));
Assert
.
assertTrue
(
StringUtil
.
isEmpty
(
""
));
Assert
.
assertFalse
(
StringUtil
.
isEmpty
(
" "
));
Assert
.
assertFalse
(
StringUtil
.
isEmpty
(
"A String"
));
}
@Test
public
void
testJoin
(){
Assert
.
assertNull
(
StringUtil
.
join
(
'.'
));
Assert
.
assertEquals
(
"Single part."
,
StringUtil
.
join
(
'.'
,
"Single part."
));
Assert
.
assertEquals
(
"part1.part2.p3"
,
StringUtil
.
join
(
'.'
,
"part1"
,
"part2"
,
"p3"
));
}
}
skywalking-sniffer/skywalking-api/pom.xml
浏览文件 @
696090b0
...
...
@@ -36,11 +36,6 @@
<artifactId>
disruptor
</artifactId>
<version>
3.3.6
</version>
</dependency>
<dependency>
<groupId>
com.a.eye
</groupId>
<artifactId>
skywalking-health-report
</artifactId>
<version>
${project.version}
</version>
</dependency>
<dependency>
<groupId>
com.a.eye
</groupId>
<artifactId>
skywalking-logging-api
</artifactId>
...
...
skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/queue/TraceSegmentProcessQueue.java
浏览文件 @
696090b0
...
...
@@ -3,8 +3,6 @@ package com.a.eye.skywalking.api.queue;
import
com.a.eye.skywalking.api.conf.Config
;
import
com.a.eye.skywalking.api.context.TracerContext
;
import
com.a.eye.skywalking.api.context.TracerContextListener
;
import
com.a.eye.skywalking.health.report.HealthCollector
;
import
com.a.eye.skywalking.health.report.HeathReading
;
import
com.a.eye.skywalking.trace.TraceSegment
;
import
com.lmax.disruptor.RingBuffer
;
import
com.lmax.disruptor.dsl.Disruptor
;
...
...
@@ -24,8 +22,6 @@ public enum TraceSegmentProcessQueue implements TracerContextListener {
try
{
TraceSegmentHolder
data
=
this
.
buffer
.
get
(
sequence
);
data
.
setValue
(
traceSegment
);
HealthCollector
.
getCurrentHeathReading
(
"TraceSegmentProcessQueue"
).
updateData
(
HeathReading
.
INFO
,
"receive finished traceSegment."
);
}
finally
{
this
.
buffer
.
publish
(
sequence
);
}
...
...
@@ -36,7 +32,7 @@ public enum TraceSegmentProcessQueue implements TracerContextListener {
RingBuffer
<
TraceSegmentHolder
>
buffer
;
TraceSegmentProcessQueue
()
{
disruptor
=
new
Disruptor
<
TraceSegmentHolder
>(
TraceSegmentHolder
.
Factory
.
INSTANCE
,
Config
.
Disruptor
.
BUFFER_SIZE
,
DaemonThreadFactory
.
INSTANCE
);
disruptor
=
new
Disruptor
<>(
TraceSegmentHolder
.
Factory
.
INSTANCE
,
Config
.
Disruptor
.
BUFFER_SIZE
,
DaemonThreadFactory
.
INSTANCE
);
buffer
=
disruptor
.
getRingBuffer
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录