Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
E
evsuits
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
OpsTeam
evsuits
Commits
edeb845c
提交
edeb845c
authored
11月 08, 2019
作者:
blu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feature: report status
上级
e973400e
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
70 行增加
和
35 行删除
+70
-35
evcloudsvc.cpp
opencv-motion-detect/evcloudsvc.cpp
+1
-1
evslicer.cpp
opencv-motion-detect/evslicer.cpp
+68
-34
zmqhelper.hpp
opencv-motion-detect/inc/zmqhelper.hpp
+1
-0
没有找到文件。
opencv-motion-detect/evcloudsvc.cpp
浏览文件 @
edeb845c
...
...
@@ -690,7 +690,7 @@ private:
}
}
if
(
catId
==
EV_MSG_REPORT_CATID_AVMODOFFLINE
||
catId
==
EV_MSG_REPORT_CATID_AVWRITEPIPE
||
(
modId
.
find
(
"evpuller"
)
!=
string
::
npos
&&
catId
==
EV_MSG_REPORT_CATID_AVOPENINPUT
))
{
if
(
catId
==
EV_MSG_REPORT_CATID_AV
FAILEDUPLOAD
||
catId
==
EV_MSG_REPORT_CATID_AV
MODOFFLINE
||
catId
==
EV_MSG_REPORT_CATID_AVWRITEPIPE
||
(
modId
.
find
(
"evpuller"
)
!=
string
::
npos
&&
catId
==
EV_MSG_REPORT_CATID_AVOPENINPUT
))
{
ipcStatus
[
"current"
][
modId
]
=
true
;
}
}
...
...
opencv-motion-detect/evslicer.cpp
浏览文件 @
edeb845c
...
...
@@ -53,7 +53,7 @@ private:
json
slices
;
condition_variable
cvMsg
;
mutex
mutMsg
;
bool
gotFormat
=
false
;
bool
gotFormat
=
false
,
bUploadFailed
=
false
;
queue
<
string
>
eventQueue
;
condition_variable
cvEvent
;
mutex
mutEvent
;
...
...
@@ -865,6 +865,24 @@ protected:
return
ret
;
}
void
reportUploadFailure
(
string
modId
,
bool
fail
,
string
reason
){
string
modifier
=
fail
?
"failed"
:
"successfully"
;
string
status
=
fail
?
"active"
:
"recover"
;
string
msg
=
fmt
::
format
(
"evslicer {} {} upload videos: {}"
,
selfId
,
modifier
,
reason
);
json
meta
;
json
data
;
data
[
"msg"
]
=
msg
;
data
[
"modId"
]
=
modId
;
data
[
"type"
]
=
EV_MSG_META_TYPE_REPORT
;
data
[
"catId"
]
=
EV_MSG_REPORT_CATID_AVFAILEDUPLOAD
;
data
[
"level"
]
=
EV_MSG_META_VALUE_REPORT_LEVEL_FATAL
;
data
[
"time"
]
=
chrono
::
duration_cast
<
chrono
::
seconds
>
(
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
();
data
[
"status"
]
=
"recover"
;
meta
[
"type"
]
=
EV_MSG_META_TYPE_REPORT
;
meta
[
"value"
]
=
EV_MSG_META_VALUE_REPORT_LEVEL_FATAL
;
z_send
(
pDaemon
,
"evcloudsvc"
,
meta
.
dump
(),
data
.
dump
());
}
public
:
EvSlicer
()
{
...
...
@@ -1040,14 +1058,18 @@ public:
string
strResp
;
ret
=
netutils
::
postFiles
(
this
->
videoFileServerApi
,
params
,
fileNames
,
strResp
);
if
(
ret
!=
0
)
{
spdlog
::
info
(
"evslicer {} failed uploaded ({}, {}). local({}, {}). resp: {} files:
\n
{}"
,
selfId
,
tss
,
tse
,
first
,
end
,
strResp
,
sf
);
bUploadFailed
=
true
;
spdlog
::
error
(
"evslicer {} failed uploaded ({}, {}). local({}, {}). resp: {} files:
\n
{}"
,
selfId
,
tss
,
tse
,
first
,
end
,
strResp
,
sf
);
reportUploadFailure
(
selfId
,
true
,
strResp
);
if
(
ret
>
0
)
{
if
(
jEvt
.
count
(
"cnt"
)
==
0
)
{
jEvt
[
"cnt"
]
=
ret
;
}
if
(
jEvt
[
"cnt"
].
get
<
int
>
()
<=
0
)
{
spdlog
::
error
(
"evslicer {} failed to upload videos over N times, abort retrying: {}"
,
selfId
,
evt
);
// TODO: report message to cloud
string
msg
=
fmt
::
format
(
"evslicer {} failed to upload videos over N times: {}"
,
selfId
,
strResp
);
spdlog
::
error
(
msg
);
// TODO: move to failed folder
string
dirDest
=
"/var/data/evsuits/failed_events/"
;
system
((
string
(
"mkdir -p "
)
+
dirDest
).
c_str
());
...
...
@@ -1078,46 +1100,58 @@ public:
}
}
}
else
{
else
{
// ret == 0
spdlog
::
info
(
"evslicer {} upload ({}, {}). local({}, {}). resp: {} files:
\n
{}"
,
selfId
,
tss
,
tse
,
first
,
end
,
strResp
,
sf
);
if
(
ret
>
0
)
{
try
{
auto
resp
=
json
::
parse
(
strResp
);
//TODO: open this swith when video server has implemented this functionality
if
(
true
)
{
if
(
resp
.
count
(
"code"
)
!=
0
&&
resp
[
"code"
]
!=
0
)
{
if
(
resp
[
"code"
]
==
4
||
resp
[
"code"
]
==
7
)
{
if
(
jEvt
.
count
(
"cnt"
)
==
0
)
{
jEvt
[
"cnt"
]
=
2
;
try
{
auto
resp
=
json
::
parse
(
strResp
);
//TODO: open this swith when video server has implemented this functionality
if
(
true
)
{
if
(
resp
.
count
(
"code"
)
==
0
||
resp
[
"code"
]
!=
0
)
{
bUploadFailed
=
true
;
reportUploadFailure
(
selfId
,
true
,
strResp
);
}
if
(
resp
.
count
(
"code"
)
!=
0
&&
resp
[
"code"
]
!=
0
)
{
bUploadFailed
=
true
;
if
(
resp
[
"code"
]
==
4
||
resp
[
"code"
]
==
7
)
{
if
(
jEvt
.
count
(
"cnt"
)
==
0
)
{
jEvt
[
"cnt"
]
=
2
;
}
else
{
if
(
jEvt
[
"cnt"
].
get
<
int
>
()
<=
0
)
{
string
msg
=
fmt
::
format
(
"evslicer {} failed to upload videos over N times. reason: {}"
,
selfId
,
strResp
);
spdlog
::
error
(
msg
);
}
else
{
if
(
jEvt
[
"cnt"
].
get
<
int
>
()
<=
0
)
{
spdlog
::
error
(
"evslicer {} failed to upload videos over N times, abort retrying: {}"
,
this
->
selfId
,
evt
);
}
else
{
jEvt
[
"cnt"
]
=
jEvt
[
"cnt"
].
get
<
int
>
()
-
1
;
lock_guard
<
mutex
>
lock
(
this
->
mutEvent
);
this
->
eventQueue
.
push
(
jEvt
.
dump
());
if
(
eventQueue
.
size
()
>
MAX_EVENT_QUEUE_SIZE
)
{
eventQueue
.
pop
();
}
cvEvent
.
notify_one
();
jEvt
[
"cnt"
]
=
jEvt
[
"cnt"
].
get
<
int
>
()
-
1
;
lock_guard
<
mutex
>
lock
(
this
->
mutEvent
);
this
->
eventQueue
.
push
(
jEvt
.
dump
());
if
(
eventQueue
.
size
()
>
MAX_EVENT_QUEUE_SIZE
)
{
eventQueue
.
pop
();
}
cvEvent
.
notify_one
();
}
}
else
if
(
resp
[
"code"
]
==
6
)
{
// TODO: cloud storage issue. need stratigy policy
spdlog
::
warn
(
"evslicer {} TODO: handle cloud storage"
,
this
->
selfId
);
}
else
{
spdlog
::
error
(
"evslicer {} failed to upload videos. abort retry."
,
this
->
selfId
);
}
}
else
if
(
resp
[
"code"
]
==
6
)
{
// TODO: cloud storage issue. need stratigy policy
spdlog
::
warn
(
"evslicer {} TODO: handle cloud storage"
,
this
->
selfId
);
}
else
{
spdlog
::
error
(
"evslicer {} failed to upload videos. abort retry."
,
this
->
selfId
);
}
}
if
(
resp
.
count
(
"code"
)
!=
0
&&
resp
[
"code"
]
==
0
){
if
(
bUploadFailed
)
{
bUploadFailed
=
false
;
reportUploadFailure
(
selfId
,
false
,
strResp
);
}
}
}
catch
(
exception
&
e
)
{
spdlog
::
error
(
"evslicer {} {}:{} exception: {}"
,
this
->
selfId
,
__FILE__
,
__LINE__
,
e
.
what
());
}
}
catch
(
exception
&
e
)
{
spdlog
::
error
(
"evslicer {} {}:{} exception: {}"
,
this
->
selfId
,
__FILE__
,
__LINE__
,
e
.
what
());
}
}
}
...
...
opencv-motion-detect/inc/zmqhelper.hpp
浏览文件 @
edeb845c
...
...
@@ -46,6 +46,7 @@ namespace zmqhelper {
#define EV_MSG_REPORT_CATID_AVEOF "AV_EOF"
#define EV_MSG_REPORT_CATID_AVWRITEPIPE "AV_WRITEPIPE"
#define EV_MSG_REPORT_CATID_AVLOOPRESTART "AV_LOOPRESTART"
#define EV_MSG_REPORT_CATID_AVFAILEDUPLOAD "AV_FAILEDUPLOAD"
#define EV_MSG_META_VALUE_REPORT_LEVEL_INFO "info"
#define EV_MSG_META_VALUE_REPORT_LEVEL_DEBUG "debug"
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论