Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
byit-myth-job
Overview
Overview
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
liyuan
byit-myth-job
Commits
4037ac2c
Commit
4037ac2c
authored
Nov 30, 2020
by
huangfusuper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
设置结束回调方法
parent
40aeadac
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
10 deletions
+45
-10
RunRecordingWrapped.java
...-core/src/main/java/com/byit/dto/RunRecordingWrapped.java
+4
-0
RpcCallbackInstanceRunTheLifeCycleCallback.java
...tegy/impl/RpcCallbackInstanceRunTheLifeCycleCallback.java
+38
-9
CallbackDto.java
...o-core/src/main/java/com/byit/dto/common/CallbackDto.java
+1
-0
FlowExtendedConfiguration.java
...n/java/com/byit/dto/plugin/FlowExtendedConfiguration.java
+2
-1
No files found.
byit-myth-core/myth-admin-core/src/main/java/com/byit/dto/RunRecordingWrapped.java
View file @
4037ac2c
...
...
@@ -2,7 +2,9 @@ package com.byit.dto;
import
com.byit.model.JobTask
;
import
com.byit.model.RunRecording
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serializable
;
import
java.util.List
;
...
...
@@ -14,6 +16,8 @@ import java.util.List;
* @date 2020年11月25日18:31:07
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
RunRecordingWrapped
implements
Serializable
{
private
static
final
long
serialVersionUID
=
6309696511670011734L
;
...
...
byit-myth-core/myth-admin-core/src/main/java/com/byit/strategy/impl/RpcCallbackInstanceRunTheLifeCycleCallback.java
View file @
4037ac2c
...
...
@@ -18,7 +18,9 @@ import com.byit.param.CommunicationParam;
import
com.byit.service.WorkspaceService
;
import
com.byit.strategy.InstanceRunTheLifeCycleCallback
;
import
com.byit.task.annotations.TaskClient
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
...
...
@@ -31,15 +33,19 @@ import java.util.stream.Collectors;
* @author huangfu
*/
@Component
@Slf4j
public
class
RpcCallbackInstanceRunTheLifeCycleCallback
implements
InstanceRunTheLifeCycleCallback
{
public
static
final
String
EXTENDED_PARAMS_S
=
"extended:params:%s"
;
@TaskClient
(
timeout
=
30000
,
callMethodEnum
=
CallMethodEnum
.
SYNCHRONIZE
)
private
TaskServer
taskServer
;
private
final
WorkspaceService
workspaceService
;
private
final
StringRedisTemplate
stringRedisTemplate
;
public
RpcCallbackInstanceRunTheLifeCycleCallback
(
WorkspaceService
workspaceService
)
{
public
RpcCallbackInstanceRunTheLifeCycleCallback
(
WorkspaceService
workspaceService
,
StringRedisTemplate
stringRedisTemplate
)
{
this
.
workspaceService
=
workspaceService
;
this
.
stringRedisTemplate
=
stringRedisTemplate
;
}
/**
...
...
@@ -51,10 +57,22 @@ public class RpcCallbackInstanceRunTheLifeCycleCallback implements InstanceRunTh
*/
@Override
public
RunRecordingWrapped
postProcessAfterInitialization
(
RunRecording
runRecording
,
List
<
JobTask
>
jobTaskList
)
{
PluginRpcRequestPacket
param
=
buildPluginRpcRequestPacket
(
runRecording
);
String
extendedConfiguration
=
runRecording
.
getExtendedConfiguration
();
FlowExtendedConfiguration
flowExtendedConfiguration
=
JSON
.
parseObject
(
extendedConfiguration
,
FlowExtendedConfiguration
.
class
);
if
(
flowExtendedConfiguration
==
null
){
return
new
RunRecordingWrapped
(
jobTaskList
,
runRecording
);
}
String
rpcServerKey
=
flowExtendedConfiguration
.
getRpcStartServerKey
();
if
(
StringUtils
.
isBlank
(
rpcServerKey
)){
return
new
RunRecordingWrapped
(
jobTaskList
,
runRecording
);
}
CallbackDto
callbackDto
=
new
CallbackDto
();
PluginRpcRequestPacket
param
=
buildPluginRpcRequestPacket
(
runRecording
,
callbackDto
,
rpcServerKey
);
PluginRpcResponsePacket
call
=
taskServer
.
call
(
param
);
Object
result
=
call
.
getResult
();
ScriptParamAndPlaceholderDto
rpcScriptParamAndPlaceholderDto
=
(
ScriptParamAndPlaceholderDto
)
result
;
//放置到对应的redis里面
stringRedisTemplate
.
opsForValue
().
set
(
String
.
format
(
EXTENDED_PARAMS_S
,
runRecording
.
getRunId
()),
JSON
.
toJSONString
(
rpcScriptParamAndPlaceholderDto
));
if
(
rpcScriptParamAndPlaceholderDto
!=
null
)
{
List
<
JobTask
>
jobTasks
=
jobTaskList
.
stream
().
map
(
jobTask
->
{
//新增参数
...
...
@@ -131,19 +149,14 @@ public class RpcCallbackInstanceRunTheLifeCycleCallback implements InstanceRunTh
* @param runRecording 执行实例
* @return {@link PluginRpcRequestPacket}
*/
private
PluginRpcRequestPacket
buildPluginRpcRequestPacket
(
RunRecording
runRecording
)
{
private
PluginRpcRequestPacket
buildPluginRpcRequestPacket
(
RunRecording
runRecording
,
CallbackDto
callbackDto
,
String
serverKey
)
{
PluginRpcRequestPacket
rpcRequestPacket
=
new
PluginRpcRequestPacket
();
String
extendedConfiguration
=
runRecording
.
getExtendedConfiguration
();
FlowExtendedConfiguration
flowExtendedConfiguration
=
JSON
.
parseObject
(
extendedConfiguration
,
FlowExtendedConfiguration
.
class
);
String
rpcServerKey
=
flowExtendedConfiguration
.
getRpcServerKey
();
rpcRequestPacket
.
setCallMethodEnum
(
CallMethodEnum
.
SYNCHRONIZE
);
rpcRequestPacket
.
setJobName
(
rpcS
erverKey
);
rpcRequestPacket
.
setJobName
(
s
erverKey
);
CommunicationParam
param
=
new
CommunicationParam
();
param
.
setRunId
(
runRecording
.
getRunId
());
param
.
setHasMakeUp
(
String
.
valueOf
(
runRecording
.
getScheduleType
()));
CallbackDto
callbackDto
=
new
CallbackDto
();
callbackDto
.
setFlowName
(
runRecording
.
getFlowName
());
callbackDto
.
setVersionName
(
runRecording
.
getFlowVersionName
());
...
...
@@ -163,5 +176,21 @@ public class RpcCallbackInstanceRunTheLifeCycleCallback implements InstanceRunTh
@Override
public
void
postProcessBeforeInitialization
(
RunRecording
runRecording
)
{
String
extendedConfiguration
=
runRecording
.
getExtendedConfiguration
();
FlowExtendedConfiguration
flowExtendedConfiguration
=
JSON
.
parseObject
(
extendedConfiguration
,
FlowExtendedConfiguration
.
class
);
if
(
flowExtendedConfiguration
==
null
){
return
;
}
String
rpcEndServerKey
=
flowExtendedConfiguration
.
getRpcEndServerKey
();
if
(
StringUtils
.
isBlank
(
rpcEndServerKey
)){
return
;
}
String
extendedParam
=
stringRedisTemplate
.
opsForValue
().
get
(
String
.
format
(
EXTENDED_PARAMS_S
,
runRecording
.
getRunId
()));
CallbackDto
callbackDto
=
new
CallbackDto
();
callbackDto
.
setData
(
extendedParam
);
PluginRpcRequestPacket
rpcRequestPacket
=
buildPluginRpcRequestPacket
(
runRecording
,
callbackDto
,
rpcEndServerKey
);
PluginRpcResponsePacket
call
=
taskServer
.
call
(
rpcRequestPacket
);
log
.
info
(
"回调{}通讯成功!"
,
call
);
}
}
byit-myth-core/myth-dto-core/src/main/java/com/byit/dto/common/CallbackDto.java
View file @
4037ac2c
...
...
@@ -17,4 +17,5 @@ public class CallbackDto implements Serializable {
private
String
flowName
;
private
String
workspaceName
;
private
String
versionName
;
private
String
data
;
}
byit-myth-core/myth-dto-core/src/main/java/com/byit/dto/plugin/FlowExtendedConfiguration.java
View file @
4037ac2c
...
...
@@ -10,5 +10,6 @@ import lombok.Data;
*/
@Data
public
class
FlowExtendedConfiguration
{
private
String
rpcServerKey
;
private
String
rpcStartServerKey
;
private
String
rpcEndServerKey
;
}
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