Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gdyjdao
SkyWalking
提交
e9abfff1
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,发现更多精彩内容 >>
提交
e9abfff1
编写于
4月 01, 2017
作者:
P
pengys5
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify testcase bug When errors occur in timezone
上级
be626bda
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
62 addition
and
30 deletion
+62
-30
skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/segment/SegmentPost.java
.../eye/skywalking/collector/worker/segment/SegmentPost.java
+1
-0
skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/tools/DateTools.java
...om/a/eye/skywalking/collector/worker/tools/DateTools.java
+10
-1
skywalking-collector/skywalking-collector-worker/src/test/java/com/a/eye/skywalking/collector/worker/MergePersistenceMemberTestCase.java
...king/collector/worker/MergePersistenceMemberTestCase.java
+0
-7
skywalking-collector/skywalking-collector-worker/src/test/java/com/a/eye/skywalking/collector/worker/segment/SegmentPostTestCase.java
...walking/collector/worker/segment/SegmentPostTestCase.java
+23
-22
skywalking-collector/skywalking-collector-worker/src/test/java/com/a/eye/skywalking/collector/worker/tools/DateToolsTestCase.java
.../skywalking/collector/worker/tools/DateToolsTestCase.java
+28
-0
未找到文件。
skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/segment/SegmentPost.java
浏览文件 @
e9abfff1
...
...
@@ -85,6 +85,7 @@ public class SegmentPost extends AbstractPost {
long
hourSlice
=
DateTools
.
getHourSlice
(
newSegment
.
getStartTime
());
long
daySlice
=
DateTools
.
getDaySlice
(
newSegment
.
getStartTime
());
int
second
=
DateTools
.
getSecond
(
newSegment
.
getStartTime
());
logger
.
debug
(
"minuteSlice: %s, hourSlice: %s, daySlice: %s, second:%s"
,
minuteSlice
,
hourSlice
,
daySlice
,
second
);
SegmentWithTimeSlice
segmentWithTimeSlice
=
new
SegmentWithTimeSlice
(
newSegment
,
minuteSlice
,
hourSlice
,
daySlice
,
second
);
String
newSegmentJsonStr
=
gson
.
toJson
(
newSegment
);
...
...
skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/tools/DateTools.java
浏览文件 @
e9abfff1
...
...
@@ -2,6 +2,7 @@ package com.a.eye.skywalking.collector.worker.tools;
import
java.text.SimpleDateFormat
;
import
java.util.Calendar
;
import
java.util.TimeZone
;
/**
* @author pengys5
...
...
@@ -19,7 +20,7 @@ public class DateTools {
}
public
static
long
getMinuteSlice
(
long
time
)
{
Calendar
calendar
=
Calendar
.
getInstance
();
Calendar
calendar
=
Calendar
.
getInstance
(
TimeZone
.
getTimeZone
(
"GMT+8:00"
)
);
calendar
.
setTimeInMillis
(
time
);
String
timeStr
=
minuteDateFormat
.
format
(
calendar
.
getTime
());
return
Long
.
valueOf
(
timeStr
);
...
...
@@ -38,4 +39,12 @@ public class DateTools {
String
timeStr
=
dayDateFormat
.
format
(
calendar
.
getTime
())
+
"0000"
;
return
Long
.
valueOf
(
timeStr
);
}
public
static
long
changeToUTCSlice
(
long
timeSlice
)
{
if
(
TimeZone
.
getDefault
().
getID
().
equals
(
"GMT+08:00"
))
{
return
timeSlice
;
}
else
{
return
timeSlice
-
800
;
}
}
}
skywalking-collector/skywalking-collector-worker/src/test/java/com/a/eye/skywalking/collector/worker/MergePersistenceMemberTestCase.java
已删除
100644 → 0
浏览文件 @
be626bda
package
com.a.eye.skywalking.collector.worker
;
/**
* @author pengys5
*/
public
class
MergePersistenceMemberTestCase
{
}
skywalking-collector/skywalking-collector-worker/src/test/java/com/a/eye/skywalking/collector/worker/segment/SegmentPostTestCase.java
浏览文件 @
e9abfff1
...
...
@@ -14,6 +14,7 @@ import com.a.eye.skywalking.collector.worker.segment.mock.SegmentMock;
import
com.a.eye.skywalking.collector.worker.segment.persistence.SegmentCostSave
;
import
com.a.eye.skywalking.collector.worker.segment.persistence.SegmentExceptionSave
;
import
com.a.eye.skywalking.collector.worker.segment.persistence.SegmentSave
;
import
com.a.eye.skywalking.collector.worker.tools.DateTools
;
import
com.google.gson.JsonObject
;
import
org.junit.Assert
;
import
org.junit.Before
;
...
...
@@ -166,48 +167,48 @@ public class SegmentPostTestCase {
segmentPost
.
onReceive
(
cacheServiceSegmentAsString
);
Assert
.
assertEquals
(
201703310915L
,
segmentSaveAnswer_1
.
minute
);
Assert
.
assertEquals
(
201703310900L
,
segmentSaveAnswer_1
.
hour
);
Assert
.
assertEquals
(
DateTools
.
changeToUTCSlice
(
201703310915L
)
,
segmentSaveAnswer_1
.
minute
);
Assert
.
assertEquals
(
DateTools
.
changeToUTCSlice
(
201703310900L
)
,
segmentSaveAnswer_1
.
hour
);
Assert
.
assertEquals
(
201703310000L
,
segmentSaveAnswer_1
.
day
);
Assert
.
assertEquals
(
201703310915L
,
segmentSaveAnswer_2
.
minute
);
Assert
.
assertEquals
(
201703310900L
,
segmentSaveAnswer_2
.
hour
);
Assert
.
assertEquals
(
DateTools
.
changeToUTCSlice
(
201703310915L
)
,
segmentSaveAnswer_2
.
minute
);
Assert
.
assertEquals
(
DateTools
.
changeToUTCSlice
(
201703310900L
)
,
segmentSaveAnswer_2
.
hour
);
Assert
.
assertEquals
(
201703310000L
,
segmentSaveAnswer_2
.
day
);
Assert
.
assertEquals
(
201703310915L
,
segmentCostSaveAnswer
.
segmentWithTimeSlice
.
getMinute
());
Assert
.
assertEquals
(
201703310900L
,
segmentCostSaveAnswer
.
segmentWithTimeSlice
.
getHour
());
Assert
.
assertEquals
(
DateTools
.
changeToUTCSlice
(
201703310915L
)
,
segmentCostSaveAnswer
.
segmentWithTimeSlice
.
getMinute
());
Assert
.
assertEquals
(
DateTools
.
changeToUTCSlice
(
201703310900L
)
,
segmentCostSaveAnswer
.
segmentWithTimeSlice
.
getHour
());
Assert
.
assertEquals
(
201703310000L
,
segmentCostSaveAnswer
.
segmentWithTimeSlice
.
getDay
());
Assert
.
assertEquals
(
201703310915L
,
globalTraceAnalysisAnswer
.
segmentWithTimeSlice
.
getMinute
());
Assert
.
assertEquals
(
201703310900L
,
globalTraceAnalysisAnswer
.
segmentWithTimeSlice
.
getHour
());
Assert
.
assertEquals
(
DateTools
.
changeToUTCSlice
(
201703310915L
)
,
globalTraceAnalysisAnswer
.
segmentWithTimeSlice
.
getMinute
());
Assert
.
assertEquals
(
DateTools
.
changeToUTCSlice
(
201703310900L
)
,
globalTraceAnalysisAnswer
.
segmentWithTimeSlice
.
getHour
());
Assert
.
assertEquals
(
201703310000L
,
globalTraceAnalysisAnswer
.
segmentWithTimeSlice
.
getDay
());
Assert
.
assertEquals
(
201703310915L
,
segmentExceptionSaveAnswer
.
segmentWithTimeSlice
.
getMinute
());
Assert
.
assertEquals
(
201703310900L
,
segmentExceptionSaveAnswer
.
segmentWithTimeSlice
.
getHour
());
Assert
.
assertEquals
(
DateTools
.
changeToUTCSlice
(
201703310915L
)
,
segmentExceptionSaveAnswer
.
segmentWithTimeSlice
.
getMinute
());
Assert
.
assertEquals
(
DateTools
.
changeToUTCSlice
(
201703310900L
)
,
segmentExceptionSaveAnswer
.
segmentWithTimeSlice
.
getHour
());
Assert
.
assertEquals
(
201703310000L
,
segmentExceptionSaveAnswer
.
segmentWithTimeSlice
.
getDay
());
Assert
.
assertEquals
(
201703310915L
,
nodeRefMinuteAnalysisAnswer
.
segmentWithTimeSlice
.
getMinute
());
Assert
.
assertEquals
(
201703310900L
,
nodeRefMinuteAnalysisAnswer
.
segmentWithTimeSlice
.
getHour
());
Assert
.
assertEquals
(
DateTools
.
changeToUTCSlice
(
201703310915L
)
,
nodeRefMinuteAnalysisAnswer
.
segmentWithTimeSlice
.
getMinute
());
Assert
.
assertEquals
(
DateTools
.
changeToUTCSlice
(
201703310900L
)
,
nodeRefMinuteAnalysisAnswer
.
segmentWithTimeSlice
.
getHour
());
Assert
.
assertEquals
(
201703310000L
,
nodeRefMinuteAnalysisAnswer
.
segmentWithTimeSlice
.
getDay
());
Assert
.
assertEquals
(
201703310915L
,
nodeRefHourAnalysisAnswer
.
segmentWithTimeSlice
.
getMinute
());
Assert
.
assertEquals
(
201703310900L
,
nodeRefHourAnalysisAnswer
.
segmentWithTimeSlice
.
getHour
());
Assert
.
assertEquals
(
DateTools
.
changeToUTCSlice
(
201703310915L
)
,
nodeRefHourAnalysisAnswer
.
segmentWithTimeSlice
.
getMinute
());
Assert
.
assertEquals
(
DateTools
.
changeToUTCSlice
(
201703310900L
)
,
nodeRefHourAnalysisAnswer
.
segmentWithTimeSlice
.
getHour
());
Assert
.
assertEquals
(
201703310000L
,
nodeRefHourAnalysisAnswer
.
segmentWithTimeSlice
.
getDay
());
Assert
.
assertEquals
(
201703310915L
,
nodeRefDayAnalysisAnswer
.
segmentWithTimeSlice
.
getMinute
());
Assert
.
assertEquals
(
201703310900L
,
nodeRefDayAnalysisAnswer
.
segmentWithTimeSlice
.
getHour
());
Assert
.
assertEquals
(
DateTools
.
changeToUTCSlice
(
201703310915L
)
,
nodeRefDayAnalysisAnswer
.
segmentWithTimeSlice
.
getMinute
());
Assert
.
assertEquals
(
DateTools
.
changeToUTCSlice
(
201703310900L
)
,
nodeRefDayAnalysisAnswer
.
segmentWithTimeSlice
.
getHour
());
Assert
.
assertEquals
(
201703310000L
,
nodeRefDayAnalysisAnswer
.
segmentWithTimeSlice
.
getDay
());
Assert
.
assertEquals
(
201703310915L
,
nodeMinuteAnalysisAnswer
.
segmentWithTimeSlice
.
getMinute
());
Assert
.
assertEquals
(
201703310900L
,
nodeMinuteAnalysisAnswer
.
segmentWithTimeSlice
.
getHour
());
Assert
.
assertEquals
(
DateTools
.
changeToUTCSlice
(
201703310915L
)
,
nodeMinuteAnalysisAnswer
.
segmentWithTimeSlice
.
getMinute
());
Assert
.
assertEquals
(
DateTools
.
changeToUTCSlice
(
201703310900L
)
,
nodeMinuteAnalysisAnswer
.
segmentWithTimeSlice
.
getHour
());
Assert
.
assertEquals
(
201703310000L
,
nodeMinuteAnalysisAnswer
.
segmentWithTimeSlice
.
getDay
());
Assert
.
assertEquals
(
201703310915L
,
nodeHourAnalysisAnswer
.
segmentWithTimeSlice
.
getMinute
());
Assert
.
assertEquals
(
201703310900L
,
nodeHourAnalysisAnswer
.
segmentWithTimeSlice
.
getHour
());
Assert
.
assertEquals
(
DateTools
.
changeToUTCSlice
(
201703310915L
)
,
nodeHourAnalysisAnswer
.
segmentWithTimeSlice
.
getMinute
());
Assert
.
assertEquals
(
DateTools
.
changeToUTCSlice
(
201703310900L
)
,
nodeHourAnalysisAnswer
.
segmentWithTimeSlice
.
getHour
());
Assert
.
assertEquals
(
201703310000L
,
nodeHourAnalysisAnswer
.
segmentWithTimeSlice
.
getDay
());
Assert
.
assertEquals
(
201703310915L
,
nodeDayAnalysisAnswer
.
segmentWithTimeSlice
.
getMinute
());
Assert
.
assertEquals
(
201703310900L
,
nodeDayAnalysisAnswer
.
segmentWithTimeSlice
.
getHour
());
Assert
.
assertEquals
(
DateTools
.
changeToUTCSlice
(
201703310915L
)
,
nodeDayAnalysisAnswer
.
segmentWithTimeSlice
.
getMinute
());
Assert
.
assertEquals
(
DateTools
.
changeToUTCSlice
(
201703310900L
)
,
nodeDayAnalysisAnswer
.
segmentWithTimeSlice
.
getHour
());
Assert
.
assertEquals
(
201703310000L
,
nodeDayAnalysisAnswer
.
segmentWithTimeSlice
.
getDay
());
}
...
...
skywalking-collector/skywalking-collector-worker/src/test/java/com/a/eye/skywalking/collector/worker/tools/DateToolsTestCase.java
0 → 100644
浏览文件 @
e9abfff1
package
com.a.eye.skywalking.collector.worker.tools
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
java.util.TimeZone
;
/**
* @author pengys5
*/
public
class
DateToolsTestCase
{
@Test
public
void
testUTCLocation
()
{
TimeZone
.
setDefault
(
TimeZone
.
getTimeZone
(
"UTC"
));
long
timeSlice
=
201703310915L
;
long
changedTimeSlice
=
DateTools
.
changeToUTCSlice
(
timeSlice
);
Assert
.
assertEquals
(
201703310115L
,
changedTimeSlice
);
}
@Test
public
void
testUTC8Location
()
{
TimeZone
.
setDefault
(
TimeZone
.
getTimeZone
(
"GMT+08:00"
));
long
timeSlice
=
201703310915L
;
long
changedTimeSlice
=
DateTools
.
changeToUTCSlice
(
timeSlice
);
Assert
.
assertEquals
(
201703310915L
,
changedTimeSlice
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录