任务编辑界面交互调整

v1.4
xueli.xue 8 years ago
parent f7ff804739
commit 23bd08bf36

@ -193,11 +193,7 @@ public class DemoJobHandler extends IJobHandler {
<div class="form-group"> <div class="form-group">
<label for="firstname" class="col-sm-2 control-label">分组<font color="red">*</font></label> <label for="firstname" class="col-sm-2 control-label">分组<font color="red">*</font></label>
<div class="col-sm-4"> <div class="col-sm-4">
<select class="form-control" name="jobGroupTitle" disabled> <input type="text" class="form-control" name="jobGroupTitle" maxlength="50" readonly >
<#list JobGroupList as group>
<option value="${group}" >${group.desc}</option>
</#list>
</select>
<input type="hidden" name="jobGroup" > <input type="hidden" name="jobGroup" >
<input type="hidden" name="jobName" > <input type="hidden" name="jobName" >
</div> </div>
@ -226,13 +222,12 @@ public class DemoJobHandler extends IJobHandler {
<div class="form-group"> <div class="form-group">
<label for="firstname" class="col-sm-2 control-label">任务模式<font color="red">*</font></label> <label for="firstname" class="col-sm-2 control-label">任务模式<font color="red">*</font></label>
<div class="col-sm-4"> <div class="col-sm-4">
<select class="form-control" name="glueSwitch" disabled > <input type="text" class="form-control" name="glueSwitchTitle" readonly >
<option value="0" >BEAN模式</option>
<option value="1" >GLUE模式</option>
</select>
</div> </div>
<label for="lastname" class="col-sm-2 control-label">JobKey</label> <label for="lastname" class="col-sm-2 control-label">JobKey</label>
<div class="col-sm-4"><input type="text" class="form-control" name="jobKey" placeholder="请输入“jobHandler”" readonly ></div> <div class="col-sm-4">
<input type="text" class="form-control" name="jobKey" placeholder="请输入“jobHandler”" readonly >
</div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-sm-offset-3 col-sm-6"> <div class="col-sm-offset-3 col-sm-6">

@ -303,25 +303,23 @@ $(function() {
$("#updateModal .form input[name='alarmThreshold']").val($(this).parent('p').attr("alarmThreshold")); $("#updateModal .form input[name='alarmThreshold']").val($(this).parent('p').attr("alarmThreshold"));
// job group selected // job group selected
$("#updateModal .form select[name='jobGroupTitle']").find("option[value='" + $(this).parent('p').attr("jobGroup") + "']").attr("selected",true); var jobGroupTitle = $("#addModal .form select[name='jobGroup']").find("option[value='" + $(this).parent('p').attr("jobGroup") + "']").text();
$("#updateModal .form input[name='jobGroupTitle']").val(jobGroupTitle);
// job group selected // glueSwitch and jobKey
$("#updateModal .form select[name='glueSwitch']").find("option[value='" + $(this).parent('p').attr("glueSwitch") + "']").attr("selected",true); var glueSwitchTitle;
var jobKey;
// generate job key if ($(this).parent('p').attr("glueSwitch") == 0) {
$("#updateModal .form input[name='jobKey']").val( $(this).parent('p').attr("jobGroup") + "_" + $(this).parent('p').attr("jobName") ); glueSwitchTitle = "BEAN模式";
jobKey = $(this).parent('p').attr("jobGroup") + "_" + $(this).parent('p').attr("jobName");
// GLUE check
var $glueSwitch = $("#updateModal .form input[name='glueSwitch']");
var $executorHandler = $("#updateModal .form input[name='executorHandler']");
if ($glueSwitch.val() != 0) {
$executorHandler.attr("readonly","readonly");
$("#updateModal .form .ifGLUE").attr("checked", true);
} else { } else {
$executorHandler.removeAttr("readonly"); glueSwitchTitle = "GLUE模式";
$("#updateModal .form .ifGLUE").attr("checked", false); jobKey = "无";
} }
$("#updateModal .form input[name='glueSwitchTitle']").val(glueSwitchTitle);
$("#updateModal .form input[name='jobKey']").val(jobKey);
// show
$('#updateModal').modal({backdrop: false, keyboard: false}).modal('show'); $('#updateModal').modal({backdrop: false, keyboard: false}).modal('show');
}); });
var updateModalValidate = $("#updateModal .form").validate({ var updateModalValidate = $("#updateModal .form").validate({

@ -1,6 +1,6 @@
package com.xxl.job.core.executor.jetty; package com.xxl.job.core.executor.jetty;
import java.util.Map; import java.util.*;
import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Handler;
@ -88,10 +88,15 @@ public class XxlJobExecutor implements ApplicationContextAware {
Map<String, Object> serviceBeanMap = XxlJobExecutor.applicationContext.getBeansWithAnnotation(JobHander.class); Map<String, Object> serviceBeanMap = XxlJobExecutor.applicationContext.getBeansWithAnnotation(JobHander.class);
if (serviceBeanMap!=null && serviceBeanMap.size()>0) { if (serviceBeanMap!=null && serviceBeanMap.size()>0) {
for (Object serviceBean : serviceBeanMap.values()) { for (Object serviceBean : serviceBeanMap.values()) {
String jobName = serviceBean.getClass().getAnnotation(JobHander.class).value(); if (serviceBean instanceof IJobHandler){
if (jobName!=null && jobName.trim().length()>0 && serviceBean instanceof IJobHandler) { String jobKeys = serviceBean.getClass().getAnnotation(JobHander.class).value();
if (jobKeys!=null && jobKeys.trim().length()>0) {
Set<String> jobKeySet = new HashSet<String>(Arrays.asList(jobKeys.split(",")));
for (String jobKey : jobKeySet) {
IJobHandler handler = (IJobHandler) serviceBean; IJobHandler handler = (IJobHandler) serviceBean;
HandlerRepository.regist(jobName, handler); HandlerRepository.regist(jobKey, handler);
}
}
} }
} }
} }

@ -102,7 +102,6 @@ public class HandlerRepository {
callback.setMsg("JOB_GROUP or JOB_NAME is null."); callback.setMsg("JOB_GROUP or JOB_NAME is null.");
return JacksonUtil.writeValueAsString(callback); return JacksonUtil.writeValueAsString(callback);
} }
String jobKey = job_group.concat("_").concat(job_name);
// glue switch // glue switch
String handler_glue_switch = _param.get(HandlerParamEnum.GLUE_SWITCH.name()); String handler_glue_switch = _param.get(HandlerParamEnum.GLUE_SWITCH.name());
@ -111,7 +110,8 @@ public class HandlerRepository {
return JacksonUtil.writeValueAsString(callback); return JacksonUtil.writeValueAsString(callback);
} }
HandlerThread handlerThread = handlerTreadMap.get(jobKey);; String jobKey = job_group.concat("_").concat(job_name);
HandlerThread handlerThread = handlerTreadMap.get(jobKey);
if ("0".equals(handler_glue_switch)) { if ("0".equals(handler_glue_switch)) {
// bean model // bean model
if (handlerThread == null) { if (handlerThread == null) {
@ -129,27 +129,6 @@ public class HandlerRepository {
// push data to queue // push data to queue
handlerThread.pushData(_param); handlerThread.pushData(_param);
callback.setStatus(RemoteCallBack.SUCCESS); callback.setStatus(RemoteCallBack.SUCCESS);
} else if (namespace.equals(ActionEnum.LOG.name())) {
String log_id = _param.get(HandlerParamEnum.LOG_ID.name());
String log_date = _param.get(HandlerParamEnum.LOG_DATE.name());
if (log_id==null || log_date==null) {
callback.setMsg("LOG_ID | LOG_DATE can not be null.");
return JacksonUtil.writeValueAsString(callback);
}
int logId = -1;
Date triggerDate = null;
try {
logId = Integer.valueOf(log_id);
triggerDate = new Date(Long.valueOf(log_date));
} catch (Exception e) {
}
if (logId<=0 || triggerDate==null) {
callback.setMsg("LOG_ID | LOG_DATE parse error.");
return JacksonUtil.writeValueAsString(callback);
}
String logConteng = XxlJobFileAppender.readLog(triggerDate, log_id);
callback.setStatus(RemoteCallBack.SUCCESS);
callback.setMsg(logConteng);
} else if (namespace.equals(ActionEnum.KILL.name())) { } else if (namespace.equals(ActionEnum.KILL.name())) {
// generate jobKey // generate jobKey
String job_group = _param.get(HandlerParamEnum.JOB_GROUP.name()); String job_group = _param.get(HandlerParamEnum.JOB_GROUP.name());
@ -172,6 +151,27 @@ public class HandlerRepository {
callback.setMsg("handler for jobKey=[" + jobKey + "] not found."); callback.setMsg("handler for jobKey=[" + jobKey + "] not found.");
} }
} else if (namespace.equals(ActionEnum.LOG.name())) {
String log_id = _param.get(HandlerParamEnum.LOG_ID.name());
String log_date = _param.get(HandlerParamEnum.LOG_DATE.name());
if (log_id==null || log_date==null) {
callback.setMsg("LOG_ID | LOG_DATE can not be null.");
return JacksonUtil.writeValueAsString(callback);
}
int logId = -1;
Date triggerDate = null;
try {
logId = Integer.valueOf(log_id);
triggerDate = new Date(Long.valueOf(log_date));
} catch (Exception e) {
}
if (logId<=0 || triggerDate==null) {
callback.setMsg("LOG_ID | LOG_DATE parse error.");
return JacksonUtil.writeValueAsString(callback);
}
String logConteng = XxlJobFileAppender.readLog(triggerDate, log_id);
callback.setStatus(RemoteCallBack.SUCCESS);
callback.setMsg(logConteng);
} else if (namespace.equals(ActionEnum.BEAT.name())) { } else if (namespace.equals(ActionEnum.BEAT.name())) {
callback.setStatus(RemoteCallBack.SUCCESS); callback.setStatus(RemoteCallBack.SUCCESS);
callback.setMsg(null); callback.setMsg(null);

@ -16,11 +16,11 @@ import com.xxl.job.core.handler.annotation.JobHander;
* *
* 1 IJobHandler * 1 IJobHandler
* 2Spring @Service * 2Spring @Service
* 3 @JobHander namename使 * 3 @JobHander valueJobKey;JobKey;
* *
* @author xuxueli 2015-12-19 19:43:36 * @author xuxueli 2015-12-19 19:43:36
*/ */
@JobHander(value="defaults_201607192222270796") @JobHander(value="defaults_201607192256270689,defaults_201607192256270689")
@Service @Service
public class DemoJobHandler extends IJobHandler { public class DemoJobHandler extends IJobHandler {
private static transient Logger logger = LoggerFactory.getLogger(DemoJobHandler.class); private static transient Logger logger = LoggerFactory.getLogger(DemoJobHandler.class);

Loading…
Cancel
Save