Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jz-dmp-service
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
姚本章
jz-dmp-service
Commits
d804ae96
Commit
d804ae96
authored
Mar 05, 2021
by
mcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit 数据运维
parent
4726f8d6
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
326 additions
and
57 deletions
+326
-57
FlowInstanceEnum.java
src/main/java/com/jz/common/enums/FlowInstanceEnum.java
+61
-0
AzkabanApiUtils2.java
src/main/java/com/jz/common/utils/AzkabanApiUtils2.java
+90
-39
ExecutionFlowsMapper.java
...ain/java/com/jz/dmp/azkaban/dao/ExecutionFlowsMapper.java
+1
-1
DmpDevExamplesController.java
...es/controller/dataOperation/DmpDevExamplesController.java
+22
-4
DmpDevTaskController.java
...odules/controller/dataOperation/DmpDevTaskController.java
+1
-1
SetSlaReq.java
.../dmp/modules/controller/dataOperation/bean/SetSlaReq.java
+41
-0
SetSlaRulesReq.java
...modules/controller/dataOperation/bean/SetSlaRulesReq.java
+42
-0
DmpDevelopTaskService.java
...ava/com/jz/dmp/modules/service/DmpDevelopTaskService.java
+9
-4
DmpDevelopTaskServiceImpl.java
...z/dmp/modules/service/impl/DmpDevelopTaskServiceImpl.java
+44
-6
ExecutionFlowsMapper.xml
src/main/resources/azkabanmapper/ExecutionFlowsMapper.xml
+14
-1
DmpDevelopTaskMapper.xml
src/main/resources/mapper/dmp/DmpDevelopTaskMapper.xml
+1
-1
No files found.
src/main/java/com/jz/common/enums/FlowInstanceEnum.java
0 → 100644
View file @
d804ae96
package
com
.
jz
.
common
.
enums
;
/**
* 业务流程实例状态
*
* @author Bellamy
* @since 2020-11-30 14:30:23
*/
public
enum
FlowInstanceEnum
{
/**
* 运行
*/
running
(
"running"
,
"30"
),
/**
* 成功
*/
success
(
"success"
,
"50"
),
kill
(
"kill"
,
"60"
),
failed
(
"failed"
,
"70"
),
;
private
String
code
;
private
String
value
;
private
FlowInstanceEnum
(
String
code
,
String
value
)
{
this
.
code
=
code
;
this
.
value
=
value
;
}
public
static
FlowInstanceEnum
get
(
String
code
)
{
if
(
code
==
null
)
{
return
null
;
}
for
(
FlowInstanceEnum
status
:
values
())
{
if
(
status
.
getCode
().
equalsIgnoreCase
(
code
))
{
return
status
;
}
}
return
null
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
String
getValue
()
{
return
value
;
}
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
}
}
src/main/java/com/jz/common/utils/AzkabanApiUtils2.java
View file @
d804ae96
...
...
@@ -7,6 +7,8 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.Map
;
import
com.jz.dmp.modules.controller.dataOperation.bean.SetSlaReq
;
import
com.jz.dmp.modules.controller.dataOperation.bean.SetSlaRulesReq
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.core.io.FileSystemResource
;
...
...
@@ -725,5 +727,54 @@ public class AzkabanApiUtils2 {
return
list
;
}
/**
* Set SLA
* @author Bellamy
* @return 调用成功后,返回execid
*/
@SuppressWarnings
(
"unchecked"
)
public
String
saveSla
(
SetSlaReq
req
)
{
String
sessionId
=
login
();
String
executeFlowUrl
=
azkabanServerUrl
+
"/schedule?token="
+
sessionId
;
LinkedMultiValueMap
<
String
,
Object
>
linkedMultiValueMap
=
new
LinkedMultiValueMap
<
String
,
Object
>();
linkedMultiValueMap
.
add
(
"session.id"
,
sessionId
);
linkedMultiValueMap
.
add
(
"ajax"
,
"setSla"
);
linkedMultiValueMap
.
add
(
"scheduleId"
,
req
.
getScheduleId
());
linkedMultiValueMap
.
add
(
"slaEmails"
,
req
.
getSlaEmails
());
List
<
SetSlaRulesReq
>
slaRule
=
req
.
getSlaRule
();
for
(
int
i
=
0
;
i
<
slaRule
.
size
();
i
++)
{
SetSlaRulesReq
sla
=
slaRule
.
get
(
i
);
linkedMultiValueMap
.
add
(
"settings["
+
i
+
"]"
,
sla
.
getFlow
()
+
","
+
sla
.
getSlaRule
()
+
","
+
sla
.
getDuration
()+
","
+
sla
.
getEmailNotification
()+
","
+
sla
.
getKill
());
}
Map
<
String
,
Object
>
postForObject
=
null
;
try
{
postForObject
=
bulidRestTemplate
().
postForObject
(
executeFlowUrl
,
linkedMultiValueMap
,
Map
.
class
);
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
executeFlowUrl
+
"----"
+
linkedMultiValueMap
+
"----设置SLA接口异常"
);
e
.
printStackTrace
();
throw
new
RuntimeException
(
"设置SLA接口异常"
);
}
if
(
postForObject
.
containsKey
(
"error"
)){
throw
new
RuntimeException
(
postForObject
.
get
(
"error"
).
toString
());
}
String
status
=
(
String
)
postForObject
.
get
(
"status"
);
if
(
"error"
.
equals
(
status
))
{
String
message
=
(
String
)
postForObject
.
get
(
"message"
);
throw
new
RuntimeException
(
message
);
}
/*Integer[] execIds = new Integer[] {};
if (postForObject.get("execIds")!=null) {
execIds = (Integer[])postForObject.get("execIds");
}
LOGGER.info("获取所有任务("+projectName+")正在调度execids"+execIds.toString());*/
return
null
;
}
}
src/main/java/com/jz/dmp/azkaban/dao/ExecutionFlowsMapper.java
View file @
d804ae96
...
...
@@ -40,5 +40,5 @@ public interface ExecutionFlowsMapper {
Map
<
String
,
Object
>
queryTaskInstanceStatus
()
throws
Exception
;
List
<
Map
>
queryLastStatus
(
@Param
(
"taskName"
)
String
[]
taskName
)
throws
Exception
;
List
<
Map
>
queryLastStatus
(
@Param
(
"taskName"
)
String
[]
taskName
,
@Param
(
"status"
)
String
status
)
throws
Exception
;
}
src/main/java/com/jz/dmp/modules/controller/dataOperation/DmpDevExamplesController.java
View file @
d804ae96
...
...
@@ -3,10 +3,7 @@ package com.jz.dmp.modules.controller.dataOperation;
import
com.jz.common.constant.JsonResult
;
import
com.jz.common.constant.ResultCode
;
import
com.jz.common.page.PageInfoResponse
;
import
com.jz.dmp.modules.controller.dataOperation.bean.DataDevExamplesListDto
;
import
com.jz.dmp.modules.controller.dataOperation.bean.DataDevExamplesListReq
;
import
com.jz.dmp.modules.controller.dataOperation.bean.DataDevTaskListDto
;
import
com.jz.dmp.modules.controller.dataOperation.bean.DataDevTaskListReq
;
import
com.jz.dmp.modules.controller.dataOperation.bean.*
;
import
com.jz.dmp.modules.service.DmpDevelopTaskService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
...
...
@@ -83,4 +80,25 @@ public class DmpDevExamplesController {
return
result
;
}
/**
* 设置SLA
*
* @return
* @author Bellamy
* @since 2021-02-03
*/
@ApiOperation
(
value
=
"设置SLA"
,
notes
=
"设置SLA"
)
@PostMapping
(
value
=
"/setSla"
)
public
JsonResult
setSla
(
@RequestBody
SetSlaReq
req
)
{
JsonResult
result
=
new
JsonResult
();
try
{
result
=
dmpDevelopTaskService
.
setSla
(
req
);
}
catch
(
Exception
e
)
{
result
.
setCode
(
ResultCode
.
INTERNAL_SERVER_ERROR
);
result
.
setMessage
(
"failed!"
);
e
.
printStackTrace
();
}
return
result
;
}
}
src/main/java/com/jz/dmp/modules/controller/dataOperation/DmpDevTaskController.java
View file @
d804ae96
...
...
@@ -84,7 +84,7 @@ public class DmpDevTaskController {
* @since 2021-02-22
*/
@ApiOperation
(
value
=
"运维大屏--重点关注任务状态"
,
notes
=
"重点关注"
)
@
Pos
tMapping
(
value
=
"/getTaskStatus"
)
@
Ge
tMapping
(
value
=
"/getTaskStatus"
)
public
JsonResult
getTaskStatus
(
@RequestParam
String
projectId
)
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
projectId
))
{
return
new
JsonResult
(
ResultCode
.
PARAMS_ERROR
,
"projectId不能为空!"
);
...
...
src/main/java/com/jz/dmp/modules/controller/dataOperation/bean/SetSlaReq.java
0 → 100644
View file @
d804ae96
package
com
.
jz
.
dmp
.
modules
.
controller
.
dataOperation
.
bean
;
import
com.jz.common.page.BasePageBean
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
javax.validation.constraints.NotEmpty
;
import
javax.validation.constraints.NotNull
;
import
java.io.Serializable
;
import
java.util.List
;
/**
* @ClassName: SetSlaReq
* @Description: set sla请求参数
* @Author:Bellamy
* @Date 2021/01/13
* @Version 1.0
*/
@Data
@ApiModel
(
value
=
"set sla请求参数"
,
description
=
"et sla请求参数"
)
public
class
SetSlaReq
implements
Serializable
{
private
static
final
long
serialVersionUID
=
4274039208139198292L
;
@ApiModelProperty
(
value
=
"scheduleId"
)
private
String
scheduleId
;
@ApiModelProperty
(
value
=
"邮件"
)
private
String
slaEmails
;
@ApiModelProperty
(
value
=
"sla规则"
)
private
List
<
SetSlaRulesReq
>
slaRule
;
@ApiModelProperty
(
value
=
"projectId"
)
@NotEmpty
(
message
=
"projectId不能为空!"
)
@NotNull
(
message
=
"projectId不能为空!"
)
private
String
projectId
;
}
src/main/java/com/jz/dmp/modules/controller/dataOperation/bean/SetSlaRulesReq.java
0 → 100644
View file @
d804ae96
package
com
.
jz
.
dmp
.
modules
.
controller
.
dataOperation
.
bean
;
import
com.jz.common.page.BasePageBean
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
javax.validation.constraints.NotEmpty
;
import
javax.validation.constraints.NotNull
;
import
java.io.Serializable
;
/**
* @ClassName: SetSlaRulesReq
* @Description: 数据运维-SLA请求参数
* @Author:Bellamy
* @Date 2021/01/13
* @Version 1.0
*/
@Data
@ApiModel
(
value
=
"SLA请求参数"
,
description
=
"SLA请求参数"
)
public
class
SetSlaRulesReq
implements
Serializable
{
private
static
final
long
serialVersionUID
=
7548870996371216281L
;
@ApiModelProperty
(
value
=
"flow/job"
)
@NotNull
(
message
=
"flow/job不能为空"
)
@NotEmpty
(
message
=
"flow/job不能为空"
)
private
String
flow
;
@ApiModelProperty
(
value
=
"sla 规则"
)
private
String
slaRule
;
@ApiModelProperty
(
value
=
"duration"
)
private
String
duration
;
@ApiModelProperty
(
value
=
"邮件通知"
)
private
Boolean
emailNotification
;
@ApiModelProperty
(
value
=
"kill"
)
private
Boolean
kill
;
}
src/main/java/com/jz/dmp/modules/service/DmpDevelopTaskService.java
View file @
d804ae96
...
...
@@ -9,10 +9,7 @@ import com.jz.common.page.PageInfoResponse;
import
com.jz.dmp.modules.controller.DataIntegration.bean.flow.FlowPro
;
import
com.jz.dmp.modules.controller.bean.DmpDevelopTaskDto
;
import
com.jz.dmp.modules.controller.bean.DmpDevelopTaskRequest
;
import
com.jz.dmp.modules.controller.dataOperation.bean.DataDevExamplesListDto
;
import
com.jz.dmp.modules.controller.dataOperation.bean.DataDevExamplesListReq
;
import
com.jz.dmp.modules.controller.dataOperation.bean.DataDevTaskListDto
;
import
com.jz.dmp.modules.controller.dataOperation.bean.DataDevTaskListReq
;
import
com.jz.dmp.modules.controller.dataOperation.bean.*
;
import
com.jz.dmp.modules.model.DmpDevelopTask
;
/**
...
...
@@ -183,4 +180,12 @@ public interface DmpDevelopTaskService {
* @since 2021-02-22
*/
JsonResult
getTaskStatus
(
String
projectId
)
throws
Exception
;
/**
* 设置SLA
*
* @return
* @author Bellamy
* @since 2021-02-03
*/
JsonResult
setSla
(
SetSlaReq
req
)
throws
Exception
;
}
\ No newline at end of file
src/main/java/com/jz/dmp/modules/service/impl/DmpDevelopTaskServiceImpl.java
View file @
d804ae96
...
...
@@ -12,6 +12,7 @@ import com.jz.common.constant.CommConstant;
import
com.jz.common.constant.JsonResult
;
import
com.jz.common.constant.ResultCode
;
import
com.jz.common.constant.StatuConstant
;
import
com.jz.common.enums.FlowInstanceEnum
;
import
com.jz.common.enums.ModuleLogEnum
;
import
com.jz.common.page.PageInfoResponse
;
import
com.jz.common.persistence.BaseService
;
...
...
@@ -24,10 +25,7 @@ import com.jz.dmp.modules.controller.bean.DmpDevelopTaskDto;
import
com.jz.dmp.modules.controller.bean.DmpDevelopTaskRequest
;
import
com.jz.dmp.modules.controller.bean.MyDmpDevelopTaskConverter
;
import
com.jz.dmp.modules.controller.bean.MyDmpDevelopTaskHistoryConverter
;
import
com.jz.dmp.modules.controller.dataOperation.bean.DataDevExamplesListDto
;
import
com.jz.dmp.modules.controller.dataOperation.bean.DataDevExamplesListReq
;
import
com.jz.dmp.modules.controller.dataOperation.bean.DataDevTaskListDto
;
import
com.jz.dmp.modules.controller.dataOperation.bean.DataDevTaskListReq
;
import
com.jz.dmp.modules.controller.dataOperation.bean.*
;
import
com.jz.dmp.modules.controller.projconfig.bean.DmpProjectConfigInfoDto
;
import
com.jz.dmp.modules.dao.*
;
import
com.jz.dmp.modules.dao.projconfig.DmpProjectConfigInfoMapper
;
...
...
@@ -789,6 +787,16 @@ public class DmpDevelopTaskServiceImpl extends BaseService implements DmpDevelop
req
.
setTreeIdOrName
(
req
.
getTreeIdOrName
().
trim
());
//节点名称
}
}
if
(
StringUtils
.
isNotBlank
(
req
.
getStatus
()))
{
if
(
FlowInstanceEnum
.
running
.
getCode
().
equals
(
req
.
getStatus
()))
{
req
.
setStatus
(
FlowInstanceEnum
.
running
.
getValue
());
}
else
if
(
FlowInstanceEnum
.
failed
.
getCode
().
equals
(
req
.
getStatus
()))
{
req
.
setStatus
(
FlowInstanceEnum
.
failed
.
getValue
());
}
else
{
//全部
req
.
setStatus
(
""
);
}
}
PageHelper
.
startPage
(
req
.
getPageNum
(),
req
.
getPageSize
());
List
<
DataDevTaskListDto
>
list
=
dmpDevelopTaskDao
.
queryDevTaskListPage
(
req
);
...
...
@@ -798,11 +806,21 @@ public class DmpDevelopTaskServiceImpl extends BaseService implements DmpDevelop
pageInfoResponse
.
setMessage
(
"查询成功"
);
pageInfoResponse
.
setData
(
pageInfo
);
String
taskName
=
""
;
List
<
DataDevTaskListDto
>
listObj
=
(
List
<
DataDevTaskListDto
>)
pageInfo
;
List
<
DataDevTaskListDto
>
listObj
=
pageInfoResponse
.
getData
().
getList
()
;
for
(
DataDevTaskListDto
str
:
listObj
)
{
taskName
+=
","
+
str
.
getTaskName
();
}
List
<
Map
>
flowList
=
executionFlowsMapper
.
queryLastStatus
(
taskName
.
substring
(
1
).
split
(
","
));
//查询实例最后执行状态
List
<
Map
>
flowList
=
executionFlowsMapper
.
queryLastStatus
(
taskName
.
substring
(
1
).
split
(
","
),
req
.
getStatus
());
if
(
flowList
.
size
()
>
0
&&
flowList
!=
null
)
{
for
(
DataDevTaskListDto
str
:
listObj
)
{
for
(
Map
strFlow
:
flowList
)
{
if
(
str
.
getTaskName
().
equals
(
strFlow
.
get
(
"taskName"
)))
{
str
.
setStatus
(
String
.
valueOf
(
strFlow
.
get
(
"status"
)));
}
}
}
}
return
pageInfoResponse
;
}
...
...
@@ -1611,4 +1629,24 @@ public class DmpDevelopTaskServiceImpl extends BaseService implements DmpDevelop
return
JsonResult
.
ok
(
taskStatus
);
}
/**
* 设置SLA
*
* @return
* @author Bellamy
* @since 2021-02-03
*/
@Override
public
JsonResult
setSla
(
SetSlaReq
req
)
throws
Exception
{
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
Long
projectId
=
Long
.
valueOf
(
req
.
getProjectId
());
//项目id
DmpProjectSystemInfo
publishToProjectSystemInfo
=
dmpProjectDao
.
queryProjectSystemInfo
(
projectId
);
//调用azkaban服务
String
azkabanApiUrl
=
publishToProjectSystemInfo
.
getAzkabanMonitorUrl
();
AzkabanApiUtils2
azkabanApiUtils
=
new
AzkabanApiUtils2
(
azkabanApiUrl
,
redisTemplate
);
azkabanApiUtils
.
saveSla
(
req
);
return
null
;
}
}
\ No newline at end of file
src/main/resources/azkabanmapper/ExecutionFlowsMapper.xml
View file @
d804ae96
...
...
@@ -222,7 +222,20 @@
)t
</select>
<select
id=
"queryLastStatus"
resultType=
"java.util.Map"
>
SELECT
exec_id AS execId,
flow_id AS taskName,
max(from_unixtime( submit_time / 1000, '%Y-%m-%d %H:%i:%s' )) AS startTime,
(case when status='30' then '运行中' when status='50' then '成功' when status='70' then '失败' end) status
FROM
execution_flows
WHERE 1 = 1
<if
test=
"status != null and status !='' "
>
and status=#{status}
</if>
and flow_id in
<foreach
collection=
"taskName"
item=
"item"
open=
"("
separator=
","
close=
")"
>
#{item}
</foreach>
group by flow_id
</select>
</mapper>
\ No newline at end of file
src/main/resources/mapper/dmp/DmpDevelopTaskMapper.xml
View file @
d804ae96
...
...
@@ -177,7 +177,7 @@
dmp_navigation_tree t1
inner join dmp_develop_task t2 on t2.TREE_ID=t1.ID and t2.data_status ='1'
left join dmp_member t3 on t1.create_user_id=t3.user_id
where 1=1 and IS_LEVEL ='1'
where 1=1 and IS_LEVEL ='1'
and t1.data_status ='1'
and t1.project_id = #{projectId}
<if
test=
"taskId != null and taskId != ''"
>
and t2.id =#{taskId}
</if>
<if
test=
"treeIdOrName != null and treeIdOrName != ''"
>
and t1.name like concat('%',#{treeIdOrName},'%')
</if>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment