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
4a0fe49b
authored
Sep 26, 2019
by
许雪里
Committed by
GitHub
Sep 26, 2019
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge pull request #1105 from WEIZIBIN/fix_graceful_shutdown_unregister_fast
优雅停机时,admin快速注销执行器地址
parents
9969e304
3f8befe8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
4 deletions
xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobGroupDao.java
xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/AdminBizImpl.java
xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobGroupMapper.xml
xxl-job-core/src/main/java/com/xxl/job/core/executor/XxlJobExecutor.java
xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobGroupDao.java
View file @
4a0fe49b
...
@@ -16,6 +16,10 @@ public interface XxlJobGroupDao {
...
@@ -16,6 +16,10 @@ public interface XxlJobGroupDao {
public
List
<
XxlJobGroup
>
findByAddressType
(
@Param
(
"addressType"
)
int
addressType
);
public
List
<
XxlJobGroup
>
findByAddressType
(
@Param
(
"addressType"
)
int
addressType
);
public
List
<
XxlJobGroup
>
findAutoRegisterGroupByAppName
(
@Param
(
"appName"
)
String
appName
);
public
int
updateAddressListById
(
@Param
(
"id"
)
int
id
,
@Param
(
"addressList"
)
String
addressList
);
public
int
save
(
XxlJobGroup
xxlJobGroup
);
public
int
save
(
XxlJobGroup
xxlJobGroup
);
public
int
update
(
XxlJobGroup
xxlJobGroup
);
public
int
update
(
XxlJobGroup
xxlJobGroup
);
...
...
xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/AdminBizImpl.java
View file @
4a0fe49b
package
com
.
xxl
.
job
.
admin
.
service
.
impl
;
package
com
.
xxl
.
job
.
admin
.
service
.
impl
;
import
com.xxl.job.admin.core.model.XxlJobGroup
;
import
com.xxl.job.admin.core.model.XxlJobInfo
;
import
com.xxl.job.admin.core.model.XxlJobInfo
;
import
com.xxl.job.admin.core.model.XxlJobLog
;
import
com.xxl.job.admin.core.model.XxlJobLog
;
import
com.xxl.job.admin.core.thread.JobTriggerPoolHelper
;
import
com.xxl.job.admin.core.thread.JobTriggerPoolHelper
;
import
com.xxl.job.admin.core.trigger.TriggerTypeEnum
;
import
com.xxl.job.admin.core.trigger.TriggerTypeEnum
;
import
com.xxl.job.admin.core.util.I18nUtil
;
import
com.xxl.job.admin.core.util.I18nUtil
;
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
;
...
@@ -16,6 +18,8 @@ import com.xxl.job.core.handler.IJobHandler;
...
@@ -16,6 +18,8 @@ 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.CollectionUtils
;
import
org.springframework.util.StringUtils
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.text.MessageFormat
;
import
java.text.MessageFormat
;
...
@@ -35,6 +39,8 @@ public class AdminBizImpl implements AdminBiz {
...
@@ -35,6 +39,8 @@ public class AdminBizImpl implements AdminBiz {
private
XxlJobInfoDao
xxlJobInfoDao
;
private
XxlJobInfoDao
xxlJobInfoDao
;
@Resource
@Resource
private
XxlJobRegistryDao
xxlJobRegistryDao
;
private
XxlJobRegistryDao
xxlJobRegistryDao
;
@Resource
private
XxlJobGroupDao
xxlJobGroupDao
;
@Override
@Override
...
@@ -132,8 +138,40 @@ public class AdminBizImpl implements AdminBiz {
...
@@ -132,8 +138,40 @@ public class AdminBizImpl implements AdminBiz {
@Override
@Override
public
ReturnT
<
String
>
registryRemove
(
RegistryParam
registryParam
)
{
public
ReturnT
<
String
>
registryRemove
(
RegistryParam
registryParam
)
{
xxlJobRegistryDao
.
registryDelete
(
registryParam
.
getRegistGroup
(),
registryParam
.
getRegistryKey
(),
registryParam
.
getRegistryValue
());
int
ret
=
xxlJobRegistryDao
.
registryDelete
(
registryParam
.
getRegistGroup
(),
registryParam
.
getRegistryKey
(),
registryParam
.
getRegistryValue
());
if
(
ret
==
1
)
{
List
<
XxlJobGroup
>
autoRegisterGroups
=
xxlJobGroupDao
.
findAutoRegisterGroupByAppName
(
registryParam
.
getRegistryKey
());
removeRegisterFromGroups
(
autoRegisterGroups
,
registryParam
.
getRegistryValue
());
}
return
ReturnT
.
SUCCESS
;
return
ReturnT
.
SUCCESS
;
}
}
private
void
removeRegisterFromGroups
(
List
<
XxlJobGroup
>
groups
,
String
address
)
{
if
(
StringUtils
.
isEmpty
(
address
))
{
return
;
}
if
(
CollectionUtils
.
isEmpty
(
groups
))
{
return
;
}
for
(
XxlJobGroup
group
:
groups
)
{
List
<
String
>
addressList
=
group
.
getRegistryList
();
if
(
addressList
==
null
)
{
continue
;
}
if
(!
addressList
.
contains
(
address
))
{
continue
;
}
addressList
.
remove
(
address
);
String
newAddressListStr
=
StringUtils
.
collectionToCommaDelimitedString
(
addressList
);
String
oldAddressListStr
=
group
.
getAddressList
();
int
update
=
xxlJobGroupDao
.
updateAddressListById
(
group
.
getId
(),
newAddressListStr
);
if
(
logger
.
isDebugEnabled
())
{
logger
.
debug
(
"update group name [{}] title [{}] old address list [{}] new address list [{}] update result [{}]"
,
group
.
getAppName
(),
group
.
getTitle
(),
oldAddressListStr
,
newAddressListStr
,
update
);
}
}
}
}
}
xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobGroupMapper.xml
View file @
4a0fe49b
...
@@ -27,6 +27,13 @@
...
@@ -27,6 +27,13 @@
ORDER BY t.order ASC
ORDER BY t.order ASC
</select>
</select>
<select
id=
"findAutoRegisterGroupByAppName"
resultMap=
"XxlJobGroup"
>
SELECT
<include
refid=
"Base_Column_List"
/>
FROM xxl_job_group AS t
WHERE `app_name` = #{appName}
AND `address_type` = 0
</select>
<select
id=
"findByAddressType"
parameterType=
"java.lang.Integer"
resultMap=
"XxlJobGroup"
>
<select
id=
"findByAddressType"
parameterType=
"java.lang.Integer"
resultMap=
"XxlJobGroup"
>
SELECT
<include
refid=
"Base_Column_List"
/>
SELECT
<include
refid=
"Base_Column_List"
/>
FROM xxl_job_group AS t
FROM xxl_job_group AS t
...
@@ -49,6 +56,12 @@
...
@@ -49,6 +56,12 @@
WHERE id = #{id}
WHERE id = #{id}
</update>
</update>
<update
id=
"updateAddressListById"
>
UPDATE xxl_job_group
SET `address_list` = #{addressList}
WHERE id = #{id}
</update>
<delete
id=
"remove"
parameterType=
"java.lang.Integer"
>
<delete
id=
"remove"
parameterType=
"java.lang.Integer"
>
DELETE FROM xxl_job_group
DELETE FROM xxl_job_group
WHERE id = #{id}
WHERE id = #{id}
...
...
xxl-job-core/src/main/java/com/xxl/job/core/executor/XxlJobExecutor.java
View file @
4a0fe49b
...
@@ -86,6 +86,9 @@ public class XxlJobExecutor {
...
@@ -86,6 +86,9 @@ public class XxlJobExecutor {
initRpcProvider
(
ip
,
port
,
appName
,
accessToken
);
initRpcProvider
(
ip
,
port
,
appName
,
accessToken
);
}
}
public
void
destroy
(){
public
void
destroy
(){
// destory executor-server
stopRpcProvider
();
// destory jobThreadRepository
// destory jobThreadRepository
if
(
jobThreadRepository
.
size
()
>
0
)
{
if
(
jobThreadRepository
.
size
()
>
0
)
{
for
(
Map
.
Entry
<
Integer
,
JobThread
>
item:
jobThreadRepository
.
entrySet
())
{
for
(
Map
.
Entry
<
Integer
,
JobThread
>
item:
jobThreadRepository
.
entrySet
())
{
...
@@ -102,9 +105,6 @@ public class XxlJobExecutor {
...
@@ -102,9 +105,6 @@ public class XxlJobExecutor {
// destory TriggerCallbackThread
// destory TriggerCallbackThread
TriggerCallbackThread
.
getInstance
().
toStop
();
TriggerCallbackThread
.
getInstance
().
toStop
();
// destory executor-server
stopRpcProvider
();
// destory invoker
// destory invoker
stopInvokerFactory
();
stopInvokerFactory
();
}
}
...
...
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