com.xxl.job.core.thread.JobThread Java Examples

The following examples show how to use com.xxl.job.core.thread.JobThread. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XxlJobExecutor.java    From zuihou-admin-cloud with Apache License 2.0 6 votes vote down vote up
public void destroy() {
    // destory jobThreadRepository
    if (jobThreadRepository.size() > 0) {
        for (Map.Entry<Integer, JobThread> item : jobThreadRepository.entrySet()) {
            removeJobThread(item.getKey(), "web container destroy and kill the job.");
        }
        jobThreadRepository.clear();
    }


    // destory JobLogFileCleanThread
    JobLogFileCleanThread.getInstance().toStop();

    // destory TriggerCallbackThread
    TriggerCallbackThread.getInstance().toStop();

    // destory executor-server
    stopRpcProvider();
}
 
Example #2
Source File: XxlJobExecutor.java    From microservices-platform with Apache License 2.0 6 votes vote down vote up
public void destroy(){
    // destory jobThreadRepository
    if (jobThreadRepository.size() > 0) {
        for (Map.Entry<Integer, JobThread> item: jobThreadRepository.entrySet()) {
            removeJobThread(item.getKey(), "web container destroy and kill the job.");
        }
        jobThreadRepository.clear();
    }


    // destory JobLogFileCleanThread
    JobLogFileCleanThread.getInstance().toStop();

    // destory TriggerCallbackThread
    TriggerCallbackThread.getInstance().toStop();

    // destory executor-server
    stopRpcProvider();
}
 
Example #3
Source File: XxlJobExecutor.java    From zuihou-admin-boot with Apache License 2.0 6 votes vote down vote up
public void destroy() {
    // destory jobThreadRepository
    if (jobThreadRepository.size() > 0) {
        for (Map.Entry<Integer, JobThread> item : jobThreadRepository.entrySet()) {
            removeJobThread(item.getKey(), "web container destroy and kill the job.");
        }
        jobThreadRepository.clear();
    }


    // destory JobLogFileCleanThread
    JobLogFileCleanThread.getInstance().toStop();

    // destory TriggerCallbackThread
    TriggerCallbackThread.getInstance().toStop();

    // destory executor-server
    stopRpcProvider();
}
 
Example #4
Source File: ExecutorBizImpl.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
@Override
public ReturnT<String> kill(int jobId) {
    // kill handlerThread, and create new one
    JobThread jobThread = XxlJobExecutor.loadJobThread(jobId);
    if (jobThread != null) {
        XxlJobExecutor.removeJobThread(jobId, "人工手动终止");
        return ReturnT.SUCCESS;
    }

    return new ReturnT<String>(ReturnT.SUCCESS_CODE, "job thread aleady killed.");
}
 
Example #5
Source File: XxlJobExecutor.java    From xxl-job with GNU General Public License v3.0 5 votes vote down vote up
public static JobThread removeJobThread(int jobId, String removeOldReason){
    JobThread oldJobThread = jobThreadRepository.remove(jobId);
    if (oldJobThread != null) {
        oldJobThread.toStop(removeOldReason);
        oldJobThread.interrupt();

        return oldJobThread;
    }
    return null;
}
 
Example #6
Source File: XxlJobExecutor.java    From xxl-job with GNU General Public License v3.0 5 votes vote down vote up
public static JobThread registJobThread(int jobId, IJobHandler handler, String removeOldReason){
    JobThread newJobThread = new JobThread(jobId, handler);
    newJobThread.start();
    logger.info(">>>>>>>>>>> xxl-job regist JobThread success, jobId:{}, handler:{}", new Object[]{jobId, handler});

    JobThread oldJobThread = jobThreadRepository.put(jobId, newJobThread);	// putIfAbsent | oh my god, map's put method return the old value!!!
    if (oldJobThread != null) {
        oldJobThread.toStop(removeOldReason);
        oldJobThread.interrupt();
    }

    return newJobThread;
}
 
