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
5c2bcb9f
authored
Jul 20, 2016
by
xueli.xue
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
任务回调队列 + 任务执行队列,poll改为take;修复一处可能导致cpu占满的问题
parent
2477a85d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
24 deletions
xxl-job-core/src/main/java/com/xxl/job/core/handler/HandlerRepository.java
xxl-job-core/src/main/java/com/xxl/job/core/handler/HandlerThread.java
xxl-job-core/src/main/java/com/xxl/job/core/handler/HandlerRepository.java
View file @
5c2bcb9f
...
...
@@ -192,7 +192,7 @@ public class HandlerRepository {
public
void
run
()
{
while
(
true
){
try
{
HashMap
<
String
,
String
>
item
=
callBackQueue
.
poll
();
HashMap
<
String
,
String
>
item
=
callBackQueue
.
take
();
if
(
item
!=
null
)
{
RemoteCallBack
callback
=
null
;
try
{
...
...
@@ -201,7 +201,7 @@ public class HandlerRepository {
logger
.
info
(
"HandlerThread Exception:"
,
e
);
}
logger
.
info
(
">>>>>>>>>>> xxl-job callback , params:{}, result:{}"
,
new
Object
[]{
item
,
callback
});
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
...
...
xxl-job-core/src/main/java/com/xxl/job/core/handler/HandlerThread.java
View file @
5c2bcb9f
package
com
.
xxl
.
job
.
core
.
handler
;
import
com.xxl.job.core.handler.HandlerRepository.HandlerParamEnum
;
import
com.xxl.job.core.handler.IJobHandler.JobHandleStatus
;
import
com.xxl.job.core.log.XxlJobFileAppender
;
import
com.xxl.job.core.util.HttpUtil
;
import
org.eclipse.jetty.util.ConcurrentHashSet
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.PrintWriter
;
import
java.io.StringWriter
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.TimeUnit
;
import
org.eclipse.jetty.util.ConcurrentHashSet
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.xxl.job.core.handler.HandlerRepository.HandlerParamEnum
;
import
com.xxl.job.core.handler.IJobHandler.JobHandleStatus
;
import
com.xxl.job.core.log.XxlJobFileAppender
;
import
com.xxl.job.core.util.HttpUtil
;
/**
* handler thread
...
...
@@ -57,7 +55,7 @@ public class HandlerThread extends Thread{
public
void
run
()
{
while
(!
toStop
){
try
{
Map
<
String
,
String
>
handlerData
=
handlerDataQueue
.
poll
();
Map
<
String
,
String
>
handlerData
=
handlerDataQueue
.
take
();
if
(
handlerData
!=
null
)
{
i
=
0
;
String
log_address
=
handlerData
.
get
(
HandlerParamEnum
.
LOG_ADDRESS
.
name
());
...
...
@@ -103,17 +101,6 @@ public class HandlerThread extends Thread{
params
.
put
(
"msg"
,
"人工手动终止[业务运行中,被强制终止]"
);
HandlerRepository
.
pushCallBack
(
HttpUtil
.
addressToUrl
(
log_address
),
params
);
}
}
else
{
i
++;
logIdSet
.
clear
();
try
{
TimeUnit
.
MILLISECONDS
.
sleep
(
i
*
100
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
if
(
i
>
5
)
{
i
=
0
;
}
}
}
catch
(
Exception
e
)
{
logger
.
info
(
"HandlerThread Exception:"
,
e
);
...
...
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