Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
Project
Project
Details
Activity
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
wangpeng
dinky
Commits
fa1ce86a
Unverified
Commit
fa1ce86a
authored
Dec 24, 2023
by
aiwenmo
Committed by
GitHub
Dec 24, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Fix-2731] [scheduler] Fix push task to dolphinscheduler (#2732)
Co-authored-by:
wenmo
<
32723967+wenmo@users.noreply.github.com
>
parent
5df10a4a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
49 additions
and
97 deletions
+49
-97
SchedulerController.java
...c/main/java/org/dinky/controller/SchedulerController.java
+0
-4
SchedulerServiceImpl.java
...ain/java/org/dinky/service/impl/SchedulerServiceImpl.java
+0
-0
ProcessClient.java
...c/main/java/org/dinky/scheduler/client/ProcessClient.java
+12
-7
TaskClient.java
.../src/main/java/org/dinky/scheduler/client/TaskClient.java
+1
-1
DagNodeLocation.java
.../main/java/org/dinky/scheduler/model/DagNodeLocation.java
+2
-0
ProcessTaskRelation.java
...n/java/org/dinky/scheduler/model/ProcessTaskRelation.java
+12
-0
TaskDefinition.java
...c/main/java/org/dinky/scheduler/model/TaskDefinition.java
+3
-0
TaskRequest.java
.../src/main/java/org/dinky/scheduler/model/TaskRequest.java
+3
-0
ReadFileUtil.java
...src/main/java/org/dinky/scheduler/utils/ReadFileUtil.java
+0
-80
pages.ts
dinky-web/src/locales/en-US/pages.ts
+2
-0
pages.ts
dinky-web/src/locales/zh-CN/pages.ts
+2
-0
function.tsx
...pages/DataStudio/HeaderContainer/PushDolphin/function.tsx
+2
-0
index.tsx
...rc/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx
+7
-0
index.tsx
dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx
+0
-5
data.d.ts
dinky-web/src/types/Studio/data.d.ts
+2
-0
init.d.ts
dinky-web/src/types/Studio/init.d.ts
+1
-0
No files found.
dinky-admin/src/main/java/org/dinky/controller/SchedulerController.java
View file @
fa1ce86a
...
...
@@ -35,7 +35,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
cn.hutool.core.collection.CollUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -84,9 +83,6 @@ public class SchedulerController {
example
=
"1"
)
public
Result
<
List
<
TaskMainInfo
>>
getTaskMainInfos
(
@ApiParam
(
value
=
"dinky任务id"
)
@RequestParam
Long
dinkyTaskId
)
{
List
<
TaskMainInfo
>
taskMainInfos
=
schedulerService
.
getTaskMainInfos
(
dinkyTaskId
);
if
(
CollUtil
.
isEmpty
(
taskMainInfos
))
{
return
Result
.
failed
();
}
return
Result
.
succeed
(
taskMainInfos
);
}
...
...
dinky-admin/src/main/java/org/dinky/service/impl/SchedulerServiceImpl.java
View file @
fa1ce86a
This diff is collapsed.
Click to expand it.
dinky-scheduler/src/main/java/org/dinky/scheduler/client/ProcessClient.java
View file @
fa1ce86a
...
...
@@ -28,7 +28,7 @@ import org.dinky.scheduler.result.PageInfo;
import
org.dinky.scheduler.result.Result
;
import
org.dinky.scheduler.utils.MyJSONUtil
;
import
org.dinky.scheduler.utils.ParamUtil
;
import
org.dinky.
scheduler.utils.ReadFileUtil
;
import
org.dinky.
utils.JsonUtils
;
import
java.util.ArrayList
;
import
java.util.Collections
;
...
...
@@ -75,7 +75,7 @@ public class ProcessClient {
.
getDolphinschedulerToken
()
.
getValue
())
.
form
(
ParamUtil
.
getPageParams
(
processName
))
.
timeout
(
5
000
)
.
timeout
(
20
000
)
.
execute
()
.
body
();
PageInfo
<
JSONObject
>
data
=
MyJSONUtil
.
toPageBean
(
content
);
...
...
@@ -85,7 +85,11 @@ public class ProcessClient {
}
for
(
JSONObject
jsonObject
:
data
.
getTotalList
())
{
lists
.
add
(
MyJSONUtil
.
toBean
(
jsonObject
,
ProcessDefinition
.
class
));
ProcessDefinition
processDefinition
=
MyJSONUtil
.
toBean
(
jsonObject
,
ProcessDefinition
.
class
);
// The locations of processDefinition is json string
List
<
DagNodeLocation
>
locations
=
jsonObject
.
getBeanList
(
"locations"
,
DagNodeLocation
.
class
);
processDefinition
.
setLocations
(
locations
);
lists
.
add
(
processDefinition
);
}
return
lists
;
}
...
...
@@ -127,7 +131,7 @@ public class ProcessClient {
SystemConfiguration
.
getInstances
()
.
getDolphinschedulerToken
()
.
getValue
())
.
timeout
(
5
000
)
.
timeout
(
20
000
)
.
execute
()
.
body
();
...
...
@@ -148,6 +152,7 @@ public class ProcessClient {
Long
processCode
,
String
processName
,
Long
taskCode
,
String
taskRelationJson
,
String
taskDefinitionJson
,
List
<
DagNodeLocation
>
locations
,
boolean
isModify
)
{
...
...
@@ -160,8 +165,8 @@ public class ProcessClient {
params
.
put
(
"name"
,
processName
);
params
.
put
(
"description"
,
"系统添加"
);
params
.
put
(
"tenantCode"
,
"default"
);
params
.
put
(
"locations"
,
locations
);
params
.
put
(
"taskRelationJson"
,
ReadFileUtil
.
taskRelation
(
Collections
.
singletonMap
(
"code"
,
taskCode
))
);
params
.
put
(
"locations"
,
JsonUtils
.
toJsonString
(
locations
)
);
params
.
put
(
"taskRelationJson"
,
taskRelationJson
);
params
.
put
(
"taskDefinitionJson"
,
taskDefinitionJson
);
params
.
put
(
"executionType"
,
"PARALLEL"
);
...
...
@@ -178,7 +183,7 @@ public class ProcessClient {
.
getDolphinschedulerToken
()
.
getValue
())
.
form
(
params
)
.
timeout
(
5
000
)
.
timeout
(
20
000
)
.
execute
();
String
content
=
httpResponse
.
body
();
return
MyJSONUtil
.
verifyResult
(
MyJSONUtil
.
toBean
(
content
,
new
TypeReference
<
Result
<
ProcessDefinition
>>()
{}));
...
...
dinky-scheduler/src/main/java/org/dinky/scheduler/client/TaskClient.java
View file @
fa1ce86a
...
...
@@ -138,7 +138,7 @@ public class TaskClient {
SystemConfiguration
.
getInstances
()
.
getDolphinschedulerToken
()
.
getValue
())
.
timeout
(
5
000
)
.
timeout
(
20
000
)
.
execute
()
.
body
();
...
...
dinky-scheduler/src/main/java/org/dinky/scheduler/model/DagNodeLocation.java
View file @
fa1ce86a
...
...
@@ -26,6 +26,8 @@ import lombok.Data;
@Data
public
class
DagNodeLocation
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
5243356147439794746L
;
private
long
taskCode
;
private
long
x
;
private
long
y
;
...
...
dinky-scheduler/src/main/java/org/dinky/scheduler/model/ProcessTaskRelation.java
View file @
fa1ce86a
...
...
@@ -67,4 +67,16 @@ public class ProcessTaskRelation {
@ApiModelProperty
(
value
=
"更新时间"
)
private
Date
updateTime
;
public
static
ProcessTaskRelation
generateProcessTaskRelation
(
long
taskCode
)
{
ProcessTaskRelation
processTaskRelation
=
new
ProcessTaskRelation
();
processTaskRelation
.
setName
(
""
);
processTaskRelation
.
setPreTaskCode
(
0
);
processTaskRelation
.
setPreTaskVersion
(
0
);
processTaskRelation
.
setPostTaskCode
(
taskCode
);
processTaskRelation
.
setPostTaskVersion
(
1
);
processTaskRelation
.
setConditionType
(
ConditionType
.
NONE
);
processTaskRelation
.
setConditionParams
(
"{}"
);
return
processTaskRelation
;
}
}
dinky-scheduler/src/main/java/org/dinky/scheduler/model/TaskDefinition.java
View file @
fa1ce86a
...
...
@@ -74,6 +74,9 @@ public class TaskDefinition {
@ApiModelProperty
(
value
=
"运行标志 yes 正常/no 禁止执行"
)
private
Flag
flag
;
@ApiModelProperty
(
value
=
"Cache run: yes/no "
)
private
Flag
isCache
;
@ApiModelProperty
(
value
=
"优先级"
)
private
Priority
taskPriority
;
...
...
dinky-scheduler/src/main/java/org/dinky/scheduler/model/TaskRequest.java
View file @
fa1ce86a
...
...
@@ -53,6 +53,9 @@ public class TaskRequest {
@ApiModelProperty
(
value
=
"运行标志 yes 正常/no 禁止执行"
)
private
String
flag
;
@ApiModelProperty
(
value
=
"Cache run: yes/no"
)
private
String
isCache
;
@ApiModelProperty
(
value
=
"任务参数 默认DINKY参数"
)
private
String
taskParams
;
...
...
dinky-scheduler/src/main/java/org/dinky/scheduler/utils/ReadFileUtil.java
deleted
100644 → 0
View file @
5df10a4a
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org
.
dinky
.
scheduler
.
utils
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.Map
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
cn.hutool.core.io.IoUtil
;
import
cn.hutool.core.util.StrUtil
;
public
class
ReadFileUtil
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ReadFileUtil
.
class
);
public
static
String
taskDefinition
(
Map
<
String
,
Object
>
maps
)
{
InputStream
in
=
ReadFileUtil
.
class
.
getResourceAsStream
(
"/json/taskDefinition.json"
);
String
readFile
=
readFile
(
in
);
if
(
maps
==
null
||
maps
.
isEmpty
())
{
return
readFile
;
}
return
StrUtil
.
format
(
readFile
,
maps
);
}
public
static
String
taskRelation
(
Map
<
String
,
Object
>
maps
)
{
InputStream
in
=
ReadFileUtil
.
class
.
getResourceAsStream
(
"/json/taskRelation.json"
);
String
readFile
=
readFile
(
in
);
if
(
maps
==
null
||
maps
.
isEmpty
())
{
return
readFile
;
}
return
StrUtil
.
format
(
readFile
,
maps
);
}
public
static
String
createTaskDefinition
(
Map
<
String
,
Object
>
maps
)
{
InputStream
in
=
ReadFileUtil
.
class
.
getResourceAsStream
(
"/json/createTaskDefinition.json"
);
String
readFile
=
readFile
(
in
);
if
(
maps
==
null
||
maps
.
isEmpty
())
{
return
readFile
;
}
return
StrUtil
.
format
(
readFile
,
maps
);
}
/** 读取文件 */
public
static
String
readFile
(
InputStream
inputStream
)
{
try
{
BufferedReader
reader
=
IoUtil
.
getUtf8Reader
(
inputStream
);
int
ch
;
StringBuilder
sb
=
new
StringBuilder
();
while
((
ch
=
reader
.
read
())
!=
-
1
)
{
sb
.
append
((
char
)
ch
);
}
IoUtil
.
close
(
reader
);
return
sb
.
toString
();
}
catch
(
IOException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
return
null
;
}
}
}
dinky-web/src/locales/en-US/pages.ts
View file @
fa1ce86a
...
...
@@ -109,6 +109,8 @@ export default {
'datastudio.header.pushdolphin.timeoutFlagTip'
:
'Please select a timeout warning'
,
'datastudio.header.pushdolphin.flag'
:
'Run flag'
,
'datastudio.header.pushdolphin.flagTip'
:
'Please select the run flag'
,
'datastudio.header.pushdolphin.isCache'
:
'Cache run'
,
'datastudio.header.pushdolphin.isCacheTip'
:
'Please select cache run'
,
'datastudio.header.pushdolphin.timeoutNotifyStrategy'
:
'Timeout notification strategy'
,
'datastudio.header.pushdolphin.timeoutNotifyStrategyTip'
:
'Please select a timeout notification strategy'
,
...
...
dinky-web/src/locales/zh-CN/pages.ts
View file @
fa1ce86a
...
...
@@ -102,6 +102,8 @@ export default {
'datastudio.header.pushdolphin.timeoutFlagTip'
:
'请选择超时警告'
,
'datastudio.header.pushdolphin.flag'
:
'运行标志'
,
'datastudio.header.pushdolphin.flagTip'
:
'请选择运行标志'
,
'datastudio.header.pushdolphin.isCache'
:
'缓存执行'
,
'datastudio.header.pushdolphin.isCacheTip'
:
'请选择是否缓存执行'
,
'datastudio.header.pushdolphin.timeoutNotifyStrategy'
:
'超时通知策略'
,
'datastudio.header.pushdolphin.timeoutNotifyStrategyTip'
:
'请选择超时通知策略'
,
'datastudio.header.pushdolphin.timeout'
:
'超时时间(分钟)'
,
...
...
dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/function.tsx
View file @
fa1ce86a
...
...
@@ -30,6 +30,7 @@ export const transformPushDolphinParams = (
description
:
dolphinTaskDefinition
.
description
,
timeoutFlag
:
dolphinTaskDefinition
.
timeoutFlag
===
'OPEN'
,
flag
:
dolphinTaskDefinition
.
flag
===
'YES'
,
isCache
:
dolphinTaskDefinition
.
isCache
===
'YES'
,
upstreamCodes
:
dolphinTaskDefinition
.
upstreamTaskMap
?
Object
.
keys
(
dolphinTaskDefinition
.
upstreamTaskMap
)
:
[],
...
...
@@ -46,6 +47,7 @@ export const transformPushDolphinParams = (
description
:
pushDolphinParams
.
description
,
timeoutFlag
:
pushDolphinParams
.
timeoutFlag
?
'OPEN'
:
'CLOSE'
,
flag
:
pushDolphinParams
.
flag
?
'YES'
:
'NO'
,
isCache
:
pushDolphinParams
.
isCache
?
'YES'
:
'NO'
,
timeoutNotifyStrategy
:
(
pushDolphinParams
.
timeoutNotifyStrategy
as
string
[]).
join
(
''
)
};
return
falseTransformValue
;
...
...
dinky-web/src/pages/DataStudio/HeaderContainer/PushDolphin/index.tsx
View file @
fa1ce86a
...
...
@@ -239,6 +239,13 @@ export const PushDolphin: React.FC<PushDolphinProps> = (props) => {
{
...
SWITCH_OPTIONS
()}
name=
{
'flag'
}
/>
<
ProFormSwitch
label=
{
l
(
'datastudio.header.pushdolphin.isCache'
)
}
rules=
{
[{
required
:
true
,
message
:
l
(
'datastudio.header.pushdolphin.isCacheTip'
)
}]
}
{
...
SWITCH_OPTIONS
()}
name=
{
'isCache'
}
/>
</
ProFormGroup
>
{
/*如果是失败告警,则需要设置告警策略*/
}
{
formValues
.
timeoutFlag
&&
(
...
...
dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx
View file @
fa1ce86a
...
...
@@ -55,7 +55,6 @@ import { API_CONSTANTS } from '@/services/endpoints';
import
{
Jobs
}
from
'@/types/DevOps/data.d'
;
import
{
DolphinTaskDefinition
,
DolphinTaskMinInfo
}
from
'@/types/Studio/data.d'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
SuccessMessageAsync
}
from
'@/utils/messages'
;
import
{
ApartmentOutlined
,
BugOutlined
,
...
...
@@ -190,8 +189,6 @@ const HeaderContainer = (props: connect) => {
const
handlerDebug
=
async
()
=>
{
if
(
!
currentData
)
return
;
const
saved
=
currentData
.
step
==
JOB_LIFE_CYCLE
.
PUBLISH
?
true
:
await
handleSave
();
if
(
!
saved
)
return
;
// @ts-ignore
const
editor
=
currentTab
.
monacoInstance
.
editor
.
getEditors
()
...
...
@@ -217,7 +214,6 @@ const HeaderContainer = (props: connect) => {
jobState
:
res
.
data
.
status
,
runningLog
:
res
.
msg
});
await
SuccessMessageAsync
(
l
(
'pages.datastudio.editor.debug.success'
));
currentData
.
status
=
JOB_STATUS
.
RUNNING
;
// Common sql task is synchronized, so it needs to automatically update the status to finished.
if
(
isSql
(
currentData
.
dialect
))
{
...
...
@@ -251,7 +247,6 @@ const HeaderContainer = (props: connect) => {
jobState
:
res
.
data
.
status
,
runningLog
:
res
.
msg
});
await
SuccessMessageAsync
(
l
(
'pages.datastudio.editor.exec.success'
));
currentData
.
status
=
JOB_STATUS
.
RUNNING
;
// Common sql task is synchronized, so it needs to automatically update the status to finished.
if
(
isSql
(
currentData
.
dialect
))
{
...
...
dinky-web/src/types/Studio/data.d.ts
View file @
fa1ce86a
...
...
@@ -267,6 +267,7 @@ export interface DolphinTaskDefinition {
taskParamList
:
TaskParamProperty
[];
taskParamMap
:
Map
<
string
,
string
>
;
flag
:
string
;
// 0 no 1 yes
isCache
:
string
;
// 0 no 1 yes
taskPriority
:
string
;
// 0 highest 1 high 2 medium 3 low 4 lowest
userName
:
string
;
projectName
:
string
;
...
...
@@ -303,6 +304,7 @@ export interface PushDolphinParams {
timeout
:
number
;
timeoutFlag
:
boolean
|
string
;
flag
:
boolean
|
string
;
isCache
:
boolean
|
string
;
timeoutNotifyStrategy
:
string
[]
|
string
;
description
:
string
;
}
dinky-web/src/types/Studio/init.d.ts
View file @
fa1ce86a
...
...
@@ -48,6 +48,7 @@ export const InitPushDolphinParams: PushDolphinParams = {
timeout
:
30
,
timeoutFlag
:
false
,
flag
:
false
,
isCache
:
false
,
timeoutNotifyStrategy
:
[
'WARN'
],
description
:
''
};
...
...
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