Bladeren bron

1、底层表结构调整,为脚本任务做准备;

xueli.xue 8 jaren geleden
bovenliggende
commit
548426e9a7

+ 2 - 2
README.md Bestand weergeven

@@ -786,14 +786,14 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
786 786
 #### 6.14 版本 V1.7.0 特性 (Coding)
787 787
 - 1、支持脚本JOB(源码或指定路径), 即shell/python/php等, 日志实时输出并支持在线监控;定制JobHandler实现;
788 788
 
789
+
789 790
 #### TODO LIST
790 791
 - 1、任务并行触发处理规则:串行调度队列(默认)、并行、忽略、覆盖;
791 792
 - 2、任务权限管理;
792 793
 - 3、执行器,server启动,注册逻辑调整;
793 794
 - 4、调度失败重试机制;
794 795
 - 5、JobHandler开启多线程时,支持记录执行日志;
795
-- 6、执行器与数据库解耦,只需配置调度中心集群地址即可;
796
-
796
+- 6、执行器与数据库解耦,只需配置调度中心集群地址即可(与当前通过JDBC注册自动发现方式,相冲突,待考虑);
797 797
 
798 798
 ## 七、其他
799 799
 

+ 4 - 3
db/tables_xxl_job.sql Bestand weergeven

@@ -157,7 +157,7 @@ CREATE TABLE `XXL_JOB_QRTZ_TRIGGER_INFO` (
157 157
   `executor_route_strategy` varchar(50) DEFAULT NULL COMMENT '执行器路由策略',
158 158
   `executor_handler` varchar(255) DEFAULT NULL COMMENT '执行器任务handler',
159 159
   `executor_param` varchar(255) DEFAULT NULL COMMENT '执行器任务参数',
160
-  `glue_switch` int(11) DEFAULT '0' COMMENT 'GLUE模式开关:0-否,1-是',
160
+  `glue_type` varchar(50) NOT NULL COMMENT 'GLUE类型',
161 161
   `glue_source` text COMMENT 'GLUE源代码',
162 162
   `glue_remark` varchar(128) DEFAULT NULL COMMENT 'GLUE备注',
163 163
   `glue_updatetime` datetime DEFAULT NULL COMMENT 'GLUE更新时间',
@@ -184,8 +184,9 @@ CREATE TABLE `XXL_JOB_QRTZ_TRIGGER_LOG` (
184 184
 CREATE TABLE `XXL_JOB_QRTZ_TRIGGER_LOGGLUE` (
185 185
   `id` int(11) NOT NULL AUTO_INCREMENT,
186 186
   `job_id` int(11) NOT NULL COMMENT '任务,主键ID',
187
-  `glue_source` text,
188
-  `glue_remark` varchar(128) NOT NULL,
187
+  `glue_type` varchar(50) DEFAULT NULL COMMENT 'GLUE类型',
188
+  `glue_source` text COMMENT 'GLUE源代码',
189
+  `glue_remark` varchar(128) NOT NULL COMMENT 'GLUE备注',
189 190
   `add_time` timestamp NULL DEFAULT NULL,
190 191
   `update_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
191 192
   PRIMARY KEY (`id`)

+ 1 - 0
xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobCodeController.java Bestand weergeven

@@ -59,6 +59,7 @@ public class JobCodeController {
59 59
 		// log old code
60 60
 		XxlJobLogGlue xxlJobLogGlue = new XxlJobLogGlue();
61 61
 		xxlJobLogGlue.setJobId(exists_jobInfo.getId());
62
+		xxlJobLogGlue.setGlueType(exists_jobInfo.getGlueType());
62 63
 		xxlJobLogGlue.setGlueSource(exists_jobInfo.getGlueSource());
63 64
 		xxlJobLogGlue.setGlueRemark(exists_jobInfo.getGlueRemark());
64 65
 		xxlJobLogGlueDao.save(xxlJobLogGlue);

+ 4 - 0
xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobInfoController.java Bestand weergeven

@@ -6,6 +6,7 @@ import com.xxl.job.admin.core.route.ExecutorRouteStrategyEnum;
6 6
 import com.xxl.job.admin.dao.IXxlJobGroupDao;
7 7
 import com.xxl.job.admin.service.IXxlJobService;
8 8
 import com.xxl.job.core.biz.model.ReturnT;
9
+import com.xxl.job.core.glue.GlueTypeEnum;
9 10
 import org.springframework.stereotype.Controller;
10 11
 import org.springframework.ui.Model;
11 12
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -35,6 +36,9 @@ public class JobInfoController {
35 36
 		// 路由策略-列表
36 37
 		model.addAttribute("ExecutorRouteStrategyEnum", ExecutorRouteStrategyEnum.values());
37 38
 
39
+		// Glue类型-字典
40
+		model.addAttribute("GlueTypeEnum", GlueTypeEnum.values());
41
+
38 42
 		// 任务组
39 43
 		List<XxlJobGroup> jobGroupList =  xxlJobGroupDao.findAll();
40 44
 		model.addAttribute("JobGroupList", jobGroupList);

+ 2 - 1
xxl-job-admin/src/main/java/com/xxl/job/admin/core/jobbean/RemoteHttpJobBean.java Bestand weergeven

@@ -10,6 +10,7 @@ import com.xxl.job.admin.core.thread.JobRegistryHelper;
10 10
 import com.xxl.job.core.biz.ExecutorBiz;
11 11
 import com.xxl.job.core.biz.model.ReturnT;
12 12
 import com.xxl.job.core.biz.model.TriggerParam;
13
+import com.xxl.job.core.glue.GlueTypeEnum;
13 14
 import com.xxl.job.core.registry.RegistHelper;
14 15
 import com.xxl.job.core.rpc.netcom.NetComClientProxy;
15 16
 import org.apache.commons.collections.CollectionUtils;
@@ -59,7 +60,7 @@ public class RemoteHttpJobBean extends QuartzJobBean {
59 60
 		triggerParam.setJobId(jobInfo.getId());
60 61
 		triggerParam.setExecutorHandler(jobInfo.getExecutorHandler());
61 62
 		triggerParam.setExecutorParams(jobInfo.getExecutorParam());
62
-		triggerParam.setGlueSwitch((jobInfo.getGlueSwitch()==0)?false:true);
63
+		triggerParam.setGlueType(jobInfo.getGlueType());
63 64
 		triggerParam.setGlueUpdatetime(jobInfo.getGlueUpdatetime().getTime());
64 65
 		triggerParam.setLogId(jobLog.getId());
65 66
 		triggerParam.setLogDateTim(jobLog.getTriggerTime().getTime());

+ 9 - 9
xxl-job-admin/src/main/java/com/xxl/job/admin/core/model/XxlJobInfo.java Bestand weergeven

@@ -24,15 +24,15 @@ public class XxlJobInfo {
24 24
 	private String executorHandler;		    // 执行器,任务Handler名称
25 25
 	private String executorParam;		    // 执行器,任务参数
26 26
 	
27
-	private int glueSwitch;		// GLUE模式开关:0-否,1-是
28
-	private String glueSource;	// GLUE源代码
29
-	private String glueRemark;	// GLUE备注
30
-	private Date glueUpdatetime;// GLUE更新时间
27
+	private String glueType;		// GLUE类型	#com.xxl.job.core.glue.GlueTypeEnum
28
+	private String glueSource;		// GLUE源代码
29
+	private String glueRemark;		// GLUE备注
30
+	private Date glueUpdatetime;	// GLUE更新时间
31 31
 
32 32
 	private String childJobKey;		// 子任务Key
33 33
 	
34 34
 	// copy from quartz
35
-	private String jobStatus;	// 任务状态 【base on quartz】
35
+	private String jobStatus;		// 任务状态 【base on quartz】
36 36
 
37 37
 	public int getId() {
38 38
 		return id;
@@ -122,12 +122,12 @@ public class XxlJobInfo {
122 122
 		this.executorParam = executorParam;
123 123
 	}
124 124
 
125
-	public int getGlueSwitch() {
126
-		return glueSwitch;
125
+	public String getGlueType() {
126
+		return glueType;
127 127
 	}
128 128
 
129
-	public void setGlueSwitch(int glueSwitch) {
130
-		this.glueSwitch = glueSwitch;
129
+	public void setGlueType(String glueType) {
130
+		this.glueType = glueType;
131 131
 	}
132 132
 
133 133
 	public String getGlueSource() {

+ 9 - 11
xxl-job-admin/src/main/java/com/xxl/job/admin/core/model/XxlJobLogGlue.java Bestand weergeven

@@ -8,6 +8,7 @@ public class XxlJobLogGlue {
8 8
 	
9 9
 	private int id;
10 10
 	private int jobId;				// 任务主键ID
11
+	private String glueType;		// GLUE类型	#com.xxl.job.core.glue.GlueTypeEnum
11 12
 	private String glueSource;
12 13
 	private String glueRemark;
13 14
 	private String addTime;
@@ -29,6 +30,14 @@ public class XxlJobLogGlue {
29 30
 		this.jobId = jobId;
30 31
 	}
31 32
 
33
+	public String getGlueType() {
34
+		return glueType;
35
+	}
36
+
37
+	public void setGlueType(String glueType) {
38
+		this.glueType = glueType;
39
+	}
40
+
32 41
 	public String getGlueSource() {
33 42
 		return glueSource;
34 43
 	}
@@ -61,15 +70,4 @@ public class XxlJobLogGlue {
61 70
 		this.updateTime = updateTime;
62 71
 	}
63 72
 
64
-	@Override
65
-	public String toString() {
66
-		return "XxlJobLogGlue{" +
67
-				"id=" + id +
68
-				", jobId=" + jobId +
69
-				", glueSource='" + glueSource + '\'' +
70
-				", glueRemark='" + glueRemark + '\'' +
71
-				", addTime='" + addTime + '\'' +
72
-				", updateTime='" + updateTime + '\'' +
73
-				'}';
74
-	}
75 73
 }

+ 11 - 3
xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java Bestand weergeven

@@ -8,6 +8,7 @@ import com.xxl.job.admin.core.thread.JobRegistryHelper;
8 8
 import com.xxl.job.admin.dao.*;
9 9
 import com.xxl.job.admin.service.IXxlJobService;
10 10
 import com.xxl.job.core.biz.model.ReturnT;
11
+import com.xxl.job.core.glue.GlueTypeEnum;
11 12
 import com.xxl.job.core.registry.RegistHelper;
12 13
 import org.apache.commons.collections.CollectionUtils;
13 14
 import org.apache.commons.lang.StringUtils;
@@ -84,7 +85,10 @@ public class XxlJobServiceImpl implements IXxlJobService {
84 85
 		if (ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null) == null) {
85 86
 			return new ReturnT<String>(500, "路由策略非法");
86 87
 		}
87
-		if (jobInfo.getGlueSwitch()==0 && StringUtils.isBlank(jobInfo.getExecutorHandler())) {
88
+		if (GlueTypeEnum.match(jobInfo.getGlueType()) == null) {
89
+			return new ReturnT<String>(500, "运行模式非法非法");
90
+		}
91
+		if (GlueTypeEnum.BEAN==GlueTypeEnum.match(jobInfo.getGlueType()) && StringUtils.isBlank(jobInfo.getExecutorHandler())) {
88 92
 			return new ReturnT<String>(500, "请输入“JobHandler”");
89 93
 		}
90 94
 
@@ -147,7 +151,11 @@ public class XxlJobServiceImpl implements IXxlJobService {
147 151
 		if (ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null) == null) {
148 152
 			return new ReturnT<String>(500, "路由策略非法");
149 153
 		}
150
-		if (jobInfo.getGlueSwitch()==0 && StringUtils.isBlank(jobInfo.getExecutorHandler())) {
154
+
155
+		if (GlueTypeEnum.match(jobInfo.getGlueType()) == null) {
156
+			return new ReturnT<String>(500, "运行模式非法非法");
157
+		}
158
+		if (GlueTypeEnum.BEAN==GlueTypeEnum.match(jobInfo.getGlueType()) && StringUtils.isBlank(jobInfo.getExecutorHandler())) {
151 159
 			return new ReturnT<String>(500, "请输入“JobHandler”");
152 160
 		}
153 161
 
@@ -180,7 +188,7 @@ public class XxlJobServiceImpl implements IXxlJobService {
180 188
 		exists_jobInfo.setExecutorRouteStrategy(jobInfo.getExecutorRouteStrategy());
181 189
 		exists_jobInfo.setExecutorHandler(jobInfo.getExecutorHandler());
182 190
 		exists_jobInfo.setExecutorParam(jobInfo.getExecutorParam());
183
-		exists_jobInfo.setGlueSwitch(jobInfo.getGlueSwitch());
191
+		exists_jobInfo.setGlueType(jobInfo.getGlueType());
184 192
 		exists_jobInfo.setChildJobKey(jobInfo.getChildJobKey());
185 193
         xxlJobInfoDao.update(exists_jobInfo);
186 194
 

+ 5 - 5
xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobInfoMapper.xml Bestand weergeven

@@ -20,7 +20,7 @@
20 20
 		<result column="executor_handler" property="executorHandler" />
21 21
 	    <result column="executor_param" property="executorParam" />
22 22
 	    
23
-	    <result column="glue_switch" property="glueSwitch" />
23
+	    <result column="glue_type" property="glueType" />
24 24
 	    <result column="glue_source" property="glueSource" />
25 25
 	    <result column="glue_remark" property="glueRemark" />
26 26
 		<result column="glue_updatetime" property="glueUpdatetime" />
@@ -40,7 +40,7 @@
40 40
 		t.executor_route_strategy,
41 41
 		t.executor_handler,
42 42
 		t.executor_param,
43
-		t.glue_switch,
43
+		t.glue_type,
44 44
 		t.glue_source,
45 45
 		t.glue_remark,
46 46
 		t.glue_updatetime,
@@ -87,7 +87,7 @@
87 87
             executor_route_strategy,
88 88
 			executor_handler,
89 89
 			executor_param,
90
-			glue_switch,
90
+		glue_type,
91 91
 			glue_source,
92 92
 			glue_remark,
93 93
 			glue_updatetime,
@@ -103,7 +103,7 @@
103 103
 			#{executorRouteStrategy},
104 104
 			#{executorHandler},
105 105
 			#{executorParam},
106
-			#{glueSwitch},
106
+			#{glueType},
107 107
 			#{glueSource},
108 108
 			#{glueRemark},
109 109
 			NOW(),
@@ -132,7 +132,7 @@
132 132
 			executor_route_strategy = #{executorRouteStrategy},
133 133
 			executor_handler = #{executorHandler},
134 134
 			executor_param = #{executorParam},
135
-			glue_switch = #{glueSwitch},
135
+			glue_type = #{glueType},
136 136
 			glue_source = #{glueSource},
137 137
 			glue_remark = #{glueRemark},
138 138
 			glue_updatetime = #{glueUpdatetime},

+ 4 - 0
xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogGlueMapper.xml Bestand weergeven

@@ -6,6 +6,7 @@
6 6
 	<resultMap id="XxlJobLogGlue" type="com.xxl.job.admin.core.model.XxlJobLogGlue" >
7 7
 		<result column="id" property="id" />
8 8
 	    <result column="job_id" property="jobId" />
9
+		<result column="glue_type" property="glueType" />
9 10
 	    <result column="glue_source" property="glueSource" />
10 11
 	    <result column="glue_remark" property="glueRemark" />
11 12
 	    <result column="add_time" property="addTime" />
@@ -15,6 +16,7 @@
15 16
 	<sql id="Base_Column_List">
16 17
 		t.id,
17 18
 		t.job_id,
19
+		t.glue_type,
18 20
 		t.glue_source,
19 21
 		t.glue_remark,
20 22
 		t.add_time,
@@ -24,12 +26,14 @@
24 26
 	<insert id="save" parameterType="com.xxl.job.admin.core.model.XxlJobLogGlue" useGeneratedKeys="true" keyProperty="id" >
25 27
 		INSERT INTO XXL_JOB_QRTZ_TRIGGER_LOGGLUE (
26 28
 			`job_id`,
29
+			`glue_type`,
27 30
 			`glue_source`,
28 31
 			`glue_remark`,
29 32
 			`add_time`, 
30 33
 			`update_time`
31 34
 		) VALUES (
32 35
 			#{jobId},
36
+			#{glueType},
33 37
 			#{glueSource},
34 38
 			#{glueRemark},
35 39
 			now(),

+ 27 - 21
xxl-job-admin/src/main/webapp/WEB-INF/template/jobinfo/jobinfo.index.ftl Bestand weergeven

@@ -83,7 +83,7 @@
83 83
 					                  	<th name="updateTime" >更新时间</th>
84 84
 					                  	<th name="author" >负责人</th>
85 85
 					                  	<th name="alarmEmail" >报警邮件</th>
86
-					                  	<th name="glueSwitch" >GLUE模式</th>
86
+					                  	<th name="glueType" >运行模式</th>
87 87
 					                  	<th name="jobStatus" >状态</th>
88 88
 					                  	<th>操作</th>
89 89
 					                </tr>
@@ -136,16 +136,22 @@
136 136
                         <div class="col-sm-4"><input type="text" class="form-control" name="jobCron" placeholder="请输入“Cron”" maxlength="20" ></div>
137 137
                     </div>
138 138
                     <div class="form-group">
139
-                        <label for="firstname" class="col-sm-2 control-label">JobHandler<font color="red">*</font></label>
139
+                        <label for="firstname" class="col-sm-2 control-label">运行模式<font color="red">*</font></label>
140 140
                         <div class="col-sm-4">
141
-                            <div class="input-group">
142
-                                <input type="text" class="form-control" name="executorHandler" placeholder="请输入“JobHandler”" maxlength="100" >
143
-                                <span class="input-group-addon"><b>GLUE</b>&nbsp;<input type="checkbox" class="ifGLUE" ></span>
144
-                                <input type="hidden" name="glueSwitch" value="0" >
145
-                            </div>
141
+                            <select class="form-control glueType" name="glueType" >
142
+								<#list GlueTypeEnum as item>
143
+									<option value="${item}" >${item.desc}</option>
144
+								</#list>
145
+                            </select>
146 146
                         </div>
147
+                        <label for="firstname" class="col-sm-2 control-label">JobHandler<font color="black">*</font></label>
148
+                        <div class="col-sm-4"><input type="text" class="form-control" name="executorHandler" placeholder="请输入“JobHandler”" maxlength="100" ></div>
149
+                    </div>
150
+                    <div class="form-group">
147 151
                         <label for="firstname" class="col-sm-2 control-label">执行参数<font color="black">*</font></label>
148 152
                         <div class="col-sm-4"><input type="text" class="form-control" name="executorParam" placeholder="请输入“执行参数”" maxlength="100" ></div>
153
+                        <label for="lastname" class="col-sm-2 control-label">子任务Key<font color="black">*</font></label>
154
+                        <div class="col-sm-4"><input type="text" class="form-control" name="childJobKey" placeholder="请输入子任务的任务Key,如存在多个逗号分隔" maxlength="100" ></div>
149 155
                     </div>
150 156
 					<div class="form-group">
151 157
 						<label for="lastname" class="col-sm-2 control-label">报警邮件<font color="red">*</font></label>
@@ -153,10 +159,7 @@
153 159
                         <label for="lastname" class="col-sm-2 control-label">负责人<font color="red">*</font></label>
154 160
                         <div class="col-sm-4"><input type="text" class="form-control" name="author" placeholder="请输入“负责人”" maxlength="50" ></div>
155 161
 					</div>
156
-                    <div class="form-group">
157
-                        <label for="lastname" class="col-sm-2 control-label">子任务Key<font color="black">*</font></label>
158
-                        <div class="col-sm-4"><input type="text" class="form-control" name="childJobKey" placeholder="请输入子任务的任务Key,如存在多个逗号分隔" maxlength="100" ></div>
159
-                    </div>
162
+
160 163
                     <hr>
161 164
 					<div class="form-group">
162 165
 						<div class="col-sm-offset-3 col-sm-6">
@@ -227,16 +230,22 @@ public class DemoGlueJobHandler extends IJobHandler {
227 230
                         <div class="col-sm-4"><input type="text" class="form-control" name="jobCron" placeholder="请输入“Cron”" maxlength="20" ></div>
228 231
                     </div>
229 232
                     <div class="form-group">
230
-                        <label for="firstname" class="col-sm-2 control-label">JobHandler<font color="red">*</font></label>
233
+                        <label for="firstname" class="col-sm-2 control-label">运行模式<font color="red">*</font></label>
231 234
                         <div class="col-sm-4">
232
-                            <div class="input-group">
233
-                                <input type="text" class="form-control" name="executorHandler" placeholder="请输入“JobHandler”" maxlength="100" >
234
-                                <span class="input-group-addon"><b>GLUE</b>&nbsp;<input type="checkbox" class="ifGLUE" ></span>
235
-                                <input type="hidden" name="glueSwitch" value="0" >
236
-                            </div>
235
+                            <select class="form-control glueType" name="glueType" >
236
+							<#list GlueTypeEnum as item>
237
+                                <option value="${item}" >${item.desc}</option>
238
+							</#list>
239
+                            </select>
237 240
                         </div>
241
+                        <label for="firstname" class="col-sm-2 control-label">JobHandler<font color="black">*</font></label>
242
+                        <div class="col-sm-4"><input type="text" class="form-control" name="executorHandler" placeholder="请输入“JobHandler”" maxlength="100" ></div>
243
+                    </div>
244
+                    <div class="form-group">
238 245
                         <label for="firstname" class="col-sm-2 control-label">执行参数<font color="black">*</font></label>
239 246
                         <div class="col-sm-4"><input type="text" class="form-control" name="executorParam" placeholder="请输入“执行参数”" maxlength="100" ></div>
247
+                        <label for="lastname" class="col-sm-2 control-label">子任务Key<font color="black">*</font></label>
248
+                        <div class="col-sm-4"><input type="text" class="form-control" name="childJobKey" placeholder="请输入子任务的任务Key,如存在多个逗号分隔" maxlength="100" ></div>
240 249
                     </div>
241 250
                     <div class="form-group">
242 251
                         <label for="lastname" class="col-sm-2 control-label">报警邮件<font color="red">*</font></label>
@@ -244,10 +253,7 @@ public class DemoGlueJobHandler extends IJobHandler {
244 253
                         <label for="lastname" class="col-sm-2 control-label">负责人<font color="red">*</font></label>
245 254
                         <div class="col-sm-4"><input type="text" class="form-control" name="author" placeholder="请输入“负责人”" maxlength="50" ></div>
246 255
                     </div>
247
-                    <div class="form-group">
248
-                        <label for="lastname" class="col-sm-2 control-label">子任务Key<font color="black">*</font></label>
249
-                        <div class="col-sm-4"><input type="text" class="form-control" name="childJobKey" placeholder="请输入子任务的任务Key,如存在多个逗号分隔" maxlength="100" ></div>
250
-                    </div>
256
+
251 257
 					<hr>
252 258
 					<div class="form-group">
253 259
                         <div class="col-sm-offset-3 col-sm-6">

+ 20 - 60
xxl-job-admin/src/main/webapp/static/js/jobinfo.index.1.js Bestand weergeven

@@ -70,7 +70,7 @@ $(function() {
70 70
 	                },
71 71
 	                { "data": 'author', "visible" : true, "width":'10%'},
72 72
 	                { "data": 'alarmEmail', "visible" : false},
73
-	                { "data": 'glueSwitch', "visible" : false},
73
+	                { "data": 'glueType', "visible" : false},
74 74
 	                { 
75 75
 	                	"data": 'jobStatus',
76 76
 						"width":'10%',
@@ -103,7 +103,7 @@ $(function() {
103 103
 	                			
104 104
 	                			// log url
105 105
 	                			var codeBtn = "";
106
-	                			if(row.glueSwitch > 0){
106
+                                if ('BEAN' != row.glueType) {
107 107
 									var codeUrl = base_url +'/jobcode?jobId='+ row.id;
108 108
 									codeBtn = '<button class="btn btn-warning btn-xs" type="button" onclick="javascript:window.open(\'' + codeUrl + '\')" >GLUE</button>  '
109 109
 								}
@@ -118,7 +118,7 @@ $(function() {
118 118
 									' executorRouteStrategy="'+row.executorRouteStrategy +'" '+
119 119
 									' executorHandler="'+row.executorHandler +'" '+
120 120
 									' executorParam="'+ row.executorParam +'" '+
121
-									' glueSwitch="'+ row.glueSwitch +'" '+
121
+									' glueType="'+ row.glueType +'" '+
122 122
                                     ' childJobKey="'+ row.childJobKey +'" '+
123 123
 									'>'+
124 124
 									'<button class="btn btn-primary btn-xs job_operate" type="job_trigger" type="button">执行</button>  '+
@@ -240,9 +240,6 @@ $(function() {
240 240
             jobCron : {
241 241
             	required : true
242 242
             },
243
-			executorHandler : {
244
-				required : false
245
-			},
246 243
             alarmEmail : {
247 244
             	required : true
248 245
             },
@@ -257,9 +254,6 @@ $(function() {
257 254
             jobCron : {
258 255
             	required :"请输入“Cron”."
259 256
             },
260
-			executorHandler : {
261
-				required : "请输入“jobHandler”."
262
-			},
263 257
             alarmEmail : {
264 258
             	required : "请输入“报警邮件”."
265 259
             },
@@ -306,21 +300,20 @@ $(function() {
306 300
 		$("#addModal .form input[name='executorHandler']").removeAttr("readonly");
307 301
 	});
308 302
 
309
-	// GLUE模式开启
310
-	$(".ifGLUE").click(function(){
311
-		var ifGLUE = $(this).is(':checked');
312
-		var $executorHandler = $(this).parents("form").find("input[name='executorHandler']");
313
-		var $glueSwitch = $(this).parents("form").find("input[name='glueSwitch']");
314
-		if (ifGLUE) {
315
-			$executorHandler.val("");
316
-			$executorHandler.attr("readonly","readonly");
317
-			$glueSwitch.val(1);
318
-		} else {
319
-			$executorHandler.removeAttr("readonly");
320
-			$glueSwitch.val(0);
321
-		}
322
-	});
323
-	
303
+
304
+    // GLUE模式开启
305
+    $(".glueType").change(function(){
306
+        var $executorHandler = $(this).parents("form").find("input[name='executorHandler']");
307
+        var glueType = $(this).val();
308
+        console.log(glueType);
309
+        if ('BEAN' != glueType) {
310
+            $executorHandler.val("");
311
+            $executorHandler.attr("readonly","readonly");
312
+        } else {
313
+            $executorHandler.removeAttr("readonly");
314
+        }
315
+    });
316
+
324 317
 	// 更新
325 318
 	$("#job_list").on('click', '.update',function() {
326 319
 
@@ -335,20 +328,10 @@ $(function() {
335 328
 		$("#updateModal .form input[name='executorHandler']").val($(this).parent('p').attr("executorHandler"));
336 329
 		$("#updateModal .form input[name='executorParam']").val($(this).parent('p').attr("executorParam"));
337 330
         $("#updateModal .form input[name='childJobKey']").val($(this).parent('p').attr("childJobKey"));
331
+		$('#updateModal .form select[name=glueType] option[value='+ $(this).parent('p').attr("glueType") +']').prop('selected', true);
338 332
 
339
-        // glueSwitch
340
-		var glueSwitch = $(this).parent('p').attr("glueSwitch");
341
-		$("#updateModal .form input[name='glueSwitch']").val(glueSwitch);
342
-		var $ifGLUE = $("#updateModal .form .ifGLUE");
343
-		var $executorHandler = $("#updateModal .form input[name='executorHandler']");
344
-		if (glueSwitch == 1) {
345
-			$ifGLUE.attr("checked", true);
346
-			$executorHandler.val("");
347
-			$executorHandler.attr("readonly","readonly");
348
-		} else {
349
-			$ifGLUE.attr("checked", false);
350
-			$executorHandler.removeAttr("readonly");
351
-		}
333
+
334
+        $("#updateModal .form select[name=glueType]").change();
352 335
 
353 336
 		// show
354 337
 		$('#updateModal').modal({backdrop: false, keyboard: false}).modal('show');
@@ -366,9 +349,6 @@ $(function() {
366 349
 			jobCron : {
367 350
 				required : true
368 351
 			},
369
-			executorHandler : {
370
-				required : false
371
-			},
372 352
 			alarmEmail : {
373 353
 				required : true
374 354
 			},
@@ -383,9 +363,6 @@ $(function() {
383 363
 			jobCron : {
384 364
 				required :"请输入“Cron”."
385 365
 			},
386
-			executorHandler : {
387
-				required : "请输入“jobHandler”."
388
-			},
389 366
 			alarmEmail : {
390 367
 				required : "请输入“报警邮件”."
391 368
 			},
@@ -428,21 +405,4 @@ $(function() {
428 405
 		$("#updateModal .form")[0].reset()
429 406
 	});
430 407
 
431
-
432
-	/*
433
-	// 新增-添加参数
434
-	$("#addModal .addParam").on('click', function () {
435
-		var html = '<div class="form-group newParam">'+
436
-				'<label for="lastname" class="col-sm-2 control-label">参数&nbsp;<button class="btn btn-danger btn-xs removeParam" type="button">移除</button></label>'+
437
-				'<div class="col-sm-4"><input type="text" class="form-control" name="key" placeholder="请输入参数key[将会强转为String]" maxlength="200" /></div>'+
438
-				'<div class="col-sm-6"><input type="text" class="form-control" name="value" placeholder="请输入参数value[将会强转为String]" maxlength="200" /></div>'+
439
-			'</div>';
440
-		$(this).parents('.form-group').parent().append(html);
441
-		
442
-		$("#addModal .removeParam").on('click', function () {
443
-			$(this).parents('.form-group').remove();
444
-		});
445
-	});
446
-	*/
447
-
448 408
 });

+ 2 - 1
xxl-job-core/src/main/java/com/xxl/job/core/biz/impl/ExecutorBizImpl.java Bestand weergeven

@@ -6,6 +6,7 @@ import com.xxl.job.core.biz.model.ReturnT;
6 6
 import com.xxl.job.core.biz.model.TriggerParam;
7 7
 import com.xxl.job.core.executor.XxlJobExecutor;
8 8
 import com.xxl.job.core.glue.GlueFactory;
9
+import com.xxl.job.core.glue.GlueTypeEnum;
9 10
 import com.xxl.job.core.handler.IJobHandler;
10 11
 import com.xxl.job.core.handler.impl.GlueJobHandler;
11 12
 import com.xxl.job.core.log.XxlJobFileAppender;
@@ -56,7 +57,7 @@ public class ExecutorBizImpl implements ExecutorBiz {
56 57
         // load old thread
57 58
         JobThread jobThread = XxlJobExecutor.loadJobThread(triggerParam.getJobId());
58 59
 
59
-        if (!triggerParam.isGlueSwitch()) {
60
+        if (GlueTypeEnum.BEAN==GlueTypeEnum.match(triggerParam.getGlueType())) {
60 61
             // bean model
61 62
 
62 63
             // valid handler

+ 5 - 5
xxl-job-core/src/main/java/com/xxl/job/core/biz/model/TriggerParam.java Bestand weergeven

@@ -14,7 +14,7 @@ public class TriggerParam implements Serializable{
14 14
     private String executorHandler;
15 15
     private String executorParams;
16 16
 
17
-    private boolean glueSwitch;
17
+    private String glueType;
18 18
     private long glueUpdatetime;
19 19
 
20 20
     private int logId;
@@ -46,12 +46,12 @@ public class TriggerParam implements Serializable{
46 46
         this.executorParams = executorParams;
47 47
     }
48 48
 
49
-    public boolean isGlueSwitch() {
50
-        return glueSwitch;
49
+    public String getGlueType() {
50
+        return glueType;
51 51
     }
52 52
 
53
-    public void setGlueSwitch(boolean glueSwitch) {
54
-        this.glueSwitch = glueSwitch;
53
+    public void setGlueType(String glueType) {
54
+        this.glueType = glueType;
55 55
     }
56 56
 
57 57
     public long getGlueUpdatetime() {

+ 29 - 0
xxl-job-core/src/main/java/com/xxl/job/core/glue/GlueTypeEnum.java Bestand weergeven

@@ -0,0 +1,29 @@
1
+package com.xxl.job.core.glue;
2
+
3
+/**
4
+ * Created by xuxueli on 17/4/26.
5
+ */
6
+public enum GlueTypeEnum {
7
+
8
+    BEAN("BEAN模式"),
9
+    GLUE_GROOVY("GLUE模式(Java)"),
10
+    GLUE_SHELL("GLUE模式(Shell)"),
11
+    GLUE_PYTHON("GLUE模式(Python)");
12
+
13
+    private String desc;
14
+    private GlueTypeEnum(String desc) {
15
+        this.desc = desc;
16
+    }
17
+    public String getDesc() {
18
+        return desc;
19
+    }
20
+
21
+    public static GlueTypeEnum match(String name){
22
+        for (GlueTypeEnum item: GlueTypeEnum.values()) {
23
+            if (item.name().equals(name)) {
24
+                return item;
25
+            }
26
+        }
27
+        return null;
28
+    }
29
+}

+ 3 - 0
xxl-job-core/src/main/java/com/xxl/job/core/thread/JobThread.java Bestand weergeven

@@ -107,6 +107,9 @@ public class JobThread extends Thread{
107 107
 					}
108 108
 				}
109 109
 			} catch (Exception e) {
110
+				if (toStop) {
111
+					logger.error("----------- xxl-job toStop, stopReason:{}", stopReason);
112
+				}
110 113
 				logger.error("----------- xxl-job JobThread Exception:", e);
111 114
 			}
112 115
 		}