Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
熊鹏飞
/
xxljob220
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
02818b4d
authored
Jul 28, 2017
by
xuxueli
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
心跳注册和结果回调,重试逻辑优化
parent
f83346de
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
50 additions
and
10 deletions
doc/XXL-JOB官方文档.md
xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobApiController.java
xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobLogController.java
xxl-job-admin/src/main/java/com/xxl/job/admin/core/route/ExecutorRouter.java
xxl-job-admin/src/test/java/com/xxl/job/dao/impl/AdminBizTest.java
xxl-job-core/src/main/java/com/xxl/job/core/biz/AdminBiz.java
xxl-job-core/src/main/java/com/xxl/job/core/executor/XxlJobExecutor.java
xxl-job-executor-example/src/test/java/com/xxl/executor/test/DemoJobHandlerTest.java
doc/XXL-JOB官方文档.md
View file @
02818b4d
# 《分布
式任务调度平台XXL-JOB》
# 《分布
式任务调度平台XXL-JOB》
...
...
@@ -903,6 +903,7 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
-
4、执行器集群地址列表进行自然排序;
-
5、调度中心,DAO层代码精简优化并且新增测试用例覆盖;
-
6、调度中心API服务改为自研RPC形式,统一底层通讯模型;
-
7、新增调度中心API服务测试Demo,方便在调度中心API扩展和测试;
#### TODO LIST
-
1、任务权限管理:执行器为粒度分配权限,核心操作校验权限;
...
...
xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobApiController.java
View file @
02818b4d
package
com
.
xxl
.
job
.
admin
.
controller
;
import
com.xxl.job.admin.controller.annotation.PermessionLimit
;
import
com.xxl.job.core.biz.AdminBiz
;
import
com.xxl.job.core.rpc.codec.RpcRequest
;
import
com.xxl.job.core.rpc.codec.RpcResponse
;
import
com.xxl.job.core.rpc.netcom.NetComServerFactory
;
...
...
@@ -46,7 +47,7 @@ public class JobApiController {
}
}
@RequestMapping
(
"/api"
)
@RequestMapping
(
AdminBiz
.
MAPPING
)
@PermessionLimit
(
limit
=
false
)
public
void
api
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
...
...
xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobLogController.java
View file @
02818b4d
...
...
@@ -12,6 +12,8 @@ import com.xxl.job.core.biz.model.ReturnT;
import
com.xxl.job.core.rpc.netcom.NetComClientProxy
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.time.DateUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -32,6 +34,7 @@ import java.util.Map;
@Controller
@RequestMapping
(
"/joblog"
)
public
class
JobLogController
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
JobLogController
.
class
);
@Resource
private
XxlJobGroupDao
xxlJobGroupDao
;
...
...
@@ -129,7 +132,7 @@ public class JobLogController {
return
logResult
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
(
);
logger
.
error
(
e
.
getMessage
(),
e
);
return
new
ReturnT
<
LogResult
>(
ReturnT
.
FAIL_CODE
,
e
.
getMessage
());
}
}
...
...
@@ -148,14 +151,14 @@ public class JobLogController {
}
// request of kill
ExecutorBiz
executorBiz
=
null
;
ReturnT
<
String
>
runResult
=
null
;
try
{
executorBiz
=
(
ExecutorBiz
)
new
NetComClientProxy
(
ExecutorBiz
.
class
,
log
.
getExecutorAddress
()).
getObject
();
ExecutorBiz
executorBiz
=
(
ExecutorBiz
)
new
NetComClientProxy
(
ExecutorBiz
.
class
,
log
.
getExecutorAddress
()).
getObject
();
runResult
=
executorBiz
.
kill
(
jobInfo
.
getId
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
(
);
r
eturn
new
ReturnT
<
String
>(
500
,
e
.
getMessage
());
logger
.
error
(
e
.
getMessage
(),
e
);
r
unResult
=
new
ReturnT
<
String
>(
500
,
e
.
getMessage
());
}
ReturnT
<
String
>
runResult
=
executorBiz
.
kill
(
jobInfo
.
getId
());
if
(
ReturnT
.
SUCCESS_CODE
==
runResult
.
getCode
())
{
log
.
setHandleCode
(
ReturnT
.
FAIL_CODE
);
...
...
xxl-job-admin/src/main/java/com/xxl/job/admin/core/route/ExecutorRouter.java
View file @
02818b4d
...
...
@@ -36,7 +36,7 @@ public abstract class ExecutorRouter {
ExecutorBiz
executorBiz
=
(
ExecutorBiz
)
new
NetComClientProxy
(
ExecutorBiz
.
class
,
address
).
getObject
();
runResult
=
executorBiz
.
run
(
triggerParam
);
}
catch
(
Exception
e
)
{
logger
.
error
(
""
,
e
);
logger
.
error
(
e
.
getMessage
()
,
e
);
runResult
=
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
""
+
e
);
}
...
...
xxl-job-admin/src/test/java/com/xxl/job/dao/impl/AdminBizTest.java
0 → 100644
View file @
02818b4d
package
com
.
xxl
.
job
.
dao
.
impl
;
import
com.xxl.job.core.biz.AdminBiz
;
import
com.xxl.job.core.biz.model.RegistryParam
;
import
com.xxl.job.core.biz.model.ReturnT
;
import
com.xxl.job.core.enums.RegistryConfig
;
import
com.xxl.job.core.rpc.netcom.NetComClientProxy
;
import
org.junit.Assert
;
import
org.junit.Test
;
/**
* admin-api client, test
* @author xuxueli 2017-07-28 22:14:52
*/
public
class
AdminBizTest
{
@Test
public
void
registryTest
()
throws
Exception
{
// admin-client
String
addressUrl
=
"http://127.0.0.1:8080/xxl-job-admin"
.
concat
(
AdminBiz
.
MAPPING
);
AdminBiz
adminBiz
=
(
AdminBiz
)
new
NetComClientProxy
(
AdminBiz
.
class
,
addressUrl
).
getObject
();
// test executor registry
RegistryParam
registryParam
=
new
RegistryParam
(
RegistryConfig
.
RegistType
.
EXECUTOR
.
name
(),
"xxl-job-executor-example"
,
"127.0.0.1:9999"
);
ReturnT
<
String
>
returnT
=
adminBiz
.
registry
(
registryParam
);
Assert
.
assertTrue
(
returnT
.
getCode
()
==
ReturnT
.
SUCCESS_CODE
);
}
}
xxl-job-core/src/main/java/com/xxl/job/core/biz/AdminBiz.java
View file @
02818b4d
...
...
@@ -11,6 +11,8 @@ import java.util.List;
*/
public
interface
AdminBiz
{
public
static
final
String
MAPPING
=
"/api"
;
/**
* callback
*
...
...
xxl-job-core/src/main/java/com/xxl/job/core/executor/XxlJobExecutor.java
View file @
02818b4d
...
...
@@ -58,7 +58,7 @@ public class XxlJobExecutor implements ApplicationContextAware, ApplicationListe
if
(
adminAddresses
!=
null
&&
adminAddresses
.
trim
().
length
()>
0
)
{
for
(
String
address:
adminAddresses
.
trim
().
split
(
","
))
{
if
(
address
!=
null
&&
address
.
trim
().
length
()>
0
)
{
String
addressUrl
=
address
.
concat
(
"/api"
);
String
addressUrl
=
address
.
concat
(
AdminBiz
.
MAPPING
);
AdminBiz
adminBiz
=
(
AdminBiz
)
new
NetComClientProxy
(
AdminBiz
.
class
,
addressUrl
).
getObject
();
if
(
adminBizList
==
null
)
{
adminBizList
=
new
ArrayList
<
AdminBiz
>();
...
...
xxl-job-executor-example/src/test/java/com/xxl/executor/test/DemoJobHandlerTest.java
View file @
02818b4d
...
...
@@ -8,6 +8,8 @@ import com.xxl.job.core.glue.GlueTypeEnum;
import
com.xxl.job.core.rpc.netcom.NetComClientProxy
;
/**
* executor-api client, test
*
* Created by xuxueli on 17/5/12.
*/
public
class
DemoJobHandlerTest
{
...
...
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