From 50b1c679434e9ebd1c18e75c64aec3d38ac6f7b1 Mon Sep 17 00:00:00 2001 From: xuxueli <931591021@qq.com> Date: Sat, 18 Aug 2018 22:42:47 +0800 Subject: [PATCH] RM --- .../admin/core/jobbean/RemoteHttpJobBean.java | 64 +- .../xxl/job/admin/core/model/XxlJobLog.java | 310 ++++---- .../mybatis-mapper/XxlJobLogMapper.xml | 432 +++++------ .../main/webapp/static/js/joblog.index.1.js | 734 +++++++++--------- .../com/xxl/job/core/handler/IJobHandler.java | 94 +-- 5 files changed, 817 insertions(+), 817 deletions(-) diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/jobbean/RemoteHttpJobBean.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/jobbean/RemoteHttpJobBean.java index 3fbd0839..f565819a 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/jobbean/RemoteHttpJobBean.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/jobbean/RemoteHttpJobBean.java @@ -1,33 +1,33 @@ -package com.xxl.job.admin.core.jobbean; - -import com.xxl.job.admin.core.thread.JobTriggerPoolHelper; -import org.quartz.JobExecutionContext; -import org.quartz.JobExecutionException; -import org.quartz.JobKey; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.scheduling.quartz.QuartzJobBean; - -/** - * http job bean - * “@DisallowConcurrentExecution” diable concurrent, thread size can not be only one, better given more - * @author xuxueli 2015-12-17 18:20:34 - */ -//@DisallowConcurrentExecution -public class RemoteHttpJobBean extends QuartzJobBean { - private static Logger logger = LoggerFactory.getLogger(RemoteHttpJobBean.class); - - @Override - protected void executeInternal(JobExecutionContext context) - throws JobExecutionException { - - // load jobId - JobKey jobKey = context.getTrigger().getJobKey(); - Integer jobId = Integer.valueOf(jobKey.getName()); - - // trigger - //XxlJobTrigger.trigger(jobId); - JobTriggerPoolHelper.trigger(jobId, -1); - } - +package com.xxl.job.admin.core.jobbean; + +import com.xxl.job.admin.core.thread.JobTriggerPoolHelper; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; +import org.quartz.JobKey; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.scheduling.quartz.QuartzJobBean; + +/** + * http job bean + * “@DisallowConcurrentExecution” diable concurrent, thread size can not be only one, better given more + * @author xuxueli 2015-12-17 18:20:34 + */ +//@DisallowConcurrentExecution +public class RemoteHttpJobBean extends QuartzJobBean { + private static Logger logger = LoggerFactory.getLogger(RemoteHttpJobBean.class); + + @Override + protected void executeInternal(JobExecutionContext context) + throws JobExecutionException { + + // load jobId + JobKey jobKey = context.getTrigger().getJobKey(); + Integer jobId = Integer.valueOf(jobKey.getName()); + + // trigger + //XxlJobTrigger.trigger(jobId); + JobTriggerPoolHelper.trigger(jobId, -1); + } + } \ No newline at end of file diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/model/XxlJobLog.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/model/XxlJobLog.java index 99c5cc6b..b668f44a 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/model/XxlJobLog.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/model/XxlJobLog.java @@ -1,155 +1,155 @@ -package com.xxl.job.admin.core.model; - -import java.util.Date; - -/** - * xxl-job log, used to track trigger process - * @author xuxueli 2015-12-19 23:19:09 - */ -public class XxlJobLog { - - private int id; - - // job info - private int jobGroup; - private int jobId; - - // glueType - private String glueType; - - // execute info - private String executorAddress; - private String executorHandler; - private String executorParam; - private int executorFailRetryCount; - - // trigger info - private Date triggerTime; - private int triggerCode; - private String triggerMsg; - - // handle info - private Date handleTime; - private int handleCode; - private String handleMsg; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public int getJobGroup() { - return jobGroup; - } - - public void setJobGroup(int jobGroup) { - this.jobGroup = jobGroup; - } - - public int getJobId() { - return jobId; - } - - public void setJobId(int jobId) { - this.jobId = jobId; - } - - public String getGlueType() { - return glueType; - } - - public void setGlueType(String glueType) { - this.glueType = glueType; - } - - public String getExecutorAddress() { - return executorAddress; - } - - public void setExecutorAddress(String executorAddress) { - this.executorAddress = executorAddress; - } - - public String getExecutorHandler() { - return executorHandler; - } - - public void setExecutorHandler(String executorHandler) { - this.executorHandler = executorHandler; - } - - public String getExecutorParam() { - return executorParam; - } - - public void setExecutorParam(String executorParam) { - this.executorParam = executorParam; - } - - public int getExecutorFailRetryCount() { - return executorFailRetryCount; - } - - public void setExecutorFailRetryCount(int executorFailRetryCount) { - this.executorFailRetryCount = executorFailRetryCount; - } - - public Date getTriggerTime() { - return triggerTime; - } - - public void setTriggerTime(Date triggerTime) { - this.triggerTime = triggerTime; - } - - public int getTriggerCode() { - return triggerCode; - } - - public void setTriggerCode(int triggerCode) { - this.triggerCode = triggerCode; - } - - public String getTriggerMsg() { - return triggerMsg; - } - - public void setTriggerMsg(String triggerMsg) { - // plugin - if (triggerMsg!=null && triggerMsg.length()>2000) { - triggerMsg = triggerMsg.substring(0, 2000); - } - this.triggerMsg = triggerMsg; - } - - public Date getHandleTime() { - return handleTime; - } - - public void setHandleTime(Date handleTime) { - this.handleTime = handleTime; - } - - public int getHandleCode() { - return handleCode; - } - - public void setHandleCode(int handleCode) { - this.handleCode = handleCode; - } - - public String getHandleMsg() { - return handleMsg; - } - - public void setHandleMsg(String handleMsg) { - // plugin - if (handleMsg!=null && handleMsg.length()>2000) { - handleMsg = handleMsg.substring(0, 2000); - } - this.handleMsg = handleMsg; - } -} +package com.xxl.job.admin.core.model; + +import java.util.Date; + +/** + * xxl-job log, used to track trigger process + * @author xuxueli 2015-12-19 23:19:09 + */ +public class XxlJobLog { + + private int id; + + // job info + private int jobGroup; + private int jobId; + + // glueType + private String glueType; + + // execute info + private String executorAddress; + private String executorHandler; + private String executorParam; + private int executorFailRetryCount; + + // trigger info + private Date triggerTime; + private int triggerCode; + private String triggerMsg; + + // handle info + private Date handleTime; + private int handleCode; + private String handleMsg; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getJobGroup() { + return jobGroup; + } + + public void setJobGroup(int jobGroup) { + this.jobGroup = jobGroup; + } + + public int getJobId() { + return jobId; + } + + public void setJobId(int jobId) { + this.jobId = jobId; + } + + public String getGlueType() { + return glueType; + } + + public void setGlueType(String glueType) { + this.glueType = glueType; + } + + public String getExecutorAddress() { + return executorAddress; + } + + public void setExecutorAddress(String executorAddress) { + this.executorAddress = executorAddress; + } + + public String getExecutorHandler() { + return executorHandler; + } + + public void setExecutorHandler(String executorHandler) { + this.executorHandler = executorHandler; + } + + public String getExecutorParam() { + return executorParam; + } + + public void setExecutorParam(String executorParam) { + this.executorParam = executorParam; + } + + public int getExecutorFailRetryCount() { + return executorFailRetryCount; + } + + public void setExecutorFailRetryCount(int executorFailRetryCount) { + this.executorFailRetryCount = executorFailRetryCount; + } + + public Date getTriggerTime() { + return triggerTime; + } + + public void setTriggerTime(Date triggerTime) { + this.triggerTime = triggerTime; + } + + public int getTriggerCode() { + return triggerCode; + } + + public void setTriggerCode(int triggerCode) { + this.triggerCode = triggerCode; + } + + public String getTriggerMsg() { + return triggerMsg; + } + + public void setTriggerMsg(String triggerMsg) { + // plugin + if (triggerMsg!=null && triggerMsg.length()>2000) { + triggerMsg = triggerMsg.substring(0, 2000); + } + this.triggerMsg = triggerMsg; + } + + public Date getHandleTime() { + return handleTime; + } + + public void setHandleTime(Date handleTime) { + this.handleTime = handleTime; + } + + public int getHandleCode() { + return handleCode; + } + + public void setHandleCode(int handleCode) { + this.handleCode = handleCode; + } + + public String getHandleMsg() { + return handleMsg; + } + + public void setHandleMsg(String handleMsg) { + // plugin + if (handleMsg!=null && handleMsg.length()>2000) { + handleMsg = handleMsg.substring(0, 2000); + } + this.handleMsg = handleMsg; + } +} diff --git a/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml b/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml index 2b5879b3..99757ead 100644 --- a/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml +++ b/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml @@ -1,217 +1,217 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - t.id, - t.job_group, - t.job_id, - t.glue_type, - t.executor_address, - t.executor_handler, - t.executor_param, - t.executor_fail_retry_count, - t.trigger_time, - t.trigger_code, - t.trigger_msg, - t.handle_time, - t.handle_code, - t.handle_msg - - - - - - - - - - - INSERT INTO XXL_JOB_QRTZ_TRIGGER_LOG ( - `job_group`, - `job_id`, - `trigger_code`, - `handle_code` - ) VALUES ( - #{jobGroup}, - #{jobId}, - #{triggerCode}, - #{handleCode} - ); - - - - - UPDATE XXL_JOB_QRTZ_TRIGGER_LOG - SET - `glue_type`= #{glueType}, - `trigger_time`= #{triggerTime}, - `trigger_code`= #{triggerCode}, - `trigger_msg`= #{triggerMsg}, - `executor_address`= #{executorAddress}, - `executor_handler`=#{executorHandler}, - `executor_param`= #{executorParam}, - `executor_fail_retry_count`= #{executorFailRetryCount} - WHERE `id`= #{id} - - - - UPDATE XXL_JOB_QRTZ_TRIGGER_LOG - SET - `handle_time`= #{handleTime}, - `handle_code`= #{handleCode}, - `handle_msg`= #{handleMsg} - WHERE `id`= #{id} - - - - delete from XXL_JOB_QRTZ_TRIGGER_LOG - WHERE job_id = #{jobId} - - - - - - - - delete from XXL_JOB_QRTZ_TRIGGER_LOG - - - AND job_group = #{jobGroup} - - - AND job_id = #{jobId} - - - AND trigger_time #{clearBeforeTime} - - - AND id NOT in( - SELECT id FROM( - SELECT id FROM XXL_JOB_QRTZ_TRIGGER_LOG AS t - - - AND t.job_group = #{jobGroup} - - - AND t.job_id = #{jobId} - - - ORDER BY t.trigger_time desc - LIMIT 0, #{clearBeforeNum} - ) t1 - ) - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + t.id, + t.job_group, + t.job_id, + t.glue_type, + t.executor_address, + t.executor_handler, + t.executor_param, + t.executor_fail_retry_count, + t.trigger_time, + t.trigger_code, + t.trigger_msg, + t.handle_time, + t.handle_code, + t.handle_msg + + + + + + + + + + + INSERT INTO XXL_JOB_QRTZ_TRIGGER_LOG ( + `job_group`, + `job_id`, + `trigger_code`, + `handle_code` + ) VALUES ( + #{jobGroup}, + #{jobId}, + #{triggerCode}, + #{handleCode} + ); + + + + + UPDATE XXL_JOB_QRTZ_TRIGGER_LOG + SET + `glue_type`= #{glueType}, + `trigger_time`= #{triggerTime}, + `trigger_code`= #{triggerCode}, + `trigger_msg`= #{triggerMsg}, + `executor_address`= #{executorAddress}, + `executor_handler`=#{executorHandler}, + `executor_param`= #{executorParam}, + `executor_fail_retry_count`= #{executorFailRetryCount} + WHERE `id`= #{id} + + + + UPDATE XXL_JOB_QRTZ_TRIGGER_LOG + SET + `handle_time`= #{handleTime}, + `handle_code`= #{handleCode}, + `handle_msg`= #{handleMsg} + WHERE `id`= #{id} + + + + delete from XXL_JOB_QRTZ_TRIGGER_LOG + WHERE job_id = #{jobId} + + + + + + + + delete from XXL_JOB_QRTZ_TRIGGER_LOG + + + AND job_group = #{jobGroup} + + + AND job_id = #{jobId} + + + AND trigger_time #{clearBeforeTime} + + + AND id NOT in( + SELECT id FROM( + SELECT id FROM XXL_JOB_QRTZ_TRIGGER_LOG AS t + + + AND t.job_group = #{jobGroup} + + + AND t.job_id = #{jobId} + + + ORDER BY t.trigger_time desc + LIMIT 0, #{clearBeforeNum} + ) t1 + ) + + + + \ No newline at end of file diff --git a/xxl-job-admin/src/main/webapp/static/js/joblog.index.1.js b/xxl-job-admin/src/main/webapp/static/js/joblog.index.1.js index bb68fe9c..f3686a89 100644 --- a/xxl-job-admin/src/main/webapp/static/js/joblog.index.1.js +++ b/xxl-job-admin/src/main/webapp/static/js/joblog.index.1.js @@ -1,367 +1,367 @@ -$(function() { - - // jobGroup change, job list init and select - $("#jobGroup").on("change", function () { - var jobGroup = $(this).children('option:selected').val(); - $.ajax({ - type : 'POST', - async: false, // async, avoid js invoke pagelist before jobId data init - url : base_url + '/joblog/getJobsByGroup', - data : {"jobGroup":jobGroup}, - dataType : "json", - success : function(data){ - if (data.code == 200) { - $("#jobId").html( '' ); - $.each(data.content, function (n, value) { - $("#jobId").append(''); - }); - if ($("#jobId").attr("paramVal")){ - $("#jobId").find("option[value='" + $("#jobId").attr("paramVal") + "']").attr("selected",true); - } - } else { - layer.open({ - title: I18n.system_tips , - btn: [ I18n.system_ok ], - content: (data.msg || I18n.system_api_error ), - icon: '2' - }); - } - }, - }); - }); - if ($("#jobGroup").attr("paramVal")){ - $("#jobGroup").find("option[value='" + $("#jobGroup").attr("paramVal") + "']").attr("selected",true); - $("#jobGroup").change(); - } - - // filter Time - var rangesConf = {}; - rangesConf[I18n.daterangepicker_ranges_recent_hour] = [moment().subtract(1, 'hours'), moment()]; - rangesConf[I18n.daterangepicker_ranges_today] = [moment().startOf('day'), moment().endOf('day')]; - rangesConf[I18n.daterangepicker_ranges_yesterday] = [moment().subtract(1, 'days').startOf('day'), moment().subtract(1, 'days').endOf('day')]; - rangesConf[I18n.daterangepicker_ranges_this_month] = [moment().startOf('month'), moment().endOf('month')]; - rangesConf[I18n.daterangepicker_ranges_last_month] = [moment().subtract(1, 'months').startOf('month'), moment().subtract(1, 'months').endOf('month')]; - rangesConf[I18n.daterangepicker_ranges_recent_week] = [moment().subtract(1, 'weeks').startOf('day'), moment().endOf('day')]; - rangesConf[I18n.daterangepicker_ranges_recent_month] = [moment().subtract(1, 'months').startOf('day'), moment().endOf('day')]; - - $('#filterTime').daterangepicker({ - autoApply:false, - singleDatePicker:false, - showDropdowns:false, // 是否显示年月选择条件 - timePicker: true, // 是否显示小时和分钟选择条件 - timePickerIncrement: 10, // 时间的增量,单位为分钟 - timePicker24Hour : true, - opens : 'left', //日期选择框的弹出位置 - ranges: rangesConf, - locale : { - format: 'YYYY-MM-DD HH:mm:ss', - separator : ' - ', - customRangeLabel : I18n.daterangepicker_custom_name , - applyLabel : I18n.system_ok , - cancelLabel : I18n.system_cancel , - fromLabel : I18n.daterangepicker_custom_starttime , - toLabel : I18n.daterangepicker_custom_endtime , - daysOfWeek : I18n.daterangepicker_custom_daysofweek.split(',') , // '日', '一', '二', '三', '四', '五', '六' - monthNames : I18n.daterangepicker_custom_monthnames.split(',') , // '一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月' - firstDay : 1 - }, - startDate: rangesConf[I18n.daterangepicker_ranges_today][0], - endDate: rangesConf[I18n.daterangepicker_ranges_today][1] - }); - - // init date tables - var logTable = $("#joblog_list").dataTable({ - "deferRender": true, - "processing" : true, - "serverSide": true, - "ajax": { - url: base_url + "/joblog/pageList" , - type:"post", - data : function ( d ) { - var obj = {}; - obj.jobGroup = $('#jobGroup').val(); - obj.jobId = $('#jobId').val(); - obj.logStatus = $('#logStatus').val(); - obj.filterTime = $('#filterTime').val(); - obj.start = d.start; - obj.length = d.length; - return obj; - } - }, - "searching": false, - "ordering": false, - //"scrollX": false, - "columns": [ - { - "data": 'jobId', - "visible" : true, - "width":'10%', - "render": function ( data, type, row ) { - - var glueTypeTitle = GlueTypeEnum[row.glueType]; - if (row.executorHandler) { - glueTypeTitle = glueTypeTitle +":" + row.executorHandler; - } - - var temp = ''; - temp += I18n.joblog_field_executorAddress + ':' + (row.executorAddress?row.executorAddress:''); - temp += '
'+ I18n.jobinfo_field_gluetype +':' + glueTypeTitle; - temp += '
'+ I18n.jobinfo_field_executorparam +':' + row.executorParam; - - return ''+ row.jobId +''+ temp +''; - } - }, - { "data": 'jobGroup', "visible" : false}, - { - "data": 'triggerTime', - "width":'16%', - "render": function ( data, type, row ) { - return data?moment(new Date(data)).format("YYYY-MM-DD HH:mm:ss"):""; - } - }, - { - "data": 'triggerCode', - "width":'12%', - "render": function ( data, type, row ) { - var html = data; - if (data == 200) { - html = ''+ I18n.system_success +''; - } else if (data == 500) { - html = ''+ I18n.system_fail +''; - } else if (data == 0) { - html = ''; - } - return html; - } - }, - { - "data": 'triggerMsg', - "width":'12%', - "render": function ( data, type, row ) { - return data?''+ I18n.system_show +''+ data +'':I18n.system_empty; - } - }, - { - "data": 'handleTime', - "width":'16%', - "render": function ( data, type, row ) { - return data?moment(new Date(data)).format("YYYY-MM-DD HH:mm:ss"):""; - } - }, - { - "data": 'handleCode', - "width":'12%', - "render": function ( data, type, row ) { - var html = data; - if (data == 200) { - html = ''+ I18n.joblog_handleCode_200 +''; - } else if (data == 500) { - html = ''+ I18n.joblog_handleCode_500 +''; - } else if (data == 502) { - html = ''+ I18n.joblog_handleCode_502 +''; - } else if (data == 0) { - html = ''; - } - return html; - } - }, - { - "data": 'handleMsg', - "width":'12%', - "render": function ( data, type, row ) { - return data?''+ I18n.system_show +''+ data +'':I18n.system_empty; - } - }, - { - "data": 'handleMsg' , - "bSortable": false, - "width":'10%', - "render": function ( data, type, row ) { - // better support expression or string, not function - return function () { - if (row.triggerCode == 200){ - var temp = ''+ I18n.joblog_rolling_log +''; - if(row.handleCode == 0){ - temp += '
'+ I18n.joblog_kill_log +''; - } - return temp; - } - return null; - } - } - } - ], - "language" : { - "sProcessing" : I18n.dataTable_sProcessing , - "sLengthMenu" : I18n.dataTable_sLengthMenu , - "sZeroRecords" : I18n.dataTable_sZeroRecords , - "sInfo" : I18n.dataTable_sInfo , - "sInfoEmpty" : I18n.dataTable_sInfoEmpty , - "sInfoFiltered" : I18n.dataTable_sInfoFiltered , - "sInfoPostFix" : "", - "sSearch" : I18n.dataTable_sSearch , - "sUrl" : "", - "sEmptyTable" : I18n.dataTable_sEmptyTable , - "sLoadingRecords" : I18n.dataTable_sLoadingRecords , - "sInfoThousands" : ",", - "oPaginate" : { - "sFirst" : I18n.dataTable_sFirst , - "sPrevious" : I18n.dataTable_sPrevious , - "sNext" : I18n.dataTable_sNext , - "sLast" : I18n.dataTable_sLast - }, - "oAria" : { - "sSortAscending" : I18n.dataTable_sSortAscending , - "sSortDescending" : I18n.dataTable_sSortDescending - } - } - }); - - // logTips alert - $('#joblog_list').on('click', '.logTips', function(){ - var msg = $(this).find('span').html(); - ComAlertTec.show(msg); - }); - - // search Btn - $('#searchBtn').on('click', function(){ - logTable.fnDraw(); - }); - - // logDetail look - $('#joblog_list').on('click', '.logDetail', function(){ - var _id = $(this).attr('_id'); - - window.open(base_url + '/joblog/logDetailPage?id=' + _id); - return; - }); - - /** - * log Kill - */ - $('#joblog_list').on('click', '.logKill', function(){ - var _id = $(this).attr('_id'); - - layer.confirm( (I18n.system_ok + I18n.joblog_kill_log + '?'), { - icon: 3, - title: I18n.system_tips , - btn: [ I18n.system_ok, I18n.system_cancel ] - }, function(index){ - layer.close(index); - - $.ajax({ - type : 'POST', - url : base_url + '/joblog/logKill', - data : {"id":_id}, - dataType : "json", - success : function(data){ - if (data.code == 200) { - layer.open({ - title: I18n.system_tips, - btn: [ I18n.system_ok ], - content: I18n.system_opt_suc , - icon: '1', - end: function(layero, index){ - logTable.fnDraw(); - } - }); - } else { - layer.open({ - title: I18n.system_tips, - btn: [ I18n.system_ok ], - content: (data.msg || I18n.system_opt_fail ), - icon: '2' - }); - } - }, - }); - }); - - }); - - /** - * clear Log - */ - $('#clearLog').on('click', function(){ - - var jobGroup = $('#jobGroup').val(); - var jobId = $('#jobId').val(); - - var jobGroupText = $("#jobGroup").find("option:selected").text(); - var jobIdText = $("#jobId").find("option:selected").text(); - - $('#clearLogModal input[name=jobGroup]').val(jobGroup); - $('#clearLogModal input[name=jobId]').val(jobId); - - $('#clearLogModal .jobGroupText').val(jobGroupText); - $('#clearLogModal .jobIdText').val(jobIdText); - - $('#clearLogModal').modal('show'); - - }); - $("#clearLogModal .ok").on('click', function(){ - $.post(base_url + "/joblog/clearLog", $("#clearLogModal .form").serialize(), function(data, status) { - if (data.code == "200") { - $('#clearLogModal').modal('hide'); - layer.open({ - title: I18n.system_tips , - btn: [ I18n.system_ok ], - content: (I18n.joblog_clean_log + I18n.system_success) , - icon: '1', - end: function(layero, index){ - logTable.fnDraw(); - } - }); - } else { - layer.open({ - title: I18n.system_tips , - btn: [ I18n.system_ok ], - content: (data.msg || (I18n.joblog_clean_log + I18n.system_fail) ), - icon: '2' - }); - } - }); - }); - $("#clearLogModal").on('hide.bs.modal', function () { - $("#clearLogModal .form")[0].reset(); - }); - -}); - - -// Com Alert by Tec theme -var ComAlertTec = { - html:function(){ - var html = - ''; - return html; - }, - show:function(msg, callback){ - // dom init - if ($('#ComAlertTec').length == 0){ - $('body').append(ComAlertTec.html()); - } - - // init com alert - $('#ComAlertTec .alert').html(msg); - $('#ComAlertTec').modal('show'); - - $('#ComAlertTec .ok').click(function(){ - $('#ComAlertTec').modal('hide'); - if(typeof callback == 'function') { - callback(); - } - }); - } -}; +$(function() { + + // jobGroup change, job list init and select + $("#jobGroup").on("change", function () { + var jobGroup = $(this).children('option:selected').val(); + $.ajax({ + type : 'POST', + async: false, // async, avoid js invoke pagelist before jobId data init + url : base_url + '/joblog/getJobsByGroup', + data : {"jobGroup":jobGroup}, + dataType : "json", + success : function(data){ + if (data.code == 200) { + $("#jobId").html( '' ); + $.each(data.content, function (n, value) { + $("#jobId").append(''); + }); + if ($("#jobId").attr("paramVal")){ + $("#jobId").find("option[value='" + $("#jobId").attr("paramVal") + "']").attr("selected",true); + } + } else { + layer.open({ + title: I18n.system_tips , + btn: [ I18n.system_ok ], + content: (data.msg || I18n.system_api_error ), + icon: '2' + }); + } + }, + }); + }); + if ($("#jobGroup").attr("paramVal")){ + $("#jobGroup").find("option[value='" + $("#jobGroup").attr("paramVal") + "']").attr("selected",true); + $("#jobGroup").change(); + } + + // filter Time + var rangesConf = {}; + rangesConf[I18n.daterangepicker_ranges_recent_hour] = [moment().subtract(1, 'hours'), moment()]; + rangesConf[I18n.daterangepicker_ranges_today] = [moment().startOf('day'), moment().endOf('day')]; + rangesConf[I18n.daterangepicker_ranges_yesterday] = [moment().subtract(1, 'days').startOf('day'), moment().subtract(1, 'days').endOf('day')]; + rangesConf[I18n.daterangepicker_ranges_this_month] = [moment().startOf('month'), moment().endOf('month')]; + rangesConf[I18n.daterangepicker_ranges_last_month] = [moment().subtract(1, 'months').startOf('month'), moment().subtract(1, 'months').endOf('month')]; + rangesConf[I18n.daterangepicker_ranges_recent_week] = [moment().subtract(1, 'weeks').startOf('day'), moment().endOf('day')]; + rangesConf[I18n.daterangepicker_ranges_recent_month] = [moment().subtract(1, 'months').startOf('day'), moment().endOf('day')]; + + $('#filterTime').daterangepicker({ + autoApply:false, + singleDatePicker:false, + showDropdowns:false, // 是否显示年月选择条件 + timePicker: true, // 是否显示小时和分钟选择条件 + timePickerIncrement: 10, // 时间的增量,单位为分钟 + timePicker24Hour : true, + opens : 'left', //日期选择框的弹出位置 + ranges: rangesConf, + locale : { + format: 'YYYY-MM-DD HH:mm:ss', + separator : ' - ', + customRangeLabel : I18n.daterangepicker_custom_name , + applyLabel : I18n.system_ok , + cancelLabel : I18n.system_cancel , + fromLabel : I18n.daterangepicker_custom_starttime , + toLabel : I18n.daterangepicker_custom_endtime , + daysOfWeek : I18n.daterangepicker_custom_daysofweek.split(',') , // '日', '一', '二', '三', '四', '五', '六' + monthNames : I18n.daterangepicker_custom_monthnames.split(',') , // '一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月' + firstDay : 1 + }, + startDate: rangesConf[I18n.daterangepicker_ranges_today][0], + endDate: rangesConf[I18n.daterangepicker_ranges_today][1] + }); + + // init date tables + var logTable = $("#joblog_list").dataTable({ + "deferRender": true, + "processing" : true, + "serverSide": true, + "ajax": { + url: base_url + "/joblog/pageList" , + type:"post", + data : function ( d ) { + var obj = {}; + obj.jobGroup = $('#jobGroup').val(); + obj.jobId = $('#jobId').val(); + obj.logStatus = $('#logStatus').val(); + obj.filterTime = $('#filterTime').val(); + obj.start = d.start; + obj.length = d.length; + return obj; + } + }, + "searching": false, + "ordering": false, + //"scrollX": false, + "columns": [ + { + "data": 'jobId', + "visible" : true, + "width":'10%', + "render": function ( data, type, row ) { + + var glueTypeTitle = GlueTypeEnum[row.glueType]; + if (row.executorHandler) { + glueTypeTitle = glueTypeTitle +":" + row.executorHandler; + } + + var temp = ''; + temp += I18n.joblog_field_executorAddress + ':' + (row.executorAddress?row.executorAddress:''); + temp += '
'+ I18n.jobinfo_field_gluetype +':' + glueTypeTitle; + temp += '
'+ I18n.jobinfo_field_executorparam +':' + row.executorParam; + + return ''+ row.jobId +''+ temp +''; + } + }, + { "data": 'jobGroup', "visible" : false}, + { + "data": 'triggerTime', + "width":'16%', + "render": function ( data, type, row ) { + return data?moment(new Date(data)).format("YYYY-MM-DD HH:mm:ss"):""; + } + }, + { + "data": 'triggerCode', + "width":'12%', + "render": function ( data, type, row ) { + var html = data; + if (data == 200) { + html = ''+ I18n.system_success +''; + } else if (data == 500) { + html = ''+ I18n.system_fail +''; + } else if (data == 0) { + html = ''; + } + return html; + } + }, + { + "data": 'triggerMsg', + "width":'12%', + "render": function ( data, type, row ) { + return data?''+ I18n.system_show +''+ data +'':I18n.system_empty; + } + }, + { + "data": 'handleTime', + "width":'16%', + "render": function ( data, type, row ) { + return data?moment(new Date(data)).format("YYYY-MM-DD HH:mm:ss"):""; + } + }, + { + "data": 'handleCode', + "width":'12%', + "render": function ( data, type, row ) { + var html = data; + if (data == 200) { + html = ''+ I18n.joblog_handleCode_200 +''; + } else if (data == 500) { + html = ''+ I18n.joblog_handleCode_500 +''; + } else if (data == 502) { + html = ''+ I18n.joblog_handleCode_502 +''; + } else if (data == 0) { + html = ''; + } + return html; + } + }, + { + "data": 'handleMsg', + "width":'12%', + "render": function ( data, type, row ) { + return data?''+ I18n.system_show +''+ data +'':I18n.system_empty; + } + }, + { + "data": 'handleMsg' , + "bSortable": false, + "width":'10%', + "render": function ( data, type, row ) { + // better support expression or string, not function + return function () { + if (row.triggerCode == 200){ + var temp = ''+ I18n.joblog_rolling_log +''; + if(row.handleCode == 0){ + temp += '
'+ I18n.joblog_kill_log +''; + } + return temp; + } + return null; + } + } + } + ], + "language" : { + "sProcessing" : I18n.dataTable_sProcessing , + "sLengthMenu" : I18n.dataTable_sLengthMenu , + "sZeroRecords" : I18n.dataTable_sZeroRecords , + "sInfo" : I18n.dataTable_sInfo , + "sInfoEmpty" : I18n.dataTable_sInfoEmpty , + "sInfoFiltered" : I18n.dataTable_sInfoFiltered , + "sInfoPostFix" : "", + "sSearch" : I18n.dataTable_sSearch , + "sUrl" : "", + "sEmptyTable" : I18n.dataTable_sEmptyTable , + "sLoadingRecords" : I18n.dataTable_sLoadingRecords , + "sInfoThousands" : ",", + "oPaginate" : { + "sFirst" : I18n.dataTable_sFirst , + "sPrevious" : I18n.dataTable_sPrevious , + "sNext" : I18n.dataTable_sNext , + "sLast" : I18n.dataTable_sLast + }, + "oAria" : { + "sSortAscending" : I18n.dataTable_sSortAscending , + "sSortDescending" : I18n.dataTable_sSortDescending + } + } + }); + + // logTips alert + $('#joblog_list').on('click', '.logTips', function(){ + var msg = $(this).find('span').html(); + ComAlertTec.show(msg); + }); + + // search Btn + $('#searchBtn').on('click', function(){ + logTable.fnDraw(); + }); + + // logDetail look + $('#joblog_list').on('click', '.logDetail', function(){ + var _id = $(this).attr('_id'); + + window.open(base_url + '/joblog/logDetailPage?id=' + _id); + return; + }); + + /** + * log Kill + */ + $('#joblog_list').on('click', '.logKill', function(){ + var _id = $(this).attr('_id'); + + layer.confirm( (I18n.system_ok + I18n.joblog_kill_log + '?'), { + icon: 3, + title: I18n.system_tips , + btn: [ I18n.system_ok, I18n.system_cancel ] + }, function(index){ + layer.close(index); + + $.ajax({ + type : 'POST', + url : base_url + '/joblog/logKill', + data : {"id":_id}, + dataType : "json", + success : function(data){ + if (data.code == 200) { + layer.open({ + title: I18n.system_tips, + btn: [ I18n.system_ok ], + content: I18n.system_opt_suc , + icon: '1', + end: function(layero, index){ + logTable.fnDraw(); + } + }); + } else { + layer.open({ + title: I18n.system_tips, + btn: [ I18n.system_ok ], + content: (data.msg || I18n.system_opt_fail ), + icon: '2' + }); + } + }, + }); + }); + + }); + + /** + * clear Log + */ + $('#clearLog').on('click', function(){ + + var jobGroup = $('#jobGroup').val(); + var jobId = $('#jobId').val(); + + var jobGroupText = $("#jobGroup").find("option:selected").text(); + var jobIdText = $("#jobId").find("option:selected").text(); + + $('#clearLogModal input[name=jobGroup]').val(jobGroup); + $('#clearLogModal input[name=jobId]').val(jobId); + + $('#clearLogModal .jobGroupText').val(jobGroupText); + $('#clearLogModal .jobIdText').val(jobIdText); + + $('#clearLogModal').modal('show'); + + }); + $("#clearLogModal .ok").on('click', function(){ + $.post(base_url + "/joblog/clearLog", $("#clearLogModal .form").serialize(), function(data, status) { + if (data.code == "200") { + $('#clearLogModal').modal('hide'); + layer.open({ + title: I18n.system_tips , + btn: [ I18n.system_ok ], + content: (I18n.joblog_clean_log + I18n.system_success) , + icon: '1', + end: function(layero, index){ + logTable.fnDraw(); + } + }); + } else { + layer.open({ + title: I18n.system_tips , + btn: [ I18n.system_ok ], + content: (data.msg || (I18n.joblog_clean_log + I18n.system_fail) ), + icon: '2' + }); + } + }); + }); + $("#clearLogModal").on('hide.bs.modal', function () { + $("#clearLogModal .form")[0].reset(); + }); + +}); + + +// Com Alert by Tec theme +var ComAlertTec = { + html:function(){ + var html = + ''; + return html; + }, + show:function(msg, callback){ + // dom init + if ($('#ComAlertTec').length == 0){ + $('body').append(ComAlertTec.html()); + } + + // init com alert + $('#ComAlertTec .alert').html(msg); + $('#ComAlertTec').modal('show'); + + $('#ComAlertTec .ok').click(function(){ + $('#ComAlertTec').modal('hide'); + if(typeof callback == 'function') { + callback(); + } + }); + } +}; diff --git a/xxl-job-core/src/main/java/com/xxl/job/core/handler/IJobHandler.java b/xxl-job-core/src/main/java/com/xxl/job/core/handler/IJobHandler.java index 087b5ba0..4347637a 100644 --- a/xxl-job-core/src/main/java/com/xxl/job/core/handler/IJobHandler.java +++ b/xxl-job-core/src/main/java/com/xxl/job/core/handler/IJobHandler.java @@ -1,47 +1,47 @@ -package com.xxl.job.core.handler; - -import com.xxl.job.core.biz.model.ReturnT; - -/** - * job handler - * - * @author xuxueli 2015-12-19 19:06:38 - */ -public abstract class IJobHandler { - - - /** success */ - public static final ReturnT SUCCESS = new ReturnT(200, null); - /** fail */ - public static final ReturnT FAIL = new ReturnT(500, null); - /** fail timeout */ - public static final ReturnT FAIL_TIMEOUT = new ReturnT(502, null); - - - /** - * execute handler, invoked when executor receives a scheduling request - * - * @param param - * @return - * @throws Exception - */ - public abstract ReturnT execute(String param) throws Exception; - - - /** - * init handler, invoked when JobThread init - */ - public void init() { - // TODO - } - - - /** - * destroy handler, invoked when JobThread destroy - */ - public void destroy() { - // TODO - } - - -} +package com.xxl.job.core.handler; + +import com.xxl.job.core.biz.model.ReturnT; + +/** + * job handler + * + * @author xuxueli 2015-12-19 19:06:38 + */ +public abstract class IJobHandler { + + + /** success */ + public static final ReturnT SUCCESS = new ReturnT(200, null); + /** fail */ + public static final ReturnT FAIL = new ReturnT(500, null); + /** fail timeout */ + public static final ReturnT FAIL_TIMEOUT = new ReturnT(502, null); + + + /** + * execute handler, invoked when executor receives a scheduling request + * + * @param param + * @return + * @throws Exception + */ + public abstract ReturnT execute(String param) throws Exception; + + + /** + * init handler, invoked when JobThread init + */ + public void init() { + // TODO + } + + + /** + * destroy handler, invoked when JobThread destroy + */ + public void destroy() { + // TODO + } + + +}