Example #7
Source File: XxlJobExecutor.java    From xxl-job with GNU General Public License v3.0 5 votes vote down vote up
public void destroy(){
    // destory executor-server
    stopEmbedServer();

    // destory jobThreadRepository
    if (jobThreadRepository.size() > 0) {
        for (Map.Entry<Integer, JobThread> item: jobThreadRepository.entrySet()) {
            JobThread oldJobThread = removeJobThread(item.getKey(), "web container destroy and kill the job.");
            // wait for job thread push result to callback queue
            if (oldJobThread != null) {
                try {
                    oldJobThread.join();
                } catch (InterruptedException e) {
                    logger.error(">>>>>>>>>>> xxl-job, JobThread destroy(join) error, jobId:{}", item.getKey(), e);
                }
            }
        }
        jobThreadRepository.clear();
    }
    jobHandlerRepository.clear();


    // destory JobLogFileCleanThread
    JobLogFileCleanThread.getInstance().toStop();

    // destory TriggerCallbackThread
    TriggerCallbackThread.getInstance().toStop();

}
 
Example #8
Source File: ExecutorBizImpl.java    From xxl-job with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ReturnT<String> kill(KillParam killParam) {
    // kill handlerThread, and create new one
    JobThread jobThread = XxlJobExecutor.loadJobThread(killParam.getJobId());
    if (jobThread != null) {
        XxlJobExecutor.removeJobThread(killParam.getJobId(), "scheduling center kill job.");
        return ReturnT.SUCCESS;
    }

    return new ReturnT<String>(ReturnT.SUCCESS_CODE, "job thread already killed.");
}
 
Example #9
Source File: ExecutorBizImpl.java    From xxl-job with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ReturnT<String> idleBeat(IdleBeatParam idleBeatParam) {

    // isRunningOrHasQueue
    boolean isRunningOrHasQueue = false;
    JobThread jobThread = XxlJobExecutor.loadJobThread(idleBeatParam.getJobId());
    if (jobThread != null && jobThread.isRunningOrHasQueue()) {
        isRunningOrHasQueue = true;
    }

    if (isRunningOrHasQueue) {
        return new ReturnT<String>(ReturnT.FAIL_CODE, "job thread is running or has trigger queue.");
    }
    return ReturnT.SUCCESS;
}
 
Example #10
Source File: XxlJobExecutor.java    From zuihou-admin-cloud with Apache License 2.0 5 votes vote down vote up
public static void removeJobThread(int jobId, String removeOldReason) {
    JobThread oldJobThread = jobThreadRepository.remove(jobId);
    if (oldJobThread != null) {
        oldJobThread.toStop(removeOldReason);
        oldJobThread.interrupt();
    }
}
 
Example #11
Source File: XxlJobExecutor.java    From zuihou-admin-cloud with Apache License 2.0 5 votes vote down vote up
public static JobThread registJobThread(int jobId, IJobHandler handler, String removeOldReason) {
    JobThread newJobThread = new JobThread(jobId, handler);
    newJobThread.start();
    logger.info(">>>>>>>>>>> xxl-job regist JobThread success, jobId:{}, handler:{}", new Object[]{jobId, handler});

    JobThread oldJobThread = jobThreadRepository.put(jobId, newJobThread);    // putIfAbsent | oh my god, map's put method return the old value!!!
    if (oldJobThread != null) {
        oldJobThread.toStop(removeOldReason);
        oldJobThread.interrupt();
    }

    return newJobThread;
}
 
Example #12
Source File: ExecutorBizImpl.java    From zuihou-admin-cloud with Apache License 2.0 5 votes vote down vote up
@Override
public ReturnT<String> kill(int jobId) {
    // kill handlerThread, and create new one
    JobThread jobThread = XxlJobExecutor.loadJobThread(jobId);
    if (jobThread != null) {
        XxlJobExecutor.removeJobThread(jobId, "scheduling center kill job.");
        return ReturnT.SUCCESS;
    }

    return new ReturnT<String>(ReturnT.SUCCESS_CODE, "job thread aleady killed.");
}
 
Example #13
Source File: ExecutorBizImpl.java    From zuihou-admin-cloud with Apache License 2.0 5 votes vote down vote up
@Override
public ReturnT<String> idleBeat(int jobId) {

    // isRunningOrHasQueue
    boolean isRunningOrHasQueue = false;
    JobThread jobThread = XxlJobExecutor.loadJobThread(jobId);
    if (jobThread != null && jobThread.isRunningOrHasQueue()) {
        isRunningOrHasQueue = true;
    }

    if (isRunningOrHasQueue) {
        return new ReturnT<String>(ReturnT.FAIL_CODE, "job thread is running or has trigger queue.");
    }
    return ReturnT.SUCCESS;
}
 
