Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
nightingale
提交
7830e60c
N
nightingale
项目概览
DiDi
/
nightingale
9 个月 前同步成功
通知
46
Star
7053
Fork
1161
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
nightingale
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
7830e60c
编写于
1月 21, 2021
作者:
7
710leo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix log
上级
56feba9b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
15 addition
and
14 deletion
+15
-14
src/modules/agent/log/worker/control.go
src/modules/agent/log/worker/control.go
+2
-1
src/modules/agent/log/worker/push.go
src/modules/agent/log/worker/push.go
+5
-5
src/modules/agent/log/worker/worker.go
src/modules/agent/log/worker/worker.go
+8
-8
未找到文件。
src/modules/agent/log/worker/control.go
浏览文件 @
7830e60c
...
...
@@ -66,7 +66,7 @@ func UpdateConfigsLoop() {
}
}
func
GetLatestTmsAndDelay
(
filepath
string
)
(
int64
,
int
64
,
bool
)
{
func
GetLatestTmsAndDelay
(
filepath
string
)
(
int64
,
int
32
,
bool
)
{
ManagerJobLock
.
RLock
()
job
,
ok
:=
ManagerJob
[
filepath
]
ManagerJobLock
.
RUnlock
()
...
...
@@ -74,6 +74,7 @@ func GetLatestTmsAndDelay(filepath string) (int64, int64, bool) {
if
!
ok
{
return
0
,
0
,
false
}
latest
,
delay
:=
job
.
w
.
GetLatestTmsAndDelay
()
return
latest
,
delay
,
true
}
...
...
src/modules/agent/log/worker/push.go
浏览文件 @
7830e60c
...
...
@@ -106,13 +106,13 @@ func tmsNeedPush(tms int64, filePath string, step int64, waitPush int) bool {
// 为解决日志时间戳乱序的最大等待时间, hard code
// delay == 0时, 不用额外等待, 进而提高时效性
if
delay
>
0
{
var
maxDelay
int
64
var
maxDelay
int
32
if
step
<=
10
{
maxDelay
=
step
*
3
maxDelay
=
int32
(
step
)
*
3
}
else
if
step
>
10
&&
step
<=
30
{
maxDelay
=
step
*
2
maxDelay
=
int32
(
step
)
*
2
}
else
{
maxDelay
=
step
maxDelay
=
int32
(
step
)
}
if
delay
>
maxDelay
{
delay
=
maxDelay
...
...
@@ -129,7 +129,7 @@ func tmsNeedPush(tms int64, filePath string, step int64, waitPush int) bool {
return
true
}
if
tms
<
AlignStepTms
(
step
,
latest
-
delay
)
{
if
tms
<
AlignStepTms
(
step
,
latest
-
int64
(
delay
)
)
{
return
true
}
...
...
src/modules/agent/log/worker/worker.go
浏览文件 @
7830e60c
...
...
@@ -16,7 +16,7 @@ import (
"github.com/didi/nightingale/src/modules/agent/stra"
)
type
callbackHandler
func
(
int64
,
int
64
)
type
callbackHandler
func
(
int64
,
int
32
)
//单个worker对象
type
Worker
struct
{
...
...
@@ -35,7 +35,7 @@ type Worker struct {
type
WorkerGroup
struct
{
WorkerNum
int
LatestTms
int64
//日志文件最新处理的时间戳
MaxDelay
int
64
//日志文件存在的时间戳乱序最大差值
MaxDelay
int
32
//日志文件存在的时间戳乱序最大差值
ResetTms
int64
//maxDelay上次重置的时间
Workers
[]
*
Worker
TimeFormatStrategy
string
...
...
@@ -71,11 +71,11 @@ func NewWorkerGroup(filePath string, stream chan string) *WorkerGroup {
return
wg
}
func
(
wg
WorkerGroup
)
GetLatestTmsAndDelay
()
(
tms
int64
,
delay
int
64
)
{
func
(
wg
WorkerGroup
)
GetLatestTmsAndDelay
()
(
tms
int64
,
delay
int
32
)
{
return
wg
.
LatestTms
,
wg
.
MaxDelay
}
func
(
wg
*
WorkerGroup
)
SetLatestTmsAndDelay
(
tms
int64
,
delay
int
64
)
{
func
(
wg
*
WorkerGroup
)
SetLatestTmsAndDelay
(
tms
int64
,
delay
int
32
)
{
latest
:=
atomic
.
LoadInt64
(
&
wg
.
LatestTms
)
if
latest
<
tms
{
...
...
@@ -89,9 +89,9 @@ func (wg *WorkerGroup) SetLatestTmsAndDelay(tms int64, delay int64) {
return
}
newest
:=
atomic
.
LoadInt
64
(
&
wg
.
MaxDelay
)
newest
:=
atomic
.
LoadInt
32
(
&
wg
.
MaxDelay
)
if
newest
<
delay
{
atomic
.
CompareAndSwapInt
64
(
&
wg
.
MaxDelay
,
newest
,
delay
)
atomic
.
CompareAndSwapInt
32
(
&
wg
.
MaxDelay
,
newest
,
delay
)
}
}
...
...
@@ -112,7 +112,7 @@ func (wg *WorkerGroup) ResetMaxDelay() {
ts
:=
time
.
Now
()
.
Unix
()
if
ts
-
wg
.
ResetTms
>
86400
{
wg
.
ResetTms
=
ts
atomic
.
StoreInt
64
(
&
wg
.
MaxDelay
,
0
)
atomic
.
StoreInt
32
(
&
wg
.
MaxDelay
,
0
)
}
}
...
...
@@ -253,7 +253,7 @@ func (w *Worker) producer(line string, strategy *stra.Strategy) (*AnalysPoint, e
delay
=
w
.
LatestTms
-
tmsUnix
}
if
updateLatest
||
delay
>
0
{
w
.
Callback
(
tmsUnix
,
delay
)
w
.
Callback
(
tmsUnix
,
int32
(
delay
)
)
}
//处理用户正则
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录