Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
X
XXL-JOB
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
靳帅
XXL-JOB
Commits
2ced6010
提交
2ced6010
authored
11月 19, 2019
作者:
xuxueli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
调度中心回调API服务改为restful方式;
上级
9767174c
显示空白字符变更
内嵌
并排
正在显示
13 个修改的文件
包含
361 行增加
和
183 行删除
+361
-183
XXL-JOB官方文档.md
doc/XXL-JOB官方文档.md
+6
-4
pom.xml
pom.xml
+1
-1
JobApiController.java
...n/java/com/xxl/job/admin/controller/JobApiController.java
+74
-11
XxlJobAdminConfig.java
...n/java/com/xxl/job/admin/core/conf/XxlJobAdminConfig.java
+0
-7
XxlJobScheduler.java
...ava/com/xxl/job/admin/core/scheduler/XxlJobScheduler.java
+16
-55
AdminBizImpl.java
...ain/java/com/xxl/job/admin/service/impl/AdminBizImpl.java
+17
-0
AdminBizTest.java
...dmin/src/test/java/com/xxl/job/adminbiz/AdminBizTest.java
+29
-43
ExecutorBizTest.java
...n/src/test/java/com/xxl/job/executor/ExecutorBizTest.java
+17
-14
AdminBiz.java
...job-core/src/main/java/com/xxl/job/core/biz/AdminBiz.java
+0
-2
AdminBizClient.java
...main/java/com/xxl/job/core/biz/client/AdminBizClient.java
+48
-0
XxlJobExecutor.java
...c/main/java/com/xxl/job/core/executor/XxlJobExecutor.java
+15
-32
XxlJobRemotingUtil.java
...c/main/java/com/xxl/job/core/util/XxlJobRemotingUtil.java
+122
-0
ExecutorBizImplTest.java
...t/java/com/xxl/job/core/biz/impl/ExecutorBizImplTest.java
+16
-14
没有找到文件。
doc/XXL-JOB官方文档.md
浏览文件 @
2ced6010
...
@@ -1588,10 +1588,11 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
...
@@ -1588,10 +1588,11 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
-
17、DB脚本默认编码改为utf8mb4,修复字符乱码问题(建议Mysql版本5.7+);
-
17、DB脚本默认编码改为utf8mb4,修复字符乱码问题(建议Mysql版本5.7+);
-
18、调度中心任务平均分配,触发组件每次获取与线程池数量相关数量的任务,避免大量任务集中在单个调度中心集群节点;
-
18、调度中心任务平均分配,触发组件每次获取与线程池数量相关数量的任务,避免大量任务集中在单个调度中心集群节点;
-
19、调度中心移除SQL中的 "now()" 函数;集群部署时不再依赖DB时钟,仅需要保证调度中心应用节点时钟一致即可;
-
19、调度中心移除SQL中的 "now()" 函数;集群部署时不再依赖DB时钟,仅需要保证调度中心应用节点时钟一致即可;
-
20、
[
ING
]
xxl-rpc服务端线程优化,降低线程内存开销;
-
20、xxl-rpc服务端线程优化,降低线程内存开销;
-
21、
[
ING
]
调度日志优化:支持设置日志保留天数,过期日志天维度记录报表,并清理;调度报表汇总实时数据和报表;
-
21、调度中心回调API服务改为restful方式;
-
22、
[
ING
]
调度中心日志删除,改为分页获取ID,根据ID删除的方式;
-
22、
[
ING
]
调度日志优化:支持设置日志保留天数,过期日志天维度记录报表,并清理;调度报表汇总实时数据和报表;
-
23、
[
ING
]
任务回调改为restful方式;
-
23、
[
ING
]
调度中心日志删除,改为分页获取ID,根据ID删除的方式;
### TODO LIST
### TODO LIST
...
@@ -1630,6 +1631,7 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
...
@@ -1630,6 +1631,7 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
-
33、任务执行一次的时候指定IP;
-
33、任务执行一次的时候指定IP;
-
34、通讯调整;双向HTTP,回调和其他API自定义AccessToken,Restful,执行器复用容器端口;
-
34、通讯调整;双向HTTP,回调和其他API自定义AccessToken,Restful,执行器复用容器端口;
-
35、父子任务参数传递;流程任务等,透传动态参数;
-
35、父子任务参数传递;流程任务等,透传动态参数;
-
36、任务操作API服务调整为和回调服务一致,降低接入成本;
## 七、其他
## 七、其他
...
...
pom.xml
浏览文件 @
2ced6010
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
<maven.compiler.target>
1.7
</maven.compiler.target>
<maven.compiler.target>
1.7
</maven.compiler.target>
<maven.test.skip>
true
</maven.test.skip>
<maven.test.skip>
true
</maven.test.skip>
<xxl-rpc.version>
1.4.
1
</xxl-rpc.version>
<xxl-rpc.version>
1.4.
2
</xxl-rpc.version>
<spring.version>
4.3.25.RELEASE
</spring.version>
<spring.version>
4.3.25.RELEASE
</spring.version>
<spring-boot.version>
1.5.22.RELEASE
</spring-boot.version>
<spring-boot.version>
1.5.22.RELEASE
</spring-boot.version>
...
...
xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobApiController.java
浏览文件 @
2ced6010
package
com
.
xxl
.
job
.
admin
.
controller
;
package
com
.
xxl
.
job
.
admin
.
controller
;
import
com.xxl.job.admin.controller.annotation.PermissionLimit
;
import
com.xxl.job.admin.controller.annotation.PermissionLimit
;
import
com.xxl.job.admin.core.
scheduler.XxlJobScheduler
;
import
com.xxl.job.admin.core.
conf.XxlJobAdminConfig
;
import
com.xxl.job.core.biz.AdminBiz
;
import
com.xxl.job.core.biz.AdminBiz
;
import
org.springframework.beans.factory.InitializingBean
;
import
com.xxl.job.core.biz.model.HandleCallbackParam
;
import
com.xxl.job.core.biz.model.RegistryParam
;
import
com.xxl.job.core.biz.model.ReturnT
;
import
com.xxl.job.core.util.XxlJobRemotingUtil
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
javax.
servlet.ServletException
;
import
javax.
annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.List
;
import
java.io.IOException
;
/**
/**
* Created by xuxueli on 17/5/10.
* Created by xuxueli on 17/5/10.
*/
*/
@Controller
@Controller
public
class
JobApiController
implements
InitializingBean
{
@RequestMapping
(
"/api"
)
public
class
JobApiController
{
@Resource
private
AdminBiz
adminBiz
;
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
// ---------------------- admin biz ----------------------
/**
* callback
*
* @param callbackParamList
* @return
*/
@RequestMapping
(
"/callback"
)
@ResponseBody
@PermissionLimit
(
limit
=
false
)
public
ReturnT
<
String
>
callback
(
HttpServletRequest
request
,
@RequestBody
List
<
HandleCallbackParam
>
callbackParamList
)
{
if
(
XxlJobAdminConfig
.
getAdminConfig
().
getAccessToken
()!=
null
&&
XxlJobAdminConfig
.
getAdminConfig
().
getAccessToken
().
trim
().
length
()>
0
&&
!
XxlJobAdminConfig
.
getAdminConfig
().
getAccessToken
().
equals
(
request
.
getHeader
(
XxlJobRemotingUtil
.
XXL_RPC_ACCESS_TOKEN
)))
{
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
"The access token is wrong."
);
}
return
adminBiz
.
callback
(
callbackParamList
);
}
/**
* registry
*
* @param registryParam
* @return
*/
@RequestMapping
(
"/registry"
)
@ResponseBody
@PermissionLimit
(
limit
=
false
)
public
ReturnT
<
String
>
registry
(
HttpServletRequest
request
,
@RequestBody
RegistryParam
registryParam
)
{
if
(
XxlJobAdminConfig
.
getAdminConfig
().
getAccessToken
()!=
null
&&
XxlJobAdminConfig
.
getAdminConfig
().
getAccessToken
().
trim
().
length
()>
0
&&
!
XxlJobAdminConfig
.
getAdminConfig
().
getAccessToken
().
equals
(
request
.
getHeader
(
XxlJobRemotingUtil
.
XXL_RPC_ACCESS_TOKEN
)))
{
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
"The access token is wrong."
);
}
return
adminBiz
.
registry
(
registryParam
);
}
}
@RequestMapping
(
AdminBiz
.
MAPPING
)
/**
* registry remove
*
* @param registryParam
* @return
*/
@RequestMapping
(
"/registryRemove"
)
@ResponseBody
@PermissionLimit
(
limit
=
false
)
@PermissionLimit
(
limit
=
false
)
public
void
api
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
,
ServletException
{
public
ReturnT
<
String
>
registryRemove
(
HttpServletRequest
request
,
@RequestBody
RegistryParam
registryParam
)
{
XxlJobScheduler
.
invokeAdminService
(
request
,
response
);
if
(
XxlJobAdminConfig
.
getAdminConfig
().
getAccessToken
()!=
null
&&
XxlJobAdminConfig
.
getAdminConfig
().
getAccessToken
().
trim
().
length
()>
0
&&
!
XxlJobAdminConfig
.
getAdminConfig
().
getAccessToken
().
equals
(
request
.
getHeader
(
XxlJobRemotingUtil
.
XXL_RPC_ACCESS_TOKEN
)))
{
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
"The access token is wrong."
);
}
}
return
adminBiz
.
registryRemove
(
registryParam
);
}
// ---------------------- job biz ----------------------
}
}
xxl-job-admin/src/main/java/com/xxl/job/admin/core/conf/XxlJobAdminConfig.java
浏览文件 @
2ced6010
...
@@ -5,7 +5,6 @@ import com.xxl.job.admin.dao.XxlJobGroupDao;
...
@@ -5,7 +5,6 @@ import com.xxl.job.admin.dao.XxlJobGroupDao;
import
com.xxl.job.admin.dao.XxlJobInfoDao
;
import
com.xxl.job.admin.dao.XxlJobInfoDao
;
import
com.xxl.job.admin.dao.XxlJobLogDao
;
import
com.xxl.job.admin.dao.XxlJobLogDao
;
import
com.xxl.job.admin.dao.XxlJobRegistryDao
;
import
com.xxl.job.admin.dao.XxlJobRegistryDao
;
import
com.xxl.job.core.biz.AdminBiz
;
import
org.springframework.beans.factory.DisposableBean
;
import
org.springframework.beans.factory.DisposableBean
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
...
@@ -77,8 +76,6 @@ public class XxlJobAdminConfig implements InitializingBean, DisposableBean {
...
@@ -77,8 +76,6 @@ public class XxlJobAdminConfig implements InitializingBean, DisposableBean {
@Resource
@Resource
private
XxlJobGroupDao
xxlJobGroupDao
;
private
XxlJobGroupDao
xxlJobGroupDao
;
@Resource
@Resource
private
AdminBiz
adminBiz
;
@Resource
private
JavaMailSender
mailSender
;
private
JavaMailSender
mailSender
;
@Resource
@Resource
private
DataSource
dataSource
;
private
DataSource
dataSource
;
...
@@ -126,10 +123,6 @@ public class XxlJobAdminConfig implements InitializingBean, DisposableBean {
...
@@ -126,10 +123,6 @@ public class XxlJobAdminConfig implements InitializingBean, DisposableBean {
return
xxlJobGroupDao
;
return
xxlJobGroupDao
;
}
}
public
AdminBiz
getAdminBiz
()
{
return
adminBiz
;
}
public
JavaMailSender
getMailSender
()
{
public
JavaMailSender
getMailSender
()
{
return
mailSender
;
return
mailSender
;
}
}
...
...
xxl-job-admin/src/main/java/com/xxl/job/admin/core/scheduler/XxlJobScheduler.java
浏览文件 @
2ced6010
...
@@ -6,24 +6,16 @@ import com.xxl.job.admin.core.thread.JobRegistryMonitorHelper;
...
@@ -6,24 +6,16 @@ import com.xxl.job.admin.core.thread.JobRegistryMonitorHelper;
import
com.xxl.job.admin.core.thread.JobScheduleHelper
;
import
com.xxl.job.admin.core.thread.JobScheduleHelper
;
import
com.xxl.job.admin.core.thread.JobTriggerPoolHelper
;
import
com.xxl.job.admin.core.thread.JobTriggerPoolHelper
;
import
com.xxl.job.admin.core.util.I18nUtil
;
import
com.xxl.job.admin.core.util.I18nUtil
;
import
com.xxl.job.core.biz.AdminBiz
;
import
com.xxl.job.core.biz.ExecutorBiz
;
import
com.xxl.job.core.biz.ExecutorBiz
;
import
com.xxl.job.core.enums.ExecutorBlockStrategyEnum
;
import
com.xxl.job.core.enums.ExecutorBlockStrategyEnum
;
import
com.xxl.rpc.remoting.invoker.XxlRpcInvokerFactory
;
import
com.xxl.rpc.remoting.invoker.call.CallType
;
import
com.xxl.rpc.remoting.invoker.call.CallType
;
import
com.xxl.rpc.remoting.invoker.reference.XxlRpcReferenceBean
;
import
com.xxl.rpc.remoting.invoker.reference.XxlRpcReferenceBean
;
import
com.xxl.rpc.remoting.invoker.route.LoadBalance
;
import
com.xxl.rpc.remoting.invoker.route.LoadBalance
;
import
com.xxl.rpc.remoting.net.NetEnum
;
import
com.xxl.rpc.remoting.net.impl.netty_http.client.NettyHttpClient
;
import
com.xxl.rpc.remoting.net.impl.servlet.server.ServletServerHandler
;
import
com.xxl.rpc.serialize.impl.HessianSerializer
;
import
com.xxl.rpc.remoting.provider.XxlRpcProviderFactory
;
import
com.xxl.rpc.serialize.Serializer
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
javax.servlet.ServletException
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentMap
;
import
java.util.concurrent.ConcurrentMap
;
...
@@ -39,9 +31,6 @@ public class XxlJobScheduler {
...
@@ -39,9 +31,6 @@ public class XxlJobScheduler {
// init i18n
// init i18n
initI18n
();
initI18n
();
// admin-server
initRpcProvider
();
// admin registry monitor run
// admin registry monitor run
JobRegistryMonitorHelper
.
getInstance
().
start
();
JobRegistryMonitorHelper
.
getInstance
().
start
();
...
@@ -72,8 +61,6 @@ public class XxlJobScheduler {
...
@@ -72,8 +61,6 @@ public class XxlJobScheduler {
// admin registry stop
// admin registry stop
JobRegistryMonitorHelper
.
getInstance
().
toStop
();
JobRegistryMonitorHelper
.
getInstance
().
toStop
();
// admin-server
stopRpcProvider
();
}
}
// ---------------------- I18n ----------------------
// ---------------------- I18n ----------------------
...
@@ -84,34 +71,6 @@ public class XxlJobScheduler {
...
@@ -84,34 +71,6 @@ public class XxlJobScheduler {
}
}
}
}
// ---------------------- admin rpc provider (no server version) ----------------------
private
static
ServletServerHandler
servletServerHandler
;
private
void
initRpcProvider
(){
// init
XxlRpcProviderFactory
xxlRpcProviderFactory
=
new
XxlRpcProviderFactory
();
xxlRpcProviderFactory
.
initConfig
(
NetEnum
.
NETTY_HTTP
,
Serializer
.
SerializeEnum
.
HESSIAN
.
getSerializer
(),
null
,
0
,
XxlJobAdminConfig
.
getAdminConfig
().
getAccessToken
(),
null
,
null
);
// add services
xxlRpcProviderFactory
.
addService
(
AdminBiz
.
class
.
getName
(),
null
,
XxlJobAdminConfig
.
getAdminConfig
().
getAdminBiz
());
// servlet handler
servletServerHandler
=
new
ServletServerHandler
(
xxlRpcProviderFactory
);
}
private
void
stopRpcProvider
()
throws
Exception
{
XxlRpcInvokerFactory
.
getInstance
().
stop
();
}
public
static
void
invokeAdminService
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
,
ServletException
{
servletServerHandler
.
handle
(
null
,
request
,
response
);
}
// ---------------------- executor-client ----------------------
// ---------------------- executor-client ----------------------
private
static
ConcurrentMap
<
String
,
ExecutorBiz
>
executorBizRepository
=
new
ConcurrentHashMap
<
String
,
ExecutorBiz
>();
private
static
ConcurrentMap
<
String
,
ExecutorBiz
>
executorBizRepository
=
new
ConcurrentHashMap
<
String
,
ExecutorBiz
>();
public
static
ExecutorBiz
getExecutorBiz
(
String
address
)
throws
Exception
{
public
static
ExecutorBiz
getExecutorBiz
(
String
address
)
throws
Exception
{
...
@@ -128,18 +87,20 @@ public class XxlJobScheduler {
...
@@ -128,18 +87,20 @@ public class XxlJobScheduler {
}
}
// set-cache
// set-cache
executorBiz
=
(
ExecutorBiz
)
new
XxlRpcReferenceBean
(
XxlRpcReferenceBean
referenceBean
=
new
XxlRpcReferenceBean
();
NetEnum
.
NETTY_HTTP
,
referenceBean
.
setClient
(
NettyHttpClient
.
class
);
Serializer
.
SerializeEnum
.
HESSIAN
.
getSerializer
(),
referenceBean
.
setSerializer
(
HessianSerializer
.
class
);
CallType
.
SYNC
,
referenceBean
.
setCallType
(
CallType
.
SYNC
);
LoadBalance
.
ROUND
,
referenceBean
.
setLoadBalance
(
LoadBalance
.
ROUND
);
ExecutorBiz
.
class
,
referenceBean
.
setIface
(
ExecutorBiz
.
class
);
null
,
referenceBean
.
setVersion
(
null
);
3000
,
referenceBean
.
setTimeout
(
3000
);
address
,
referenceBean
.
setAddress
(
address
);
XxlJobAdminConfig
.
getAdminConfig
().
getAccessToken
(),
referenceBean
.
setAccessToken
(
XxlJobAdminConfig
.
getAdminConfig
().
getAccessToken
());
null
,
referenceBean
.
setInvokeCallback
(
null
);
null
).
getObject
();
referenceBean
.
setInvokerFactory
(
null
);
executorBiz
=
(
ExecutorBiz
)
referenceBean
.
getObject
();
executorBizRepository
.
put
(
address
,
executorBiz
);
executorBizRepository
.
put
(
address
,
executorBiz
);
return
executorBiz
;
return
executorBiz
;
...
...
xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/AdminBizImpl.java
浏览文件 @
2ced6010
...
@@ -17,6 +17,7 @@ import com.xxl.job.core.handler.IJobHandler;
...
@@ -17,6 +17,7 @@ import com.xxl.job.core.handler.IJobHandler;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.text.MessageFormat
;
import
java.text.MessageFormat
;
...
@@ -126,6 +127,14 @@ public class AdminBizImpl implements AdminBiz {
...
@@ -126,6 +127,14 @@ public class AdminBizImpl implements AdminBiz {
@Override
@Override
public
ReturnT
<
String
>
registry
(
RegistryParam
registryParam
)
{
public
ReturnT
<
String
>
registry
(
RegistryParam
registryParam
)
{
// valid
if
(!
StringUtils
.
hasText
(
registryParam
.
getRegistGroup
())
||
!
StringUtils
.
hasText
(
registryParam
.
getRegistryKey
())
||
!
StringUtils
.
hasText
(
registryParam
.
getRegistryValue
()))
{
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
"Illegal Argument."
);
}
int
ret
=
xxlJobRegistryDao
.
registryUpdate
(
registryParam
.
getRegistGroup
(),
registryParam
.
getRegistryKey
(),
registryParam
.
getRegistryValue
(),
new
Date
());
int
ret
=
xxlJobRegistryDao
.
registryUpdate
(
registryParam
.
getRegistGroup
(),
registryParam
.
getRegistryKey
(),
registryParam
.
getRegistryValue
(),
new
Date
());
if
(
ret
<
1
)
{
if
(
ret
<
1
)
{
xxlJobRegistryDao
.
registrySave
(
registryParam
.
getRegistGroup
(),
registryParam
.
getRegistryKey
(),
registryParam
.
getRegistryValue
(),
new
Date
());
xxlJobRegistryDao
.
registrySave
(
registryParam
.
getRegistGroup
(),
registryParam
.
getRegistryKey
(),
registryParam
.
getRegistryValue
(),
new
Date
());
...
@@ -138,6 +147,14 @@ public class AdminBizImpl implements AdminBiz {
...
@@ -138,6 +147,14 @@ public class AdminBizImpl implements AdminBiz {
@Override
@Override
public
ReturnT
<
String
>
registryRemove
(
RegistryParam
registryParam
)
{
public
ReturnT
<
String
>
registryRemove
(
RegistryParam
registryParam
)
{
// valid
if
(!
StringUtils
.
hasText
(
registryParam
.
getRegistGroup
())
||
!
StringUtils
.
hasText
(
registryParam
.
getRegistryKey
())
||
!
StringUtils
.
hasText
(
registryParam
.
getRegistryValue
()))
{
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
"Illegal Argument."
);
}
int
ret
=
xxlJobRegistryDao
.
registryDelete
(
registryParam
.
getRegistGroup
(),
registryParam
.
getRegistryKey
(),
registryParam
.
getRegistryValue
());
int
ret
=
xxlJobRegistryDao
.
registryDelete
(
registryParam
.
getRegistGroup
(),
registryParam
.
getRegistryKey
(),
registryParam
.
getRegistryValue
());
if
(
ret
>
0
)
{
if
(
ret
>
0
)
{
...
...
xxl-job-admin/src/test/java/com/xxl/job/adminbiz/AdminBizTest.java
浏览文件 @
2ced6010
package
com
.
xxl
.
job
.
adminbiz
;
package
com
.
xxl
.
job
.
adminbiz
;
import
com.xxl.job.core.biz.AdminBiz
;
import
com.xxl.job.core.biz.AdminBiz
;
import
com.xxl.job.core.biz.client.AdminBizClient
;
import
com.xxl.job.core.biz.model.HandleCallbackParam
;
import
com.xxl.job.core.biz.model.RegistryParam
;
import
com.xxl.job.core.biz.model.RegistryParam
;
import
com.xxl.job.core.biz.model.ReturnT
;
import
com.xxl.job.core.biz.model.ReturnT
;
import
com.xxl.job.core.enums.RegistryConfig
;
import
com.xxl.job.core.enums.RegistryConfig
;
import
com.xxl.rpc.remoting.invoker.XxlRpcInvokerFactory
;
import
com.xxl.rpc.remoting.invoker.call.CallType
;
import
com.xxl.rpc.remoting.invoker.reference.XxlRpcReferenceBean
;
import
com.xxl.rpc.remoting.invoker.route.LoadBalance
;
import
com.xxl.rpc.remoting.net.NetEnum
;
import
com.xxl.rpc.serialize.Serializer
;
import
org.junit.Assert
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.junit.Test
;
import
java.util.Arrays
;
import
java.util.List
;
/**
/**
* admin api test
* admin api test
*
*
...
@@ -21,37 +20,38 @@ import org.junit.Test;
...
@@ -21,37 +20,38 @@ import org.junit.Test;
public
class
AdminBizTest
{
public
class
AdminBizTest
{
// admin-client
// admin-client
private
static
String
addressUrl
=
"http://127.0.0.1:8080/xxl-job-admin
"
.
concat
(
AdminBiz
.
MAPPING
)
;
private
static
String
addressUrl
=
"http://127.0.0.1:8080/xxl-job-admin
/"
;
private
static
String
accessToken
=
null
;
private
static
String
accessToken
=
null
;
@Test
public
void
callback
()
throws
Exception
{
AdminBiz
adminBiz
=
new
AdminBizClient
(
addressUrl
,
accessToken
);
HandleCallbackParam
param
=
new
HandleCallbackParam
();
param
.
setLogId
(
1
);
param
.
setExecuteResult
(
ReturnT
.
SUCCESS
);
List
<
HandleCallbackParam
>
callbackParamList
=
Arrays
.
asList
(
param
);
ReturnT
<
String
>
returnT
=
adminBiz
.
callback
(
callbackParamList
);
Assert
.
assertTrue
(
returnT
.
getCode
()
==
ReturnT
.
SUCCESS_CODE
);
}
/**
/**
* registry executor
* registry executor
*
*
* @throws Exception
* @throws Exception
*/
*/
@Test
@Test
public
void
registryTest
()
throws
Exception
{
public
void
registry
()
throws
Exception
{
addressUrl
=
addressUrl
.
replace
(
"http://"
,
""
);
AdminBiz
adminBiz
=
new
AdminBizClient
(
addressUrl
,
accessToken
);
AdminBiz
adminBiz
=
(
AdminBiz
)
new
XxlRpcReferenceBean
(
NetEnum
.
NETTY_HTTP
,
Serializer
.
SerializeEnum
.
HESSIAN
.
getSerializer
(),
CallType
.
SYNC
,
LoadBalance
.
ROUND
,
AdminBiz
.
class
,
null
,
3000
,
addressUrl
,
accessToken
,
null
,
null
).
getObject
();
// test executor registry
RegistryParam
registryParam
=
new
RegistryParam
(
RegistryConfig
.
RegistType
.
EXECUTOR
.
name
(),
"xxl-job-executor-example"
,
"127.0.0.1:9999"
);
RegistryParam
registryParam
=
new
RegistryParam
(
RegistryConfig
.
RegistType
.
EXECUTOR
.
name
(),
"xxl-job-executor-example"
,
"127.0.0.1:9999"
);
ReturnT
<
String
>
returnT
=
adminBiz
.
registry
(
registryParam
);
ReturnT
<
String
>
returnT
=
adminBiz
.
registry
(
registryParam
);
Assert
.
assertTrue
(
returnT
.
getCode
()
==
ReturnT
.
SUCCESS_CODE
);
// stop invoker
Assert
.
assertTrue
(
returnT
.
getCode
()
==
ReturnT
.
SUCCESS_CODE
);
XxlRpcInvokerFactory
.
getInstance
().
stop
();
}
}
/**
/**
...
@@ -61,27 +61,13 @@ public class AdminBizTest {
...
@@ -61,27 +61,13 @@ public class AdminBizTest {
*/
*/
@Test
@Test
public
void
registryRemove
()
throws
Exception
{
public
void
registryRemove
()
throws
Exception
{
addressUrl
=
addressUrl
.
replace
(
"http://"
,
""
);
AdminBiz
adminBiz
=
new
AdminBizClient
(
addressUrl
,
accessToken
);
AdminBiz
adminBiz
=
(
AdminBiz
)
new
XxlRpcReferenceBean
(
NetEnum
.
NETTY_HTTP
,
Serializer
.
SerializeEnum
.
HESSIAN
.
getSerializer
(),
CallType
.
SYNC
,
LoadBalance
.
ROUND
,
AdminBiz
.
class
,
null
,
3000
,
addressUrl
,
accessToken
,
null
,
null
).
getObject
();
// test executor registry remove
RegistryParam
registryParam
=
new
RegistryParam
(
RegistryConfig
.
RegistType
.
EXECUTOR
.
name
(),
"xxl-job-executor-example"
,
"127.0.0.1:9999"
);
RegistryParam
registryParam
=
new
RegistryParam
(
RegistryConfig
.
RegistType
.
EXECUTOR
.
name
(),
"xxl-job-executor-example"
,
"127.0.0.1:9999"
);
ReturnT
<
String
>
returnT
=
adminBiz
.
registryRemove
(
registryParam
);
ReturnT
<
String
>
returnT
=
adminBiz
.
registryRemove
(
registryParam
);
Assert
.
assertTrue
(
returnT
.
getCode
()
==
ReturnT
.
SUCCESS_CODE
);
Assert
.
assertTrue
(
returnT
.
getCode
()
==
ReturnT
.
SUCCESS_CODE
);
// stop invoker
XxlRpcInvokerFactory
.
getInstance
().
stop
();
}
}
}
}
xxl-job-admin/src/test/java/com/xxl/job/executor/ExecutorBizTest.java
浏览文件 @
2ced6010
...
@@ -9,8 +9,8 @@ import com.xxl.rpc.remoting.invoker.XxlRpcInvokerFactory;
...
@@ -9,8 +9,8 @@ import com.xxl.rpc.remoting.invoker.XxlRpcInvokerFactory;
import
com.xxl.rpc.remoting.invoker.call.CallType
;
import
com.xxl.rpc.remoting.invoker.call.CallType
;
import
com.xxl.rpc.remoting.invoker.reference.XxlRpcReferenceBean
;
import
com.xxl.rpc.remoting.invoker.reference.XxlRpcReferenceBean
;
import
com.xxl.rpc.remoting.invoker.route.LoadBalance
;
import
com.xxl.rpc.remoting.invoker.route.LoadBalance
;
import
com.xxl.rpc.remoting.net.
NetEnum
;
import
com.xxl.rpc.remoting.net.
impl.netty_http.client.NettyHttpClient
;
import
com.xxl.rpc.serialize.Serializer
;
import
com.xxl.rpc.serialize.
impl.Hessian
Serializer
;
/**
/**
* executor-api client, test
* executor-api client, test
...
@@ -49,18 +49,21 @@ public class ExecutorBizTest {
...
@@ -49,18 +49,21 @@ public class ExecutorBizTest {
// do remote trigger
// do remote trigger
String
accessToken
=
null
;
String
accessToken
=
null
;
ExecutorBiz
executorBiz
=
(
ExecutorBiz
)
new
XxlRpcReferenceBean
(
NetEnum
.
NETTY_HTTP
,
XxlRpcReferenceBean
referenceBean
=
new
XxlRpcReferenceBean
();
Serializer
.
SerializeEnum
.
HESSIAN
.
getSerializer
(),
referenceBean
.
setClient
(
NettyHttpClient
.
class
);
CallType
.
SYNC
,
referenceBean
.
setSerializer
(
HessianSerializer
.
class
);
LoadBalance
.
ROUND
,
referenceBean
.
setCallType
(
CallType
.
SYNC
);
ExecutorBiz
.
class
,
referenceBean
.
setLoadBalance
(
LoadBalance
.
ROUND
);
null
,
referenceBean
.
setIface
(
ExecutorBiz
.
class
);
3000
,
referenceBean
.
setVersion
(
null
);
"127.0.0.1:9999"
,
referenceBean
.
setTimeout
(
3000
);
null
,
referenceBean
.
setAddress
(
"127.0.0.1:9999"
);
null
,
referenceBean
.
setAccessToken
(
null
);
null
).
getObject
();
referenceBean
.
setInvokeCallback
(
null
);
referenceBean
.
setInvokerFactory
(
null
);
ExecutorBiz
executorBiz
=
(
ExecutorBiz
)
referenceBean
.
getObject
();
ReturnT
<
String
>
runResult
=
executorBiz
.
run
(
triggerParam
);
ReturnT
<
String
>
runResult
=
executorBiz
.
run
(
triggerParam
);
...
...
xxl-job-core/src/main/java/com/xxl/job/core/biz/AdminBiz.java
浏览文件 @
2ced6010
...
@@ -11,8 +11,6 @@ import java.util.List;
...
@@ -11,8 +11,6 @@ import java.util.List;
*/
*/
public
interface
AdminBiz
{
public
interface
AdminBiz
{
public
static
final
String
MAPPING
=
"/api"
;
// ---------------------- callback ----------------------
// ---------------------- callback ----------------------
...
...
xxl-job-core/src/main/java/com/xxl/job/core/biz/client/AdminBizClient.java
0 → 100644
浏览文件 @
2ced6010
package
com
.
xxl
.
job
.
core
.
biz
.
client
;
import
com.xxl.job.core.biz.AdminBiz
;
import
com.xxl.job.core.biz.model.HandleCallbackParam
;
import
com.xxl.job.core.biz.model.RegistryParam
;
import
com.xxl.job.core.biz.model.ReturnT
;
import
com.xxl.job.core.util.XxlJobRemotingUtil
;
import
java.util.List
;
/**
* admin api test
*
* @author xuxueli 2017-07-28 22:14:52
*/
public
class
AdminBizClient
implements
AdminBiz
{
public
AdminBizClient
()
{
}
public
AdminBizClient
(
String
addressUrl
,
String
accessToken
)
{
this
.
addressUrl
=
addressUrl
;
this
.
accessToken
=
accessToken
;
// valid
if
(!
this
.
addressUrl
.
endsWith
(
"/"
))
{
this
.
addressUrl
=
this
.
addressUrl
+
"/"
;
}
}
private
String
addressUrl
;
private
String
accessToken
;
@Override
public
ReturnT
<
String
>
callback
(
List
<
HandleCallbackParam
>
callbackParamList
)
{
return
XxlJobRemotingUtil
.
postBody
(
addressUrl
+
"api/callback"
,
accessToken
,
callbackParamList
,
3
);
}
@Override
public
ReturnT
<
String
>
registry
(
RegistryParam
registryParam
)
{
return
XxlJobRemotingUtil
.
postBody
(
addressUrl
+
"api/registry"
,
accessToken
,
registryParam
,
3
);
}
@Override
public
ReturnT
<
String
>
registryRemove
(
RegistryParam
registryParam
)
{
return
XxlJobRemotingUtil
.
postBody
(
addressUrl
+
"api/registryRemove"
,
accessToken
,
registryParam
,
3
);
}
}
xxl-job-core/src/main/java/com/xxl/job/core/executor/XxlJobExecutor.java
浏览文件 @
2ced6010
...
@@ -2,6 +2,7 @@ package com.xxl.job.core.executor;
...
@@ -2,6 +2,7 @@ package com.xxl.job.core.executor;
import
com.xxl.job.core.biz.AdminBiz
;
import
com.xxl.job.core.biz.AdminBiz
;
import
com.xxl.job.core.biz.ExecutorBiz
;
import
com.xxl.job.core.biz.ExecutorBiz
;
import
com.xxl.job.core.biz.client.AdminBizClient
;
import
com.xxl.job.core.biz.impl.ExecutorBizImpl
;
import
com.xxl.job.core.biz.impl.ExecutorBizImpl
;
import
com.xxl.job.core.handler.IJobHandler
;
import
com.xxl.job.core.handler.IJobHandler
;
import
com.xxl.job.core.log.XxlJobFileAppender
;
import
com.xxl.job.core.log.XxlJobFileAppender
;
...
@@ -11,12 +12,10 @@ import com.xxl.job.core.thread.JobThread;
...
@@ -11,12 +12,10 @@ import com.xxl.job.core.thread.JobThread;
import
com.xxl.job.core.thread.TriggerCallbackThread
;
import
com.xxl.job.core.thread.TriggerCallbackThread
;
import
com.xxl.rpc.registry.ServiceRegistry
;
import
com.xxl.rpc.registry.ServiceRegistry
;
import
com.xxl.rpc.remoting.invoker.XxlRpcInvokerFactory
;
import
com.xxl.rpc.remoting.invoker.XxlRpcInvokerFactory
;
import
com.xxl.rpc.remoting.invoker.call.CallType
;
import
com.xxl.rpc.remoting.net.impl.netty_http.server.NettyHttpServer
;
import
com.xxl.rpc.remoting.invoker.reference.XxlRpcReferenceBean
;
import
com.xxl.rpc.remoting.invoker.route.LoadBalance
;
import
com.xxl.rpc.remoting.net.NetEnum
;
import
com.xxl.rpc.remoting.provider.XxlRpcProviderFactory
;
import
com.xxl.rpc.remoting.provider.XxlRpcProviderFactory
;
import
com.xxl.rpc.serialize.Serializer
;
import
com.xxl.rpc.serialize.Serializer
;
import
com.xxl.rpc.serialize.impl.HessianSerializer
;
import
com.xxl.rpc.util.IpUtil
;
import
com.xxl.rpc.util.IpUtil
;
import
com.xxl.rpc.util.NetUtil
;
import
com.xxl.rpc.util.NetUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -105,35 +104,18 @@ public class XxlJobExecutor {
...
@@ -105,35 +104,18 @@ public class XxlJobExecutor {
// destory TriggerCallbackThread
// destory TriggerCallbackThread
TriggerCallbackThread
.
getInstance
().
toStop
();
TriggerCallbackThread
.
getInstance
().
toStop
();
// destory invoker
stopInvokerFactory
();
}
}
// ---------------------- admin-client (rpc invoker) ----------------------
// ---------------------- admin-client (rpc invoker) ----------------------
private
static
List
<
AdminBiz
>
adminBizList
;
private
static
List
<
AdminBiz
>
adminBizList
;
private
static
Serializer
serializer
;
private
static
Serializer
serializer
=
new
HessianSerializer
()
;
private
void
initAdminBizList
(
String
adminAddresses
,
String
accessToken
)
throws
Exception
{
private
void
initAdminBizList
(
String
adminAddresses
,
String
accessToken
)
throws
Exception
{
serializer
=
Serializer
.
SerializeEnum
.
HESSIAN
.
getSerializer
();
if
(
adminAddresses
!=
null
&&
adminAddresses
.
trim
().
length
()>
0
)
{
if
(
adminAddresses
!=
null
&&
adminAddresses
.
trim
().
length
()>
0
)
{
for
(
String
address:
adminAddresses
.
trim
().
split
(
","
))
{
for
(
String
address:
adminAddresses
.
trim
().
split
(
","
))
{
if
(
address
!=
null
&&
address
.
trim
().
length
()>
0
)
{
if
(
address
!=
null
&&
address
.
trim
().
length
()>
0
)
{
String
addressUrl
=
address
.
concat
(
AdminBiz
.
MAPPING
);
AdminBiz
adminBiz
=
new
AdminBizClient
(
address
.
trim
(),
accessToken
);
AdminBiz
adminBiz
=
(
AdminBiz
)
new
XxlRpcReferenceBean
(
NetEnum
.
NETTY_HTTP
,
serializer
,
CallType
.
SYNC
,
LoadBalance
.
ROUND
,
AdminBiz
.
class
,
null
,
3000
,
addressUrl
,
accessToken
,
null
,
null
).
getObject
();
if
(
adminBizList
==
null
)
{
if
(
adminBizList
==
null
)
{
adminBizList
=
new
ArrayList
<
AdminBiz
>();
adminBizList
=
new
ArrayList
<
AdminBiz
>();
...
@@ -143,14 +125,6 @@ public class XxlJobExecutor {
...
@@ -143,14 +125,6 @@ public class XxlJobExecutor {
}
}
}
}
}
}
private
void
stopInvokerFactory
(){
// stop invoker factory
try
{
XxlRpcInvokerFactory
.
getInstance
().
stop
();
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
public
static
List
<
AdminBiz
>
getAdminBizList
(){
public
static
List
<
AdminBiz
>
getAdminBizList
(){
return
adminBizList
;
return
adminBizList
;
}
}
...
@@ -171,7 +145,16 @@ public class XxlJobExecutor {
...
@@ -171,7 +145,16 @@ public class XxlJobExecutor {
serviceRegistryParam
.
put
(
"address"
,
address
);
serviceRegistryParam
.
put
(
"address"
,
address
);
xxlRpcProviderFactory
=
new
XxlRpcProviderFactory
();
xxlRpcProviderFactory
=
new
XxlRpcProviderFactory
();
xxlRpcProviderFactory
.
initConfig
(
NetEnum
.
NETTY_HTTP
,
Serializer
.
SerializeEnum
.
HESSIAN
.
getSerializer
(),
ip
,
port
,
accessToken
,
ExecutorServiceRegistry
.
class
,
serviceRegistryParam
);
xxlRpcProviderFactory
.
setServer
(
NettyHttpServer
.
class
);
xxlRpcProviderFactory
.
setSerializer
(
HessianSerializer
.
class
);
xxlRpcProviderFactory
.
setCorePoolSize
(
30
);
xxlRpcProviderFactory
.
setMaxPoolSize
(
200
);
xxlRpcProviderFactory
.
setIp
(
ip
);
xxlRpcProviderFactory
.
setPort
(
port
);
xxlRpcProviderFactory
.
setAccessToken
(
accessToken
);
xxlRpcProviderFactory
.
setServiceRegistry
(
ExecutorServiceRegistry
.
class
);
xxlRpcProviderFactory
.
setServiceRegistryParam
(
serviceRegistryParam
);
// add services
// add services
xxlRpcProviderFactory
.
addService
(
ExecutorBiz
.
class
.
getName
(),
null
,
new
ExecutorBizImpl
());
xxlRpcProviderFactory
.
addService
(
ExecutorBiz
.
class
.
getName
(),
null
,
new
ExecutorBizImpl
());
...
...
xxl-job-core/src/main/java/com/xxl/job/core/util/XxlJobRemotingUtil.java
0 → 100644
浏览文件 @
2ced6010
package
com
.
xxl
.
job
.
core
.
util
;
import
com.xxl.job.core.biz.model.ReturnT
;
import
com.xxl.registry.client.util.json.BasicJson
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.BufferedReader
;
import
java.io.DataOutputStream
;
import
java.io.InputStreamReader
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.util.Map
;
/**
* @author xuxueli 2018-11-25 00:55:31
*/
public
class
XxlJobRemotingUtil
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
XxlJobRemotingUtil
.
class
);
public
static
String
XXL_RPC_ACCESS_TOKEN
=
"XXL_RPC_ACCESS_TOKEN"
;
/**
* post
*
* @param url
* @param accessToken
* @param requestObj
* @return
*/
public
static
ReturnT
<
String
>
postBody
(
String
url
,
String
accessToken
,
Object
requestObj
,
int
timeout
)
{
HttpURLConnection
connection
=
null
;
BufferedReader
bufferedReader
=
null
;
try
{
// connection
URL
realUrl
=
new
URL
(
url
);
connection
=
(
HttpURLConnection
)
realUrl
.
openConnection
();
// connection setting
connection
.
setRequestMethod
(
"POST"
);
connection
.
setDoOutput
(
true
);
connection
.
setDoInput
(
true
);
connection
.
setUseCaches
(
false
);
connection
.
setReadTimeout
(
timeout
*
1000
);
connection
.
setConnectTimeout
(
3
*
1000
);
connection
.
setRequestProperty
(
"connection"
,
"Keep-Alive"
);
connection
.
setRequestProperty
(
"Content-Type"
,
"application/json;charset=UTF-8"
);
connection
.
setRequestProperty
(
"Accept-Charset"
,
"application/json;charset=UTF-8"
);
if
(
accessToken
!=
null
&&
accessToken
.
trim
().
length
()>
0
){
connection
.
setRequestProperty
(
XXL_RPC_ACCESS_TOKEN
,
accessToken
);
}
// do connection
connection
.
connect
();
// write requestBody
String
requestBody
=
BasicJson
.
toJson
(
requestObj
);
DataOutputStream
dataOutputStream
=
new
DataOutputStream
(
connection
.
getOutputStream
());
dataOutputStream
.
writeBytes
(
requestBody
);
dataOutputStream
.
flush
();
dataOutputStream
.
close
();
/*byte[] requestBodyBytes = requestBody.getBytes("UTF-8");
connection.setRequestProperty("Content-Length", String.valueOf(requestBodyBytes.length));
OutputStream outwritestream = connection.getOutputStream();
outwritestream.write(requestBodyBytes);
outwritestream.flush();
outwritestream.close();*/
// valid StatusCode
int
statusCode
=
connection
.
getResponseCode
();
if
(
statusCode
!=
200
)
{
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
"xxl-rpc remoting fail, StatusCode("
+
statusCode
+
") invalid. for url : "
+
url
);
}
// result
bufferedReader
=
new
BufferedReader
(
new
InputStreamReader
(
connection
.
getInputStream
()));
StringBuilder
result
=
new
StringBuilder
();
String
line
;
while
((
line
=
bufferedReader
.
readLine
())
!=
null
)
{
result
.
append
(
line
);
}
String
resultJson
=
result
.
toString
();
// parse returnT
try
{
Map
<
String
,
Object
>
resultMap
=
BasicJson
.
parseMap
(
resultJson
);
ReturnT
<
String
>
returnT
=
new
ReturnT
<
String
>();
if
(
resultMap
==
null
)
{
returnT
.
setCode
(
ReturnT
.
FAIL_CODE
);
returnT
.
setMsg
(
"AdminBizClient Remoting call fail."
);
}
else
{
returnT
.
setCode
(
Integer
.
valueOf
(
String
.
valueOf
(
resultMap
.
get
(
"code"
))));
returnT
.
setMsg
(
String
.
valueOf
(
resultMap
.
get
(
"msg"
)));
returnT
.
setContent
(
String
.
valueOf
(
resultMap
.
get
(
"content"
)));
}
return
returnT
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
"xxl-rpc remoting response content invalid("
+
resultJson
+
"), for url : "
+
url
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
"xxl-rpc remoting error("
+
e
.
getMessage
()
+
"), for url : "
+
url
);
}
finally
{
try
{
if
(
bufferedReader
!=
null
)
{
bufferedReader
.
close
();
}
if
(
connection
!=
null
)
{
connection
.
disconnect
();
}
}
catch
(
Exception
e2
)
{
logger
.
error
(
e2
.
getMessage
(),
e2
);
}
}
}
}
xxl-job-core/src/test/java/com/xxl/job/core/biz/impl/ExecutorBizImplTest.java
浏览文件 @
2ced6010
...
@@ -10,8 +10,8 @@ import com.xxl.job.core.glue.GlueTypeEnum;
...
@@ -10,8 +10,8 @@ import com.xxl.job.core.glue.GlueTypeEnum;
import
com.xxl.rpc.remoting.invoker.call.CallType
;
import
com.xxl.rpc.remoting.invoker.call.CallType
;
import
com.xxl.rpc.remoting.invoker.reference.XxlRpcReferenceBean
;
import
com.xxl.rpc.remoting.invoker.reference.XxlRpcReferenceBean
;
import
com.xxl.rpc.remoting.invoker.route.LoadBalance
;
import
com.xxl.rpc.remoting.invoker.route.LoadBalance
;
import
com.xxl.rpc.remoting.net.
NetEnum
;
import
com.xxl.rpc.remoting.net.
impl.netty_http.client.NettyHttpClient
;
import
com.xxl.rpc.serialize.Serializer
;
import
com.xxl.rpc.serialize.
impl.Hessian
Serializer
;
import
org.junit.After
;
import
org.junit.After
;
import
org.junit.Assert
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Before
;
...
@@ -44,18 +44,20 @@ public class ExecutorBizImplTest {
...
@@ -44,18 +44,20 @@ public class ExecutorBizImplTest {
TimeUnit
.
SECONDS
.
sleep
(
3
);
TimeUnit
.
SECONDS
.
sleep
(
3
);
// init executor biz proxy
// init executor biz proxy
executorBiz
=
(
ExecutorBiz
)
new
XxlRpcReferenceBean
(
XxlRpcReferenceBean
referenceBean
=
new
XxlRpcReferenceBean
();
NetEnum
.
NETTY_HTTP
,
referenceBean
.
setClient
(
NettyHttpClient
.
class
);
Serializer
.
SerializeEnum
.
HESSIAN
.
getSerializer
(),
referenceBean
.
setSerializer
(
HessianSerializer
.
class
);
CallType
.
SYNC
,
referenceBean
.
setCallType
(
CallType
.
SYNC
);
LoadBalance
.
ROUND
,
referenceBean
.
setLoadBalance
(
LoadBalance
.
ROUND
);
ExecutorBiz
.
class
,
referenceBean
.
setIface
(
ExecutorBiz
.
class
);
null
,
referenceBean
.
setVersion
(
null
);
3000
,
referenceBean
.
setTimeout
(
3000
);
"127.0.0.1:9999"
,
referenceBean
.
setAddress
(
"127.0.0.1:9999"
);
null
,
referenceBean
.
setAccessToken
(
null
);
null
,
referenceBean
.
setInvokeCallback
(
null
);
null
).
getObject
();
referenceBean
.
setInvokerFactory
(
null
);
executorBiz
=
(
ExecutorBiz
)
referenceBean
.
getObject
();
}
}
@After
@After
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论