Example #14
Source File: XxlJobExecutor.java    From zuihou-admin-boot with Apache License 2.0 5 votes vote down vote up
public static void removeJobThread(int jobId, String removeOldReason) {
    JobThread oldJobThread = jobThreadRepository.remove(jobId);
    if (oldJobThread != null) {
        oldJobThread.toStop(removeOldReason);
        oldJobThread.interrupt();
    }
}
 
Example #15
Source File: XxlJobExecutor.java    From zuihou-admin-boot with Apache License 2.0 5 votes vote down vote up
public static JobThread registJobThread(int jobId, IJobHandler handler, String removeOldReason) {
    JobThread newJobThread = new JobThread(jobId, handler);
    newJobThread.start();
    logger.info(">>>>>>>>>>> xxl-job regist JobThread success, jobId:{}, handler:{}", new Object[]{jobId, handler});

    JobThread oldJobThread = jobThreadRepository.put(jobId, newJobThread);    // putIfAbsent | oh my god, map's put method return the old value!!!
    if (oldJobThread != null) {
        oldJobThread.toStop(removeOldReason);
        oldJobThread.interrupt();
    }

    return newJobThread;
}
 
Example #16
Source File: ExecutorBizImpl.java    From zuihou-admin-boot with Apache License 2.0 5 votes vote down vote up
@Override
public ReturnT<String> kill(int jobId) {
    // kill handlerThread, and create new one
    JobThread jobThread = XxlJobExecutor.loadJobThread(jobId);
    if (jobThread != null) {
        XxlJobExecutor.removeJobThread(jobId, "scheduling center kill job.");
        return ReturnT.SUCCESS;
    }

    return new ReturnT<String>(ReturnT.SUCCESS_CODE, "job thread aleady killed.");
}
 
Example #17
Source File: ExecutorBizImpl.java    From zuihou-admin-boot with Apache License 2.0 5 votes vote down vote up
@Override
public ReturnT<String> idleBeat(int jobId) {

    // isRunningOrHasQueue
    boolean isRunningOrHasQueue = false;
    JobThread jobThread = XxlJobExecutor.loadJobThread(jobId);
    if (jobThread != null && jobThread.isRunningOrHasQueue()) {
        isRunningOrHasQueue = true;
    }

    if (isRunningOrHasQueue) {
        return new ReturnT<String>(ReturnT.FAIL_CODE, "job thread is running or has trigger queue.");
    }
    return ReturnT.SUCCESS;
}
 
Example #18
Source File: XxlJobExecutor.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
public static void removeJobThread(int jobId, String removeOldReason){
    JobThread oldJobThread = jobThreadRepository.remove(jobId);
    if (oldJobThread != null) {
        oldJobThread.toStop(removeOldReason);
        oldJobThread.interrupt();
    }
}
 
Example #19
Source File: XxlJobExecutor.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
public static JobThread registJobThread(int jobId, IJobHandler handler, String removeOldReason){
    JobThread newJobThread = new JobThread(jobId, handler);
    newJobThread.start();
    logger.info(">>>>>>>>>>> xxl-job regist JobThread success, jobId:{}, handler:{}", new Object[]{jobId, handler});

    JobThread oldJobThread = jobThreadRepository.put(jobId, newJobThread);	// putIfAbsent | oh my god, map's put method return the old value!!!
    if (oldJobThread != null) {
        oldJobThread.toStop(removeOldReason);
        oldJobThread.interrupt();
    }

    return newJobThread;
}
 
Example #20
Source File: ExecutorBizImpl.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
@Override
public ReturnT<String> kill(int jobId) {
    // kill handlerThread, and create new one
    JobThread jobThread = XxlJobExecutor.loadJobThread(jobId);
    if (jobThread != null) {
        XxlJobExecutor.removeJobThread(jobId, "scheduling center kill job.");
        return ReturnT.SUCCESS;
    }

    return new ReturnT<String>(ReturnT.SUCCESS_CODE, "job thread aleady killed.");
}
 
