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
1cb7eeb1
Commit
1cb7eeb1
authored
Apr 27, 2020
by
huangfusuper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test环境修改 调度代码打磨
parent
a16f9910
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
198 additions
and
142 deletions
+198
-142
TestServiceImpl.java
...admin/src/main/java/com/byit/service/TestServiceImpl.java
+1
-1
application-pro.yml
...-myth-admin/src/main/resources/config/application-pro.yml
+6
-6
application-test.yml
...myth-admin/src/main/resources/config/application-test.yml
+14
-8
EmailEnum.java
...th-admin-core/src/main/java/com/byit/enums/EmailEnum.java
+2
-2
RunScriptServiceImpl.java
...main/java/com/byit/service/impl/RunScriptServiceImpl.java
+1
-1
JavaTaskJobTask.java
...min-core/src/main/java/com/byit/task/JavaTaskJobTask.java
+7
-11
ScriptExecutorJobTask.java
...re/src/main/java/com/byit/task/ScriptExecutorJobTask.java
+52
-42
JavaTaskCallbackThread.java
...src/main/java/com/byit/thread/JavaTaskCallbackThread.java
+0
-3
LogCallbackThread.java
...core/src/main/java/com/byit/thread/LogCallbackThread.java
+2
-4
ReturnResult.java
...dto-core/src/main/java/com/byit/dto/web/ReturnResult.java
+6
-7
JobResultEnum.java
...-dto-core/src/main/java/com/byit/enums/JobResultEnum.java
+8
-13
RunResultEnum.java
...core/src/main/java/com/byit/enums/task/RunResultEnum.java
+29
-0
RunTypeEnum.java
...o-core/src/main/java/com/byit/enums/task/RunTypeEnum.java
+26
-0
ScriptExecutorService.java
...ain/java/com/byit/executor/api/ScriptExecutorService.java
+1
-1
RunJobServerHandler.java
...lugin/src/main/java/com/byit/rpc/RunJobServerHandler.java
+10
-11
RunJobThread.java
...or-plugin/src/main/java/com/byit/thread/RunJobThread.java
+3
-3
ScriptExecutorServiceImpl.java
...main/java/com/byit/service/ScriptExecutorServiceImpl.java
+0
-0
application-pro.yml
...th-executor-server/src/main/resources/application-pro.yml
+2
-2
application-test.yml
...h-executor-server/src/main/resources/application-test.yml
+4
-4
application-test.yml
byit-myth-gateway/src/main/resources/application-test.yml
+6
-6
application-test.yml
...h-register-server/src/main/resources/application-test.yml
+3
-3
NettyPluginServerHandler.java
...m/byit/server/netty/handler/NettyPluginServerHandler.java
+14
-13
IndexController.java
...java/com/byit/demo/client/controller/IndexController.java
+1
-1
No files found.
byit-myth-admin/src/main/java/com/byit/service/TestServiceImpl.java
View file @
1cb7eeb1
...
...
@@ -13,6 +13,6 @@ public class TestServiceImpl {
public
DispatchResponseDto
test
(){
return
scriptExecutorService
.
run
Python
Script
(
null
);
return
scriptExecutorService
.
runScript
(
null
);
}
}
byit-myth-admin/src/main/resources/config/application-pro.yml
View file @
1cb7eeb1
spring
:
datasource
:
driver-class-name
:
com.mysql.jdbc.Driver
url
:
jdbc:mysql://
${CM_IP}
/myth-job?Unicode=true&characterEncoding=UTF-8&useSSL=true
username
:
${CM_USER}
password
:
${CM_PWD}
url
:
jdbc:mysql://
10.0.120.30:3307
/myth-job?Unicode=true&characterEncoding=UTF-8&useSSL=true
username
:
root
password
:
root
redis
:
database
:
0
host
:
${Redis_IP}
port
:
${Redis_port}
host
:
10.0.120.208
port
:
6379
password
:
timeout
:
3000
pool
:
...
...
@@ -31,7 +31,7 @@ mybatis:
myth-rpc
:
registry
:
address
:
http://
${Eureka_IP}
/myth-register
address
:
http://
10.0.120.208:8080
/myth-register
env
:
pro
biz
:
byit-myth-job
logging
:
...
...
byit-myth-admin/src/main/resources/config/application-test.yml
View file @
1cb7eeb1
spring
:
datasource
:
driver-class-name
:
com.mysql.jdbc.Driver
url
:
jdbc:mysql://
${CM_IP}
/myth-job?Unicode=true&characterEncoding=UTF-8&useSSL=true
username
:
${CM_USER}
password
:
${CM_PWD}
url
:
jdbc:mysql://
10.0.120.30:3307
/myth-job?Unicode=true&characterEncoding=UTF-8&useSSL=true
username
:
root
password
:
root
redis
:
database
:
0
host
:
${Redis_IP}
port
:
${Redis_port}
host
:
10.0.120.208
port
:
6379
password
:
timeout
:
3000
pool
:
...
...
@@ -32,7 +32,7 @@ mybatis:
myth-rpc
:
registry
:
address
:
http://
${Eureka_IP}
/myth-register
address
:
http://
10.0.120.208:8080
/myth-register
env
:
test
biz
:
byit-myth-job
logging
:
...
...
@@ -62,4 +62,10 @@ fdfs:
tracker-list
:
-
10.0.120.216:22122
-
10.0.120.217:22122
-
10.0.120.218:22122
\ No newline at end of file
-
10.0.120.218:22122
myth
:
plugin
:
env
:
${myth-rpc.registry.env}
biz
:
${myth-rpc.registry.biz}
register
:
url
:
${myth-rpc.registry.address}
\ No newline at end of file
byit-myth-core/myth-admin-core/src/main/java/com/byit/enums/EmailEnum.java
View file @
1cb7eeb1
...
...
@@ -5,8 +5,8 @@ package com.byit.enums;
*/
public
enum
EmailEnum
{
IS_ALARM_YES
(
"
0
"
,
"已经告警"
),
IS_ALARM_NO
(
"
1
"
,
"没有告警"
)
IS_ALARM_YES
(
"
1
"
,
"已经告警"
),
IS_ALARM_NO
(
"
0
"
,
"没有告警"
)
;
private
String
code
;
private
String
msg
;
...
...
byit-myth-core/myth-admin-core/src/main/java/com/byit/service/impl/RunScriptServiceImpl.java
View file @
1cb7eeb1
...
...
@@ -16,6 +16,6 @@ public class RunScriptServiceImpl implements RunScriptService {
private
ScriptExecutorService
scriptExecutorService
;
@Override
public
DispatchResponseDto
runScript
(
ScriptDto
scriptDto
)
{
return
scriptExecutorService
.
run
Python
Script
(
scriptDto
);
return
scriptExecutorService
.
runScript
(
scriptDto
);
}
}
byit-myth-core/myth-admin-core/src/main/java/com/byit/task/JavaTaskJobTask.java
View file @
1cb7eeb1
...
...
@@ -4,6 +4,7 @@ import com.byit.conf.MythJobAutoConfigure;
import
com.byit.dto.plugin.JavaTask
;
import
com.byit.enums.NodeRunStatusPropertyEnum
;
import
com.byit.enums.ScheduleTypeEnum
;
import
com.byit.enums.task.RunResultEnum
;
import
com.byit.model.JobTaskRunLogWithBLOBs
;
import
com.byit.packet.request.PluginRpcRequestPacket
;
import
com.byit.packet.response.PluginRpcResponsePacket
;
...
...
@@ -22,6 +23,7 @@ import java.util.Date;
* @author huangfu
*/
public
class
JavaTaskJobTask
implements
TimerTask
{
public
static
final
String
JAVA_SYNC
=
"JAVA_SYNC"
;
private
final
JavaTask
javaTask
;
public
JavaTaskJobTask
(
JavaTask
javaTask
)
{
...
...
@@ -29,7 +31,7 @@ public class JavaTaskJobTask implements TimerTask {
}
@Override
public
void
run
(
Timeout
timeout
)
throws
Exception
{
public
void
run
(
Timeout
timeout
)
{
MythJobAutoConfigure
.
LOW_LEVEL_JOB_THREAD_POOL
.
execute
(
this
::
runJob
);
}
...
...
@@ -55,14 +57,13 @@ public class JavaTaskJobTask implements TimerTask {
try
{
PluginRpcResponsePacket
pluginRpcResponsePacket
=
service
.
runJava
(
request
);
if
(
pluginRpcResponsePacket
.
isStatus
()){
log
.
setTriggerCode
(
NodeRunStatusPropertyEnum
.
RUN
_SUCCESS
.
getCode
());
log
.
setTriggerCode
(
RunResultEnum
.
TRIGGER
_SUCCESS
.
getCode
());
}
else
{
log
.
setTriggerCode
(
NodeRunStatusPropertyEnum
.
RUN_FAILURE
.
getCode
());
log
.
setTriggerCode
(
RunResultEnum
.
TRIGGER_ERROR
.
getCode
());
}
log
.
setTriggerMsg
(
pluginRpcResponsePacket
.
getMsg
());
}
catch
(
Exception
e
){
log
.
setTriggerCode
(
"2"
);
log
.
setTriggerCode
(
RunResultEnum
.
TRIGGER_ERROR
.
getCode
()
);
log
.
setRunCode
(
NodeRunStatusPropertyEnum
.
RUN_FAILURE
.
getCode
());
log
.
setRunMsg
(
javaTask
.
getTaskName
()+
":"
+
e
.
getMessage
());
log
.
setTriggerMsg
(
javaTask
.
getTaskName
()+
":"
+
e
.
getMessage
());
...
...
@@ -81,14 +82,9 @@ public class JavaTaskJobTask implements TimerTask {
log
.
setHandlerName
(
javaTask
.
getTaskName
());
log
.
setRunParams
(
javaTask
.
getParam
());
log
.
setTriggerTime
(
new
Date
());
log
.
setJobType
(
"JAVA_SYNC"
);
log
.
setJobType
(
JAVA_SYNC
);
JobTaskRunLogServiceImpl
jobTaskRunLogService
=
SpringUtil
.
getBean
(
JobTaskRunLogServiceImpl
.
class
);
int
i
=
jobTaskRunLogService
.
saveJobTaskRunLog
(
log
);
return
log
.
getLogId
();
}
public
JavaTask
getJavaTask
()
{
return
javaTask
;
}
}
byit-myth-core/myth-admin-core/src/main/java/com/byit/task/ScriptExecutorJobTask.java
View file @
1cb7eeb1
This diff is collapsed.
Click to expand it.
byit-myth-core/myth-admin-core/src/main/java/com/byit/thread/JavaTaskCallbackThread.java
View file @
1cb7eeb1
package
com
.
byit
.
thread
;
import
com.byit.dto.executor.JobRunResultDto
;
import
com.byit.dto.web.ReturnResult
;
import
com.byit.enums.RunRecordingEnum
;
import
com.byit.model.JobTaskRunLogWithBLOBs
;
import
com.byit.packet.response.PluginRpcResponsePacket
;
import
com.byit.service.impl.JobTaskRunLogServiceImpl
;
...
...
byit-myth-core/myth-admin-core/src/main/java/com/byit/thread/LogCallbackThread.java
View file @
1cb7eeb1
package
com
.
byit
.
thread
;
import
com.byit.dto.executor.JobRunResultDto
;
import
com.byit.enums.EmailEnum
;
import
com.byit.model.JobTaskRunLogWithBLOBs
;
import
com.byit.service.impl.JobTaskRunLogServiceImpl
;
import
com.byit.util.SpringUtil
;
...
...
@@ -32,9 +33,6 @@ public class LogCallbackThread implements Runnable {
if
(
jobTaskRunLogById
.
getRunCount
()>
1
)
{
String
runMsg
=
jobTaskRunLogById
.
getRunMsg
()+
"|"
+
jobRunResultDto
.
getReturnResult
().
getMsg
();
//这里需要追加文件 TODO
//这里需要追加文件 TODO
jobTaskRunLog
.
setRunMsg
(
runMsg
);
}
else
{
jobTaskRunLog
.
setRunMsg
(
jobRunResultDto
.
getReturnResult
().
getMsg
());
...
...
@@ -45,7 +43,7 @@ public class LogCallbackThread implements Runnable {
jobTaskRunLog
.
setEndTime
(
jobRunResultDto
.
getEndTime
());
jobTaskRunLog
.
setRunCode
(
jobRunResultDto
.
getReturnResult
().
getCode
());
jobTaskRunLog
.
setAlertEnd
(
"0"
);
jobTaskRunLog
.
setAlertEnd
(
EmailEnum
.
IS_ALARM_NO
.
getCode
()
);
mythJobTaskRunLogService
.
updateJobTaskRunLogWithBLOBs
(
jobTaskRunLog
);
}
...
...
byit-myth-core/myth-dto-core/src/main/java/com/byit/dto/web/ReturnResult.java
View file @
1cb7eeb1
...
...
@@ -18,17 +18,16 @@ import java.io.Serializable;
@NoArgsConstructor
public
class
ReturnResult
<
T
>
implements
Serializable
{
public
static
final
long
serialVersionUID
=
1573630876693L
;
public
static
final
ReturnResult
<
String
>
SUCCESS
=
new
ReturnResult
<
String
>(
null
);
public
static
final
ReturnResult
FAIL
=
new
ReturnResult
(
JobResultEnum
.
FAIL
.
getRes
(),
JobResultEnum
.
FAIL
.
getMsg
());
public
static
final
ReturnResult
FAIL_TIMEOUT
=
new
ReturnResult
(
JobResultEnum
.
FAIL_TIMEOUT
.
getRes
(),
JobResultEnum
.
FAIL_TIMEOUT
.
getMsg
());
public
static
final
ReturnResult
<
String
>
SUCCESS
=
new
ReturnResult
<>(
null
);
public
static
final
ReturnResult
<
String
>
FAIL
=
new
ReturnResult
<>(
JobResultEnum
.
FAIL
.
getCode
(),
JobResultEnum
.
FAIL
.
getMsg
());
private
String
code
;
private
String
msg
;
private
T
content
;
/**
* 默认就是错误
* @param code
* @param msg
* @param code
错误码
* @param msg
执行信息
*/
public
ReturnResult
(
String
code
,
String
msg
)
{
this
.
code
=
code
;
...
...
@@ -37,10 +36,10 @@ public class ReturnResult<T> implements Serializable {
/**
* 默认就是成功
* @param content
* @param content
结果集
*/
private
ReturnResult
(
T
content
)
{
this
.
code
=
JobResultEnum
.
SUCCESS
.
get
Res
();
this
.
code
=
JobResultEnum
.
SUCCESS
.
get
Code
();
this
.
msg
=
JobResultEnum
.
SUCCESS
.
getMsg
();
this
.
content
=
content
;
}
...
...
byit-myth-core/myth-dto-core/src/main/java/com/byit/enums/JobResultEnum.java
View file @
1cb7eeb1
...
...
@@ -5,24 +5,23 @@ package com.byit.enums;
* @author huangfu
*/
public
enum
JobResultEnum
implements
IEnum
{
SUCCESS
(
"100200"
,
"任务执行成功"
,
"1"
),
FAIL
(
"100500"
,
"任务执行失败"
,
"2"
),
FAIL_TIMEOUT
(
"100502"
,
"超时错误"
,
"2"
),
DISPATCH_SUCCESS
(
"200200"
,
"调度成功"
,
"1"
),
DISPATCH_FAIL
(
"200500"
,
"调度失败"
,
"2"
),
SUCCESS
(
"100200"
,
"任务执行成功"
),
FAIL
(
"100500"
,
"任务执行失败"
),
FAIL_TIMEOUT
(
"100502"
,
"超时错误"
),
DISPATCH_SUCCESS
(
"200200"
,
"调度成功"
),
DISPATCH_FAIL
(
"200500"
,
"调度失败"
),
KILL_SUCCESS
(
"400000"
,
"执行数据被kill"
),
RUN_MSG_FAIL
(
"300000"
,
"执行结果异常"
,
"2"
);
RUN_MSG_FAIL
(
"300000"
,
"执行结果异常"
);
private
String
code
;
private
String
msg
;
private
String
res
;
JobResultEnum
()
{
}
JobResultEnum
(
String
code
,
String
msg
,
String
res
)
{
JobResultEnum
(
String
code
,
String
msg
)
{
this
.
code
=
code
;
this
.
msg
=
msg
;
this
.
res
=
res
;
}
...
...
@@ -35,7 +34,4 @@ public enum JobResultEnum implements IEnum {
public
String
getMsg
()
{
return
this
.
msg
;
}
public
String
getRes
()
{
return
this
.
res
;
}
}
\ No newline at end of file
byit-myth-core/myth-dto-core/src/main/java/com/byit/enums/task/RunResultEnum.java
0 → 100644
View file @
1cb7eeb1
package
com
.
byit
.
enums
.
task
;
/**
* @author huangfu
*/
public
enum
RunResultEnum
{
TRIGGER_SUCCESS
(
"1"
,
"调度成功"
),
TRIGGER_ERROR
(
"2"
,
"调度失败"
),
RUN_SUCCESS
(
"1"
,
"执行成功"
),
RUN_ERROR
(
"2"
,
"执行失败"
),
KILL_SUCCESS
(
"5"
,
"节点被kill"
)
;
private
String
code
;
private
String
msg
;
RunResultEnum
(
String
code
,
String
msg
)
{
this
.
code
=
code
;
this
.
msg
=
msg
;
}
public
String
getCode
()
{
return
code
;
}
public
String
getMsg
()
{
return
msg
;
}
}
byit-myth-core/myth-dto-core/src/main/java/com/byit/enums/task/RunTypeEnum.java
0 → 100644
View file @
1cb7eeb1
package
com
.
byit
.
enums
.
task
;
/**
* 运行类型枚举
* @author huangfu
*/
public
enum
RunTypeEnum
{
PLUGIN_RUN
(
"2"
,
"插件执行!"
),
EXECUTIVE_MACHINE_RUN
(
"1"
,
"执行机执行!"
)
;
private
String
code
;
private
String
msg
;
RunTypeEnum
(
String
code
,
String
msg
)
{
this
.
code
=
code
;
this
.
msg
=
msg
;
}
public
String
getCode
()
{
return
code
;
}
public
String
getMsg
()
{
return
msg
;
}
}
byit-myth-executor/myth-executor-api/src/main/java/com/byit/executor/api/ScriptExecutorService.java
View file @
1cb7eeb1
...
...
@@ -14,5 +14,5 @@ public interface ScriptExecutorService {
* @param scriptDto 参数
* @return 调用结果
*/
DispatchResponseDto
run
Python
Script
(
ScriptDto
scriptDto
);
DispatchResponseDto
runScript
(
ScriptDto
scriptDto
);
}
byit-myth-executor/myth-executor-plugin/src/main/java/com/byit/rpc/RunJobServerHandler.java
View file @
1cb7eeb1
...
...
@@ -33,7 +33,7 @@ public class RunJobServerHandler extends SimpleChannelInboundHandler<FullHttpReq
200
,
60L
,
TimeUnit
.
SECONDS
,
new
LinkedBlockingQueue
<
Runnable
>(
1000
),
new
LinkedBlockingQueue
<>(
1000
),
r
->
new
Thread
(
r
,
"Netty RunJobServerHandler serverThread-"
+
r
.
hashCode
()));
private
static
final
String
PENG
=
"PENG"
;
...
...
@@ -42,23 +42,23 @@ public class RunJobServerHandler extends SimpleChannelInboundHandler<FullHttpReq
protected
void
channelRead0
(
ChannelHandlerContext
ctx
,
FullHttpRequest
req
)
throws
Exception
{
log
.
debug
(
"----------------------有请求过来了------------------------"
);
DispatchResponseDto
dispatchResponseDto
=
new
DispatchResponseDto
();
dispatchResponseDto
.
setCode
(
JobResultEnum
.
DISPATCH_FAIL
.
get
Res
());
dispatchResponseDto
.
setCode
(
JobResultEnum
.
DISPATCH_FAIL
.
get
Code
());
dispatchResponseDto
.
setMsg
(
JobResultEnum
.
DISPATCH_FAIL
.
getMsg
());
if
(
req
!=
null
){
//解析 调度中心 的数据对象
AdminSenPluginDto
adminSenPluginDto
=
analysisParam
(
req
.
content
(
));
if
(
null
==
adminSenPluginDto
){
throw
new
Exception
(
"核心参数
为 null
"
);
throw
new
Exception
(
"核心参数
为空!
"
);
}
//检测是否有心跳参数,有心跳参数则为测试参数,且为PENG的话,服务端回复 PONG
String
heartbeat
=
adminSenPluginDto
.
getHeartbeat
();
if
(
null
==
heartbeat
){
JOB_TRIGGER_POOL
.
execute
(
new
RunJobThread
(
adminSenPluginDto
));
dispatchResponseDto
.
setCode
(
JobResultEnum
.
DISPATCH_SUCCESS
.
get
Res
());
dispatchResponseDto
.
setCode
(
JobResultEnum
.
DISPATCH_SUCCESS
.
get
Code
());
dispatchResponseDto
.
setMsg
(
JobResultEnum
.
DISPATCH_SUCCESS
.
getMsg
());
}
else
if
(
PENG
.
equals
(
heartbeat
)){
log
.
debug
(
"----------调度平台心跳检测-------------"
);
dispatchResponseDto
.
setCode
(
JobResultEnum
.
DISPATCH_SUCCESS
.
get
Res
());
dispatchResponseDto
.
setCode
(
JobResultEnum
.
DISPATCH_SUCCESS
.
get
Code
());
dispatchResponseDto
.
setMsg
(
JobResultEnum
.
DISPATCH_SUCCESS
.
getMsg
());
dispatchResponseDto
.
setContent
(
PONG
);
}
...
...
@@ -78,8 +78,8 @@ public class RunJobServerHandler extends SimpleChannelInboundHandler<FullHttpReq
/**
* 格式化参数
* @param byteBuf
* @return
* @param byteBuf
将缓冲流更改为字符串
* @return
调用的必要信息承载类
*/
private
AdminSenPluginDto
analysisParam
(
ByteBuf
byteBuf
){
return
JSON
.
parseObject
(
byteBuf
.
toString
(
CharsetUtil
.
UTF_8
),
AdminSenPluginDto
.
class
);
...
...
@@ -87,12 +87,11 @@ public class RunJobServerHandler extends SimpleChannelInboundHandler<FullHttpReq
/**
* 异常捕获
* @param ctx
* @param cause
* @throws Exception
* @param ctx 上线文对象
* @param cause 异常信息
*/
@Override
public
void
exceptionCaught
(
ChannelHandlerContext
ctx
,
Throwable
cause
)
throws
Exception
{
public
void
exceptionCaught
(
ChannelHandlerContext
ctx
,
Throwable
cause
)
{
cause
.
printStackTrace
();
ctx
.
close
();
}
...
...
byit-myth-executor/myth-executor-plugin/src/main/java/com/byit/thread/RunJobThread.java
View file @
1cb7eeb1
...
...
@@ -45,16 +45,16 @@ public class RunJobThread implements Runnable {
log
.
info
(
"---------服务器端:{},花费时间:{}-------------"
,
jobRunResultDto
,
jobRunResultDto
.
getStartTime
().
getTime
()-
jobRunResultDto
.
getEndTime
().
getTime
());
}
private
ReturnResult
runJob
(
String
jobHandlerName
,
String
param
){
private
ReturnResult
<
String
>
runJob
(
String
jobHandlerName
,
String
param
){
Class
<?
extends
IJobHandler
>
jobClass
=
JobUtils
.
jobCache
.
get
(
jobHandlerName
);
try
{
IJobHandler
iJobHandler
=
jobClass
.
newInstance
();
return
iJobHandler
.
execute
(
param
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
(
);
ReturnResult
returnResult
=
new
ReturnResult
();
ReturnResult
<
String
>
returnResult
=
new
ReturnResult
<>
();
returnResult
.
setMsg
(
e
.
getMessage
());
returnResult
.
setCode
(
JobResultEnum
.
FAIL
.
get
Res
());
returnResult
.
setCode
(
JobResultEnum
.
FAIL
.
get
Code
());
return
returnResult
;
}
...
...
byit-myth-executor/myth-executor-server/src/main/java/com/byit/service/ScriptExecutorServiceImpl.java
View file @
1cb7eeb1
This diff is collapsed.
Click to expand it.
byit-myth-executor/myth-executor-server/src/main/resources/application-pro.yml
View file @
1cb7eeb1
...
...
@@ -21,8 +21,8 @@ myth-job:
spring
:
redis
:
database
:
0
host
:
${Redis_IP}
port
:
${Redis_port}
host
:
10.0.120.208
port
:
6379
password
:
timeout
:
3000
pool
:
...
...
byit-myth-executor/myth-executor-server/src/main/resources/application-test.yml
View file @
1cb7eeb1
# myth-rpc
myth-rpc
:
registry
:
address
:
http://
${Eureka_IP}
/myth-register
address
:
http://
10.0.120.208:8080
/myth-register
biz
:
byit-myth-job
env
:
test
remoting
:
port
:
${Remote_PORT}
port
:
7776
logging
:
config
:
classpath:logback.xml
...
...
@@ -21,8 +21,8 @@ myth-job:
spring
:
redis
:
database
:
0
host
:
${Redis_IP}
port
:
${Redis_port}
host
:
10.0.120.208
port
:
6379
password
:
timeout
:
3000
pool
:
...
...
byit-myth-gateway/src/main/resources/application-test.yml
View file @
1cb7eeb1
#路
由规则参考byit-myth-rpc中的LoadBalance枚举类中的类型 默认是轮
询
#·
�ɹ���ο�byit-myth-rpc�е�LoadBalanceö�����е����� Ĭ������ѯ
gateway
:
load
:
balance
:
ROUND
...
...
@@ -12,11 +12,11 @@ logging:
springframework
:
INFO
myth-rpc
:
registry
:
address
:
http://
${Eureka_IP}
/myth-register
address
:
http://
10.0.120.208:8080
/myth-register
biz
:
byit-myth-job
env
:
test
remoting
:
port
:
${Remote_PORT}
port
:
7776
spring
:
datasource
:
...
...
@@ -25,9 +25,9 @@ spring:
idle-timeout
:
60000
maximum-pool-size
:
5
minimum-idle
:
1
password
:
${CM_PWD}
url
:
jdbc:mysql://
${CM_IP}
/myth-registry?useUnicode=true&useSSL=true&characterEncoding=utf-8&mysqlEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=false&autoReconnect=true&failOverReadOnly=false
username
:
${CM_USER}
password
:
root
url
:
jdbc:mysql://
10.0.120.30:3307
/myth-registry?useUnicode=true&useSSL=true&characterEncoding=utf-8&mysqlEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=false&autoReconnect=true&failOverReadOnly=false
username
:
root
zuul
:
route
:
refreshCron
:
0/10 * * * * ?
...
...
byit-myth-register/myth-register-server/src/main/resources/application-test.yml
View file @
1cb7eeb1
...
...
@@ -15,9 +15,9 @@ spring:
datasource
:
driver-class-name
:
com.mysql.jdbc.Driver
type
:
org.apache.tomcat.jdbc.pool.DataSource
url
:
jdbc:mysql://
${CM_IP}
/myth-registry?Unicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
username
:
${CM_USER}
password
:
${CM_PWD}
url
:
jdbc:mysql://
10.0.120.30:3307
/myth-registry?Unicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
username
:
root
password
:
root
tomcat
:
max-active
:
30
max-wait
:
10000
...
...
byit-plugin-core/myth-plugin-rpc-server/src/main/java/com/byit/server/netty/handler/NettyPluginServerHandler.java
View file @
1cb7eeb1
...
...
@@ -23,6 +23,9 @@ import java.util.concurrent.ThreadPoolExecutor;
*/
public
class
NettyPluginServerHandler
extends
SimpleChannelInboundHandler
<
PluginRpcRequestPacket
>
{
public
static
final
String
TOKEN_NAME
=
"token"
;
public
static
final
String
HEADER_TOKEN_NAME
=
TOKEN_NAME
;
public
static
final
String
HEADER_CONTENT_TYPE
=
"contentType"
;
private
PluginServerFactory
pluginServerFactory
;
private
ThreadPoolExecutor
threadPoolExecutor
;
...
...
@@ -32,13 +35,12 @@ public class NettyPluginServerHandler extends SimpleChannelInboundHandler<Plugin
}
/**
* //TODO 这一块有问题 不能返回两次结果 考虑能否加一个结果回调,回调的方式由自己实现
* @param ctx
* @param msg
* @throws Exception
* 接收到消费方的请求 开始处理消费方的请求
* @param ctx 上下文对象
* @param msg 消息对象
*/
@Override
protected
void
channelRead0
(
ChannelHandlerContext
ctx
,
PluginRpcRequestPacket
msg
)
throws
Exception
{
protected
void
channelRead0
(
ChannelHandlerContext
ctx
,
PluginRpcRequestPacket
msg
)
{
if
(
PluginBeat
.
BEAT_ID
.
equals
(
msg
.
getRequestId
())){
System
.
out
.
println
(
"------接收到客户端的心跳连接-------"
+
ctx
.
channel
().
id
().
asShortText
());
return
;
...
...
@@ -55,20 +57,20 @@ public class NettyPluginServerHandler extends SimpleChannelInboundHandler<Plugin
ReturnResult
<
String
>
execute
=
iJobHandler
.
execute
(
msg
.
getParam
());
long
endTime
=
System
.
currentTimeMillis
();
rpcResponsePacket
.
setResult
(
execute
);
rpcResponsePacket
.
setCode
(
"000000"
);
rpcResponsePacket
.
setMsg
(
"SUCCESS"
);
rpcResponsePacket
.
setCode
(
JobResultEnum
.
SUCCESS
.
getCode
()
);
rpcResponsePacket
.
setMsg
(
JobResultEnum
.
SUCCESS
.
getMsg
()
);
rpcResponsePacket
.
setStatus
(
true
);
rpcResponsePacket
.
setRunTime
(
endTime
-
startTime
);
rpcResponsePacket
.
setExtension
(
msg
.
getExtension
());
sendMsg
(
rpcResponsePacket
,
msg
);
}
catch
(
Throwable
e
){
rpcResponsePacket
.
setCode
(
"500000"
);
rpcResponsePacket
.
setCode
(
JobResultEnum
.
FAIL
.
getCode
()
);
rpcResponsePacket
.
setMsg
(
e
.
getMessage
());
rpcResponsePacket
.
setStatus
(
false
);
rpcResponsePacket
.
setExtension
(
msg
.
getExtension
());
ReturnResult
<
String
>
execute
=
new
ReturnResult
<>();
execute
.
setMsg
(
e
.
getMessage
());
execute
.
setCode
(
JobResultEnum
.
FAIL
.
get
Res
());
execute
.
setCode
(
JobResultEnum
.
FAIL
.
get
Code
());
rpcResponsePacket
.
setResult
(
execute
);
sendMsg
(
rpcResponsePacket
,
msg
);
throw
new
RuntimeException
(
e
);
...
...
@@ -91,8 +93,8 @@ public class NettyPluginServerHandler extends SimpleChannelInboundHandler<Plugin
String
responseStr
=
JSON
.
toJSONString
(
rpcResponsePacket
);
HttpRequest
post
=
HttpRequest
.
post
(
msg
.
getCallbackUrl
());
post
.
header
(
"token"
,
"Token"
);
post
.
header
(
"contentType"
,
"application/json"
);
post
.
header
(
HEADER_TOKEN_NAME
,
"Token"
);
post
.
header
(
HEADER_CONTENT_TYPE
,
"application/json"
);
post
.
body
(
responseStr
).
execute
();
System
.
out
.
println
(
"-------消息回复成功-----------"
);
}
...
...
@@ -101,10 +103,9 @@ public class NettyPluginServerHandler extends SimpleChannelInboundHandler<Plugin
* 异常处理
* @param ctx 上下文对象
* @param cause 异常对象
* @throws Exception 异常信息
*/
@Override
public
void
exceptionCaught
(
ChannelHandlerContext
ctx
,
Throwable
cause
)
throws
Exception
{
public
void
exceptionCaught
(
ChannelHandlerContext
ctx
,
Throwable
cause
)
{
cause
.
printStackTrace
();
ctx
.
close
();
}
...
...
demo-client/byit-demo-client/src/main/java/com/byit/demo/client/controller/IndexController.java
View file @
1cb7eeb1
...
...
@@ -34,7 +34,7 @@ public class IndexController {
@ResponseBody
public
DispatchResponseDto
say1
(
String
name
){
DispatchResponseDto
dispatchResponseDto
=
scriptExecutorService
.
run
Python
Script
(
null
);
DispatchResponseDto
dispatchResponseDto
=
scriptExecutorService
.
runScript
(
null
);
return
dispatchResponseDto
;
}
}
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