提交 5c1bba33 编写于 作者: X xueli.xue

V1.3版本,阶段A:GLUE模式开关

上级 e6c239ec
# DROP TABLE IF EXISTS XXL_JOB_QRTZ_FIRED_TRIGGERS;
# DROP TABLE IF EXISTS XXL_JOB_QRTZ_PAUSED_TRIGGER_GRPS;
# DROP TABLE IF EXISTS XXL_JOB_QRTZ_SCHEDULER_STATE;
# DROP TABLE IF EXISTS XXL_JOB_QRTZ_LOCKS;
CREATE TABLE XXL_JOB_QRTZ_JOB_DETAILS
(
......@@ -160,6 +156,9 @@ CREATE TABLE `xxl_job_qrtz_trigger_info` (
`author` varchar(64) DEFAULT NULL COMMENT '作者',
`alarm_email` varchar(255) DEFAULT NULL COMMENT '报警邮件',
`alarm_threshold` int(11) DEFAULT NULL COMMENT '报警阀值(连续失败次数)',
`glue_switch` int(11) DEFAULT '0' COMMENT 'GLUE模式开关:0-否,1-是',
`glue_source` text COMMENT 'GLUE源代码',
`glue_remark` varchar(128) DEFAULT NULL COMMENT 'GLUE备注',
PRIMARY KEY (`id`)
);
......@@ -180,5 +179,17 @@ CREATE TABLE `xxl_job_qrtz_trigger_log` (
PRIMARY KEY (`id`)
);
CREATE TABLE `xxl_job_qrtz_trigger_logglue` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`job_group` varchar(255) NOT NULL,
`job_name` varchar(255) NOT NULL,
`glue_source` text,
`glue_remark` varchar(128) NOT NULL,
`add_time` timestamp NULL DEFAULT NULL,
`update_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ;
commit;
......@@ -70,7 +70,7 @@ public class JobInfoController {
@ResponseBody
public ReturnT<String> add(String jobGroup, String jobName, String jobCron, String jobDesc,
String handler_address, String handler_name, String handler_params,
String author, String alarmEmail, int alarmThreshold) {
String author, String alarmEmail, int alarmThreshold, int glueSwitch) {
// valid
if (JobGroupEnum.match(jobGroup) == null) {
......@@ -88,7 +88,7 @@ public class JobInfoController {
if (StringUtils.isBlank(handler_address)) {
return new ReturnT<String>(500, "请输入“机器地址”");
}
if (StringUtils.isBlank(handler_name)) {
if (glueSwitch==0 && StringUtils.isBlank(handler_name)) {
return new ReturnT<String>(500, "请输入“执行器”");
}
if (StringUtils.isBlank(author)) {
......@@ -127,6 +127,9 @@ public class JobInfoController {
jobInfo.setAuthor(author);
jobInfo.setAlarmEmail(alarmEmail);
jobInfo.setAlarmThreshold(alarmThreshold);
jobInfo.setGlueSwitch(glueSwitch);
jobInfo.setGlueSource(null);
jobInfo.setGlueRemark(null);
xxlJobInfoDao.save(jobInfo);
try {
......@@ -148,7 +151,7 @@ public class JobInfoController {
@ResponseBody
public ReturnT<String> reschedule(String jobGroup, String jobName, String jobCron, String jobDesc,
String handler_address, String handler_name, String handler_params,
String author, String alarmEmail, int alarmThreshold) {
String author, String alarmEmail, int alarmThreshold, int glueSwitch) {
// valid
if (JobGroupEnum.match(jobGroup) == null) {
......@@ -166,7 +169,7 @@ public class JobInfoController {
if (StringUtils.isBlank(handler_address)) {
return new ReturnT<String>(500, "请输入“机器地址”");
}
if (StringUtils.isBlank(handler_name)) {
if (glueSwitch==0 && StringUtils.isBlank(handler_name)) {
return new ReturnT<String>(500, "请输入“执行器”");
}
if (StringUtils.isBlank(author)) {
......@@ -192,6 +195,7 @@ public class JobInfoController {
jobInfo.setAuthor(author);
jobInfo.setAlarmEmail(alarmEmail);
jobInfo.setAlarmThreshold(alarmThreshold);
jobInfo.setGlueSwitch(glueSwitch);
try {
// fresh quartz
......
......@@ -24,6 +24,10 @@ public class XxlJobInfo {
private String alarmEmail; // 报警邮件
private int alarmThreshold; // 报警阀值
private int glueSwitch; // GLUE模式开关:0-否,1-是
private String glueSource; // GLUE源代码
private String glueRemark; // GLUE备注
// copy from quartz
private String jobStatus; // 任务状态 【base on quartz】
......@@ -131,12 +135,37 @@ public class XxlJobInfo {
this.jobStatus = jobStatus;
}
public int getGlueSwitch() {
return glueSwitch;
}
public void setGlueSwitch(int glueSwitch) {
this.glueSwitch = glueSwitch;
}
public String getGlueSource() {
return glueSource;
}
public void setGlueSource(String glueSource) {
this.glueSource = glueSource;
}
public String getGlueRemark() {
return glueRemark;
}
public void setGlueRemark(String glueRemark) {
this.glueRemark = glueRemark;
}
@Override
public String toString() {
return "XxlJobInfo [id=" + id + ", jobGroup=" + jobGroup + ", jobName=" + jobName + ", jobCron=" + jobCron
+ ", jobDesc=" + jobDesc + ", jobClass=" + jobClass + ", jobData=" + jobData + ", addTime=" + addTime
+ ", updateTime=" + updateTime + ", author=" + author + ", alarmEmail=" + alarmEmail
+ ", alarmThreshold=" + alarmThreshold + ", jobStatus=" + jobStatus + "]";
+ ", alarmThreshold=" + alarmThreshold + ", glueSwitch=" + glueSwitch + ", glueSource=" + glueSource
+ ", glueRemark=" + glueRemark + ", jobStatus=" + jobStatus + "]";
}
}
......@@ -19,6 +19,10 @@
<result column="author" property="author" />
<result column="alarm_email" property="alarmEmail" />
<result column="alarm_threshold" property="alarmThreshold" />
<result column="glue_switch" property="glueSwitch" />
<result column="glue_source" property="glueSource" />
<result column="glue_remark" property="glueRemark" />
</resultMap>
<sql id="Base_Column_List">
......@@ -33,7 +37,10 @@
t.update_time,
t.author,
t.alarm_email,
t.alarm_threshold
t.alarm_threshold,
t.glue_switch,
t.glue_source,
t.glue_remark
</sql>
<select id="pageList" parameterType="java.util.HashMap" resultMap="XxlJobInfo">
......@@ -76,7 +83,10 @@
update_time,
author,
alarm_email,
alarm_threshold
alarm_threshold,
glue_switch,
glue_source,
glue_remark
) VALUES (
#{jobGroup},
#{jobName},
......@@ -88,7 +98,10 @@
NOW(),
#{author},
#{alarmEmail},
#{alarmThreshold}
#{alarmThreshold},
#{glueSwitch},
#{glueSource},
#{glueRemark}
);
<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
SELECT LAST_INSERT_ID()
......@@ -111,7 +124,10 @@
update_time = NOW(),
author = #{author},
alarm_email = #{alarmEmail},
alarm_threshold = #{alarmThreshold}
alarm_threshold = #{alarmThreshold},
glue_switch = #{glueSwitch},
glue_source = #{glueSource},
glue_remark = #{glueRemark}
WHERE job_group = #{jobGroup}
AND job_name = #{jobName}
</update>
......
......@@ -78,6 +78,7 @@
<th name="author" >负责人</th>
<th name="alarmEmail" >报警邮件</th>
<th name="alarmThreshold" >报警阀值</th>
<th name="glueSwitch" >GLUE模式</th>
<th name="jobStatus" >状态</th>
<th>操作</th>
</tr>
......@@ -142,10 +143,16 @@
<div class="col-sm-4"><input type="text" class="form-control" name="alarmThreshold" placeholder="请输入“报警阈值”" maxlength="200" ></div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-9">
<div class="col-sm-offset-3 col-sm-6">
<button type="submit" class="btn btn-primary" >保存</button>
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
</div>
<div class="col-sm-3">
<div class="checkbox">
<label><input type="checkbox" class="ifGLUE" >开启GLUE模式<font color="black">*</font></label>
<input type="hidden" name="glueSwitch" value="0" >
</div>
</div>
</div>
</form>
</div>
......@@ -194,10 +201,16 @@
<div class="col-sm-4"><input type="text" class="form-control" name="alarmThreshold" placeholder="请输入“报警阈值”" maxlength="200" ></div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-9">
<div class="col-sm-offset-3 col-sm-6">
<button type="submit" class="btn btn-primary" >保存</button>
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
</div>
<div class="col-sm-3">
<div class="checkbox">
<label><input type="checkbox" class="ifGLUE" >开启GLUE模式<font color="black">*</font></label>
<input type="hidden" name="glueSwitch" value="0" >
</div>
</div>
</div>
</form>
</div>
......
......@@ -8,10 +8,11 @@ $(function() {
});
codeEditor.setValue( $("#demoCode").val() );
// editor height
var height = Math.max(document.documentElement.clientHeight, document.body.offsetHeight);
$(".CodeMirror").attr('style', 'height:'+ height +'px');
// code source save
$("#save").click(function() {
var codeSource = codeEditor.getValue();
var codeRemark = $("#codeRemark").val();
......
......@@ -61,6 +61,7 @@ $(function() {
{ "data": 'author', "visible" : true},
{ "data": 'alarmEmail', "visible" : false},
{ "data": 'alarmThreshold', "visible" : false},
{ "data": 'glueSwitch', "visible" : false},
{
"data": 'jobStatus',
"visible" : true,
......@@ -87,8 +88,13 @@ $(function() {
}
// log url
var logUrl = base_url +'/joblog?jobGroup='+ row.jobGroup +'&jobName='+ row.jobName;
// log url
var codeUrl = base_url +'/jobcode?id='+ row.id;
var codeHtml = "";
if(row.glueSwitch != 0){
var codeUrl = base_url +'/jobcode?id='+ row.id;
codeHtml = '<button class="btn btn-warning btn-xs" type="button" onclick="javascript:window.open(\'' + codeUrl + '\')" >GLUE</button> '
}
// job data
var jobDataMap = eval('(' + row.jobData + ')');
......@@ -100,18 +106,19 @@ $(function() {
' jobDesc="'+ row.jobDesc +'" '+
' jobClass="'+ row.jobClass +'" '+
' jobData="'+ row.jobData +'" '+
' author="'+ row.author +'" '+
' alarmEmail="'+ row.alarmEmail +'" '+
' alarmThreshold="'+ row.alarmThreshold +'" '+
' handler_params="'+jobDataMap.handler_params +'" '+
' handler_address="'+ jobDataMap.handler_address +'" '+
' handler_name="'+ jobDataMap.handler_name +'" '+
' author="'+ row.author +'" '+
' alarmEmail="'+ row.alarmEmail +'" '+
' alarmThreshold="'+ row.alarmThreshold +'" '+
' glueSwitch="'+ row.glueSwitch +'" '+
'>'+
'<button class="btn btn-primary btn-xs job_operate" type="job_trigger" type="button">执行</button> '+
pause_resume +
'<button class="btn btn-primary btn-xs" type="job_del" type="button" onclick="javascript:window.open(\'' + logUrl + '\')" >日志</button><br> '+
'<button class="btn btn-warning btn-xs update" type="button">编辑</button> '+
'<button class="btn btn-warning btn-xs" type="button" onclick="javascript:window.open(\'' + codeUrl + '\')" >GLUE</button> '+
codeHtml +
'<button class="btn btn-danger btn-xs job_operate" type="job_del" type="button">删除</button> '+
'</p>';
......@@ -318,6 +325,34 @@ $(function() {
$(".remote_panel").show(); // remote
});
// GLUE模式开启
$("#addModal .form .ifGLUE").click(function(){
var ifGLUE = $(this).is(':checked');
var $handler_name = $("#addModal .form input[name='handler_name']");
var $glueSwitch = $("#addModal .form input[name='glueSwitch']");
if (ifGLUE) {
$handler_name.val("");
$handler_name.attr("readonly","readonly");
$glueSwitch.val(1);
} else {
$handler_name.removeAttr("readonly");
$glueSwitch.val(0);
}
});
$("#updateModal .form .ifGLUE").click(function(){
var ifGLUE = $(this).is(':checked');
var $handler_name = $("#updateModal .form input[name='handler_name']");
var $glueSwitch = $("#updateModal .form input[name='glueSwitch']");
if (ifGLUE) {
$handler_name.val("");
$handler_name.attr("readonly","readonly");
$glueSwitch.val(1);
} else {
$handler_name.removeAttr("readonly");
$glueSwitch.val(0);
}
});
// 更新
$("#job_list").on('click', '.update',function() {
$("#updateModal .form input[name='jobGroup']").val($(this).parent('p').attr("jobGroup"));
......@@ -330,6 +365,18 @@ $(function() {
$("#updateModal .form input[name='author']").val($(this).parent('p').attr("author"));
$("#updateModal .form input[name='alarmEmail']").val($(this).parent('p').attr("alarmEmail"));
$("#updateModal .form input[name='alarmThreshold']").val($(this).parent('p').attr("alarmThreshold"));
$("#updateModal .form input[name='glueSwitch']").val($(this).parent('p').attr("glueSwitch"));
// GLUE check
var $glueSwitch = $("#updateModal .form input[name='glueSwitch']");
var $handler_name = $("#updateModal .form input[name='handler_name']");
if ($glueSwitch.val() != 0) {
$handler_name.attr("readonly","readonly");
$("#updateModal .form .ifGLUE").attr("checked", true);
} else {
$handler_name.removeAttr("readonly");
$("#updateModal .form .ifGLUE").attr("checked", false);
}
$('#updateModal').modal({backdrop: false, keyboard: false}).modal('show');
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册