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
9fdff748
Commit
9fdff748
authored
Nov 05, 2020
by
huangfusuper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
错误日志上传
parent
44bf9310
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
80 additions
and
102 deletions
+80
-102
pom.xml
byit-myth-admin/pom.xml
+0
-6
AdminRegisterConfig.java
...in/src/main/java/com/byit/config/AdminRegisterConfig.java
+3
-3
pom.xml
byit-myth-core/myth-admin-core/pom.xml
+6
-0
JobTaskRunLogAndJobTaskServiceImpl.java
...e/mapservice/impl/JobTaskRunLogAndJobTaskServiceImpl.java
+0
-5
ScheduleThreadRunHelper.java
.../java/com/byit/thread/helper/ScheduleThreadRunHelper.java
+0
-13
SpringUtil.java
...myth-web-core/src/main/java/com/byit/util/SpringUtil.java
+0
-1
pom.xml
byit-myth-rpc/pom.xml
+18
-0
RpcReferenceBean.java
...byit/rpc/remoting/invoker/reference/RpcReferenceBean.java
+3
-1
RequestUtil.java
...myth-rpc/src/main/java/com/byit/rpc/util/RequestUtil.java
+35
-5
pom.xml
byit-plugin-core/byit-plugin-rpc-common/pom.xml
+7
-0
ClientRpcUtil.java
...pc-client/src/main/java/com/byit/utils/ClientRpcUtil.java
+8
-2
RpcSpringUtil.java
...pc-client/src/main/java/com/byit/utils/RpcSpringUtil.java
+0
-66
No files found.
byit-myth-admin/pom.xml
View file @
9fdff748
...
...
@@ -71,12 +71,6 @@
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
myth-job
</groupId>
<artifactId>
myth-web-core
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
</dependencies>
<build>
...
...
byit-myth-admin/src/main/java/com/byit/config/AdminRegisterConfig.java
View file @
9fdff748
...
...
@@ -3,7 +3,7 @@ package com.byit.config;
import
com.byit.rpc.registry.impl.RegistryServiceRegistry
;
import
com.byit.rpc.remoting.invoker.impl.RpcSpringInvokerFactory
;
import
com.byit.rpc.remoting.provider.impl.RpcSpringProviderFactory
;
import
com.byit.util
s.Rpc
SpringUtil
;
import
com.byit.util
.
SpringUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
...
...
@@ -64,8 +64,8 @@ public class AdminRegisterConfig {
}
@Bean
public
Rpc
SpringUtil
rpcSpringUtil
(){
return
new
Rpc
SpringUtil
();
public
SpringUtil
rpcSpringUtil
(){
return
new
SpringUtil
();
}
}
byit-myth-core/myth-admin-core/pom.xml
View file @
9fdff748
...
...
@@ -77,6 +77,12 @@
</dependency>
<dependency>
<groupId>
myth-job
</groupId>
<artifactId>
myth-web-core
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
redis.clients
</groupId>
<artifactId>
jedis
</artifactId>
</dependency>
...
...
byit-myth-core/myth-admin-core/src/main/java/com/byit/service/mapservice/impl/JobTaskRunLogAndJobTaskServiceImpl.java
View file @
9fdff748
package
com
.
byit
.
service
.
mapservice
.
impl
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.byit.dto.executor.DispatchResponseDto
;
import
com.byit.enums.EmailEnum
;
import
com.byit.enums.JobResultEnum
;
import
com.byit.enums.NodeRunStatusPropertyEnum
;
import
com.byit.model.*
;
import
com.byit.service.impl.JobTaskRunLogServiceImpl
;
...
...
@@ -18,8 +15,6 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* @author huangfu
...
...
byit-myth-core/myth-admin-core/src/main/java/com/byit/thread/helper/ScheduleThreadRunHelper.java
View file @
9fdff748
package
com
.
byit
.
thread
.
helper
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.byit.dto.executor.RunParamWrapped
;
import
com.byit.dto.executor.ScriptParamAndPlaceholderDto
;
import
com.byit.dto.plugin.JavaTask
;
import
com.byit.enums.NodeTypeEnum
;
import
com.byit.enums.PlaceholderEnum
;
import
com.byit.enums.ScheduleTypeEnum
;
import
com.byit.job.WorkRoulette
;
import
com.byit.job.utils.DateUtil
;
import
com.byit.job.utils.PlaceholderUtils
;
import
com.byit.model.JobTaskRunLogWithBLOBs
;
import
com.byit.model.JobTaskSchedule
;
import
com.byit.service.JobTaskScheduleService
;
import
com.byit.service.impl.JobTaskRunLogServiceImpl
;
import
com.byit.task.JavaBeanJobTask
;
import
com.byit.task.JavaNodeExecutorTask
;
import
com.byit.task.JavaTaskJobTask
;
import
com.byit.task.ScriptExecutorJobTask
;
import
com.byit.thread.BaseThreadRunHelper
;
import
com.byit.util.SpringUtil
;
import
io.netty.util.TimerTask
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.stereotype.Component
;
import
javax.sql.DataSource
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
/**
* 排期表操作
...
...
byit-myth-core/myth-
admin
-core/src/main/java/com/byit/util/SpringUtil.java
→
byit-myth-core/myth-
web
-core/src/main/java/com/byit/util/SpringUtil.java
View file @
9fdff748
package
com
.
byit
.
util
;
import
com.byit.thread.BaseThreadRunHelper
;
import
org.springframework.beans.BeansException
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextAware
;
...
...
byit-myth-rpc/pom.xml
View file @
9fdff748
...
...
@@ -29,6 +29,24 @@
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-redis
</artifactId>
<version>
1.3.2.RELEASE
</version>
</dependency>
<dependency>
<groupId>
myth-job
</groupId>
<artifactId>
myth-web-core
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
myth-job
</groupId>
<artifactId>
myth-dto-core
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<!-- ********************** net (default=netty) ********************** -->
...
...
byit-myth-rpc/src/main/java/com/byit/rpc/remoting/invoker/reference/RpcReferenceBean.java
View file @
9fdff748
package
com
.
byit
.
rpc
.
remoting
.
invoker
.
reference
;
import
com.byit.dto.executor.ScriptDto
;
import
com.byit.rpc.remoting.invoker.RpcInvokerFactory
;
import
com.byit.rpc.remoting.invoker.call.CallType
;
import
com.byit.rpc.remoting.invoker.call.RpcInvokeCallback
;
...
...
@@ -16,6 +17,7 @@ import com.byit.rpc.serialize.Serializer;
import
com.byit.rpc.util.ClassUtil
;
import
com.byit.rpc.util.RequestUtil
;
import
com.byit.rpc.util.RpcException
;
import
com.byit.utils.KeyUtil
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -201,7 +203,7 @@ public class RpcReferenceBean {
// pass
}
else
{
//finalAddress = loadBalance.rpcInvokerRouter.route(serviceKey, addressSet);
finalAddress
=
RequestUtil
.
selectRPCServer
(
client
,
loadBalance
,
addressSet
,
serverName
);
finalAddress
=
RequestUtil
.
selectRPCServer
(
client
,
loadBalance
,
addressSet
,
serverName
,
parameters
);
logger
.
debug
(
"-----选取的健壮主机为【{}】-----"
,
finalAddress
);
}
...
...
byit-myth-rpc/src/main/java/com/byit/rpc/util/RequestUtil.java
View file @
9fdff748
package
com
.
byit
.
rpc
.
util
;
import
com.alibaba.fastjson.JSON
;
import
com.byit.dto.executor.ScriptDto
;
import
com.byit.dto.plugin.RunLog
;
import
com.byit.rpc.remoting.invoker.reference.RpcReferenceBean
;
import
com.byit.rpc.remoting.invoker.route.LoadBalance
;
import
com.byit.rpc.remoting.net.Client
;
import
com.byit.rpc.remoting.net.params.Beat
;
import
com.byit.util.SpringUtil
;
import
com.byit.utils.KeyUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
java.util.TreeSet
;
import
static
com
.
alibaba
.
fastjson
.
serializer
.
SerializerFeature
.
WriteClassName
;
public
class
RequestUtil
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
RequestUtil
.
class
);
...
...
@@ -21,10 +29,19 @@ public class RequestUtil {
* @return 健全的服务地址
* @throws InterruptedException 线程异常
*/
public
static
String
selectRPCServer
(
Client
client
,
LoadBalance
loadBalance
,
TreeSet
<
String
>
address
,
String
serverKey
)
throws
InterruptedException
{
public
static
String
selectRPCServer
(
Client
client
,
LoadBalance
loadBalance
,
TreeSet
<
String
>
address
,
String
serverKey
,
Object
[]
parameters
)
throws
InterruptedException
{
String
runKey
=
null
;
if
(
parameters
!=
null
&&
parameters
.
length
>
1
){
Object
parameter
=
parameters
[
0
];
if
(
parameter
instanceof
ScriptDto
){
ScriptDto
scriptDto
=
(
ScriptDto
)
parameter
;
Integer
logId
=
scriptDto
.
getLogId
();
runKey
=
KeyUtil
.
generateRunKey
(
logId
);
}
}
for
(
String
ignored
:
address
)
{
String
routeHost
=
loadBalance
.
rpcInvokerRouter
.
route
(
serverKey
,
address
);
boolean
retryRpcHost
=
retryRpcHost
(
client
,
routeHost
,
3
,
1
);
boolean
retryRpcHost
=
retryRpcHost
(
client
,
routeHost
,
runKey
,
3
,
1
);
if
(
retryRpcHost
)
{
return
routeHost
;
}
...
...
@@ -40,7 +57,7 @@ public class RequestUtil {
* @param thisRetryCount 当前重试次数
* @return 是否成功
*/
public
static
boolean
retryRpcHost
(
Client
client
,
String
host
,
int
retryTotalCount
,
int
thisRetryCount
)
throws
InterruptedException
{
public
static
boolean
retryRpcHost
(
Client
client
,
String
host
,
String
runKey
,
int
retryTotalCount
,
int
thisRetryCount
)
throws
InterruptedException
{
log
.
info
(
"------当前rpc的请求的地址为:{}-------"
,
host
);
try
{
client
.
asyncSend
(
host
,
Beat
.
BEAT_PING
);
...
...
@@ -49,11 +66,24 @@ public class RequestUtil {
}
catch
(
Exception
e
)
{
//当前重试次数 小于等于总共的重试次数时
if
(
thisRetryCount
<=
retryTotalCount
){
String
redisFormat
=
String
.
format
(
"rpc通道[%s]建立时出现异常,开始第%s次重试!"
,
host
,
thisRetryCount
);
log
.
error
(
"{},rpc通道建立时出现异常,异常信息为:{},开始第{}次重试!"
,
host
,
RPCLogUtil
.
getMessage
(
e
),
thisRetryCount
);
StringRedisTemplate
stringRedisTemplate
=
SpringUtil
.
getBean
(
StringRedisTemplate
.
class
);
RunLog
runLog
=
RunLog
.
builder
().
runLog
(
redisFormat
).
isEnd
(
false
).
build
();
stringRedisTemplate
.
opsForList
().
rightPush
(
runKey
,
JSON
.
toJSONString
(
runLog
,
WriteClassName
));
Thread
.
sleep
(
1000
*
thisRetryCount
);
retryRpcHost
(
client
,
host
,
retryTotalCount
,++
thisRetryCount
);
retryRpcHost
(
client
,
host
,
r
unKey
,
r
etryTotalCount
,++
thisRetryCount
);
}
log
.
error
(
"----与主机【{}】建立通道,总共【{}】次,全部失败,开始挑选下一个负载均衡方案重试,请稍后------"
,
host
,
retryTotalCount
);
String
format
=
String
.
format
(
"与主机【%s】建立通道,总共【%s】次,全部失败,开始挑选下一个负载均衡方案重试,请稍后"
,
host
,
retryTotalCount
);
StringRedisTemplate
stringRedisTemplate
=
SpringUtil
.
getBean
(
StringRedisTemplate
.
class
);
RunLog
runLog
=
RunLog
.
builder
().
runLog
(
format
).
isEnd
(
false
).
build
();
stringRedisTemplate
.
opsForList
().
rightPush
(
runKey
,
JSON
.
toJSONString
(
runLog
,
WriteClassName
));
log
.
error
(
format
);
return
false
;
}
}
...
...
byit-plugin-core/byit-plugin-rpc-common/pom.xml
View file @
9fdff748
...
...
@@ -21,6 +21,13 @@
</dependency>
<dependency>
<groupId>
myth-job
</groupId>
<artifactId>
myth-web-core
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
</dependency>
...
...
byit-plugin-core/myth-plugin-rpc-client/src/main/java/com/byit/utils/ClientRpcUtil.java
View file @
9fdff748
...
...
@@ -8,6 +8,7 @@ import com.byit.param.PluginBeat;
import
com.byit.rpc.remoting.invoker.route.LoadBalance
;
import
com.byit.rpc.util.RPCLogUtil
;
import
com.byit.rpc.util.RpcException
;
import
com.byit.util.SpringUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
...
...
@@ -62,13 +63,18 @@ public class ClientRpcUtil {
String
redisFormat
=
String
.
format
(
"与执行服务器[%s]建立通道时出现异常,开始第%s次重试!"
,
host
,
thisRetryCount
);
log
.
error
(
format
);
//redis模板
StringRedisTemplate
stringRedisTemplate
=
Rpc
SpringUtil
.
getBean
(
StringRedisTemplate
.
class
);
StringRedisTemplate
stringRedisTemplate
=
SpringUtil
.
getBean
(
StringRedisTemplate
.
class
);
RunLog
runLog
=
RunLog
.
builder
().
runLog
(
redisFormat
).
isEnd
(
false
).
build
();
stringRedisTemplate
.
opsForList
().
rightPush
(
runKey
,
JSON
.
toJSONString
(
runLog
,
WriteClassName
));
Thread
.
sleep
(
1000
*
thisRetryCount
);
retryRpcHost
(
client
,
host
,
runKey
,
retryTotalCount
,
++
thisRetryCount
);
}
log
.
error
(
"----与主机【{}】建立通道,总共【{}】次,全部失败,开始挑选下一个负载均衡方案重试,请稍后------"
,
host
,
retryTotalCount
);
String
format
=
String
.
format
(
"与主机【%s】建立通道,总共【%s】次,全部失败,开始挑选下一个负载均衡方案重试,请稍后"
,
host
,
retryTotalCount
);
//redis模板
StringRedisTemplate
stringRedisTemplate
=
SpringUtil
.
getBean
(
StringRedisTemplate
.
class
);
RunLog
runLog
=
RunLog
.
builder
().
runLog
(
format
).
isEnd
(
false
).
build
();
stringRedisTemplate
.
opsForList
().
rightPush
(
runKey
,
JSON
.
toJSONString
(
runLog
,
WriteClassName
));
log
.
error
(
format
);
return
false
;
}
}
...
...
byit-plugin-core/myth-plugin-rpc-client/src/main/java/com/byit/utils/RpcSpringUtil.java
deleted
100644 → 0
View file @
44bf9310
package
com
.
byit
.
utils
;
import
org.springframework.beans.BeansException
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextAware
;
import
java.util.Map
;
public
class
RpcSpringUtil
implements
ApplicationContextAware
{
private
static
ApplicationContext
applicationContext
=
null
;
@Override
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
throws
BeansException
{
if
(
RpcSpringUtil
.
applicationContext
==
null
)
{
RpcSpringUtil
.
applicationContext
=
applicationContext
;
}
}
/**
* 获取applicationContext
* @return 返回applicationContext
*/
public
static
ApplicationContext
getApplicationContext
()
{
return
applicationContext
;
}
/**
* 通过name获取 Bean.
* @param name
* @return
*/
public
static
Object
getBean
(
String
name
){
return
getApplicationContext
().
getBean
(
name
);
}
/**
* 通过class获取Bean.
* @param clazz
* @param <T>
* @return
*/
public
static
<
T
>
T
getBean
(
Class
<
T
>
clazz
){
return
getApplicationContext
().
getBean
(
clazz
);
}
/**
* 通过name,以及Clazz返回指定的Bean
* @param name
* @param clazz
* @param <T>
* @return
*/
public
static
<
T
>
T
getBean
(
String
name
,
Class
<
T
>
clazz
){
return
getApplicationContext
().
getBean
(
name
,
clazz
);
}
/**
* 获取实现某个接口的类
* @param clazz
* @param <T>
* @return
*/
public
static
<
T
>
Map
<
String
,
T
>
getBeansOfType
(
Class
<
T
>
clazz
){
return
getApplicationContext
().
getBeansOfType
(
clazz
);
}
}
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