From 5c2bcb9ffd16c565a3be3596c3501240ba216b95 Mon Sep 17 00:00:00 2001 From: "xueli.xue" Date: Wed, 20 Jul 2016 10:39:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=9B=9E=E8=B0=83=E9=98=9F?= =?UTF-8?q?=E5=88=97=20+=20=E4=BB=BB=E5=8A=A1=E6=89=A7=E8=A1=8C=E9=98=9F?= =?UTF-8?q?=E5=88=97,poll=E6=94=B9=E4=B8=BAtake;=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E4=B8=80=E5=A4=84=E5=8F=AF=E8=83=BD=E5=AF=BC=E8=87=B4cpu?= =?UTF-8?q?=E5=8D=A0=E6=BB=A1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../job/core/handler/HandlerRepository.java | 4 +-- .../xxl/job/core/handler/HandlerThread.java | 31 ++++++------------- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/xxl-job-core/src/main/java/com/xxl/job/core/handler/HandlerRepository.java b/xxl-job-core/src/main/java/com/xxl/job/core/handler/HandlerRepository.java index 2c514d9c..5a805fd9 100644 --- a/xxl-job-core/src/main/java/com/xxl/job/core/handler/HandlerRepository.java +++ b/xxl-job-core/src/main/java/com/xxl/job/core/handler/HandlerRepository.java @@ -192,7 +192,7 @@ public class HandlerRepository { public void run() { while(true){ try { - HashMap item = callBackQueue.poll(); + HashMap 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(); } diff --git a/xxl-job-core/src/main/java/com/xxl/job/core/handler/HandlerThread.java b/xxl-job-core/src/main/java/com/xxl/job/core/handler/HandlerThread.java index 8896a5a9..13003cc0 100644 --- a/xxl-job-core/src/main/java/com/xxl/job/core/handler/HandlerThread.java +++ b/xxl-job-core/src/main/java/com/xxl/job/core/handler/HandlerThread.java @@ -1,20 +1,18 @@ 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 handlerData = handlerDataQueue.poll(); + Map 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);