Example #21
Source File: ExecutorBizImpl.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
@Override
public ReturnT<String> idleBeat(int jobId) {

    // isRunningOrHasQueue
    boolean isRunningOrHasQueue = false;
    JobThread jobThread = XxlJobExecutor.loadJobThread(jobId);
    if (jobThread != null && jobThread.isRunningOrHasQueue()) {
        isRunningOrHasQueue = true;
    }

    if (isRunningOrHasQueue) {
        return new ReturnT<String>(ReturnT.FAIL_CODE, "job thread is running or has trigger queue.");
    }
    return ReturnT.SUCCESS;
}
 
Example #22
Source File: XxlJobExecutor.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
public static void removeJobThread(int jobId, String removeOldReason){
    JobThread oldJobThread = JobThreadRepository.remove(jobId);
    if (oldJobThread != null) {
        oldJobThread.toStop(removeOldReason);
        oldJobThread.interrupt();
    }
}
 
Example #23
Source File: XxlJobExecutor.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
public static JobThread registJobThread(int jobId, IJobHandler handler, String removeOldReason){
    JobThread newJobThread = new JobThread(jobId, handler);
    newJobThread.start();
    logger.info(">>>>>>>>>>> xxl-job regist JobThread success, jobId:{}, handler:{}", new Object[]{jobId, handler});

    JobThread oldJobThread = JobThreadRepository.put(jobId, newJobThread);	// putIfAbsent | oh my god, map's put method return the old value!!!
    if (oldJobThread != null) {
        oldJobThread.toStop(removeOldReason);
        oldJobThread.interrupt();
    }

    return newJobThread;
}
 
Example #24
Source File: XxlJobExecutor.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
public void destroy(){
    // destory JobThreadRepository
    if (JobThreadRepository.size() > 0) {
        for (Map.Entry<Integer, JobThread> item: JobThreadRepository.entrySet()) {
            removeJobThread(item.getKey(), "Web容器销毁终止");
        }
        JobThreadRepository.clear();
    }

    // destory executor-server
    stopExecutorServer();

    // destory JobLogFileCleanThread
    JobLogFileCleanThread.getInstance().toStop();
}
 
Example #25
Source File: ExecutorBizImpl.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
@Override
public ReturnT<String> idleBeat(int jobId) {

    // isRunningOrHasQueue
    boolean isRunningOrHasQueue = false;
    JobThread jobThread = XxlJobExecutor.loadJobThread(jobId);
    if (jobThread != null && jobThread.isRunningOrHasQueue()) {
        isRunningOrHasQueue = true;
    }

    if (isRunningOrHasQueue) {
        return new ReturnT<String>(ReturnT.FAIL_CODE, "job thread is running or has trigger queue.");
    }
    return ReturnT.SUCCESS;
}
 
Example #26
Source File: XxlJobExecutor.java    From zuihou-admin-boot with Apache License 2.0 4 votes vote down vote up
public static JobThread loadJobThread(int jobId) {
    JobThread jobThread = jobThreadRepository.get(jobId);
    return jobThread;
}
 
Example #27
Source File: XxlJobExecutor.java    From microservices-platform with Apache License 2.0 4 votes vote down vote up
public static JobThread loadJobThread(int jobId){
    JobThread jobThread = jobThreadRepository.get(jobId);
    return jobThread;
}
 
Example #28
Source File: XxlJobExecutor.java    From zuihou-admin-cloud with Apache License 2.0 4 votes vote down vote up
public static JobThread loadJobThread(int jobId) {
    JobThread jobThread = jobThreadRepository.get(jobId);
    return jobThread;
}
 
Example #29
Source File: XxlJobExecutor.java    From open-capacity-platform with Apache License 2.0 4 votes vote down vote up
public static JobThread loadJobThread(int jobId){
    JobThread jobThread = JobThreadRepository.get(jobId);
    return jobThread;
}
 
Example #30
Source File: XxlJobExecutor.java    From xxl-job with GNU General Public License v3.0 4 votes vote down vote up
public static JobThread loadJobThread(int jobId){
    JobThread jobThread = jobThreadRepository.get(jobId);
    return jobThread;
}