执行器移除GlueLoader依赖,GLUE源码改为推送方式;

v1.7
xueli.xue 8 years ago
parent 617ed69727
commit 1b3ad6fbbe

@ -10,7 +10,6 @@ import com.xxl.job.admin.core.thread.JobRegistryHelper;
import com.xxl.job.core.biz.ExecutorBiz;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.biz.model.TriggerParam;
import com.xxl.job.core.glue.GlueTypeEnum;
import com.xxl.job.core.registry.RegistHelper;
import com.xxl.job.core.rpc.netcom.NetComClientProxy;
import org.apache.commons.collections.CollectionUtils;
@ -61,6 +60,7 @@ public class RemoteHttpJobBean extends QuartzJobBean {
triggerParam.setExecutorHandler(jobInfo.getExecutorHandler());
triggerParam.setExecutorParams(jobInfo.getExecutorParam());
triggerParam.setGlueType(jobInfo.getGlueType());
triggerParam.setGlueSource(jobInfo.getGlueSource());
triggerParam.setGlueUpdatetime(jobInfo.getGlueUpdatetime().getTime());
triggerParam.setLogId(jobLog.getId());
triggerParam.setLogDateTim(jobLog.getTriggerTime().getTime());

@ -58,7 +58,6 @@ public class ExecutorBizImpl implements ExecutorBiz {
JobThread jobThread = XxlJobExecutor.loadJobThread(triggerParam.getJobId());
if (GlueTypeEnum.BEAN==GlueTypeEnum.match(triggerParam.getGlueType())) {
// bean model
// valid handler
IJobHandler jobHandler = XxlJobExecutor.loadJobHandler(triggerParam.getExecutorHandler());
@ -80,13 +79,7 @@ public class ExecutorBizImpl implements ExecutorBiz {
jobThread = XxlJobExecutor.registJobThread(triggerParam.getJobId(), jobHandler);
}
} else {
// glue model
// valid glueloader
if (!GlueFactory.isActive()) {
return new ReturnT<String>(ReturnT.FAIL_CODE, "glueLoader for JobId=[" + triggerParam.getJobId() + "] not found.");
}
} else if (GlueTypeEnum.GLUE_GROOVY==GlueTypeEnum.match(triggerParam.getGlueType())) {
// valid exists job threadchange handler or glue timeout, need kill old thread
if (jobThread != null &&
@ -103,7 +96,7 @@ public class ExecutorBizImpl implements ExecutorBiz {
if (jobThread == null) {
IJobHandler jobHandler = null;
try {
jobHandler = GlueFactory.getInstance().loadNewInstance(triggerParam.getJobId());
jobHandler = GlueFactory.getInstance().loadNewInstance(triggerParam.getGlueSource());
} catch (Exception e) {
logger.error("", e);
return new ReturnT<String>(ReturnT.FAIL_CODE, e.getMessage());

@ -15,6 +15,7 @@ public class TriggerParam implements Serializable{
private String executorParams;
private String glueType;
private String glueSource;
private long glueUpdatetime;
private int logId;
@ -54,6 +55,14 @@ public class TriggerParam implements Serializable{
this.glueType = glueType;
}
public String getGlueSource() {
return glueSource;
}
public void setGlueSource(String glueSource) {
this.glueSource = glueSource;
}
public long getGlueUpdatetime() {
return glueUpdatetime;
}

@ -1,6 +1,5 @@
package com.xxl.job.core.glue;
import com.xxl.job.core.glue.loader.GlueLoader;
import com.xxl.job.core.handler.IJobHandler;
import groovy.lang.GroovyClassLoader;
import org.slf4j.Logger;
@ -27,17 +26,6 @@ public class GlueFactory implements ApplicationContextAware {
* groovy class loader
*/
private GroovyClassLoader groovyClassLoader = new GroovyClassLoader();
/**
* code source loader
*/
private GlueLoader glueLoader;
public void setGlueLoader(GlueLoader glueLoader) {
this.glueLoader = glueLoader;
}
public static boolean isActive() {
return GlueFactory.glueFactory.glueLoader!=null;
}
// ----------------------------- spring support -----------------------------
private static ApplicationContext applicationContext;
@ -56,7 +44,7 @@ public class GlueFactory implements ApplicationContextAware {
* inject action of spring
* @param instance
*/
public void injectService(Object instance){
private void injectService(Object instance){
if (instance==null) {
return;
}
@ -106,11 +94,7 @@ public class GlueFactory implements ApplicationContextAware {
// ----------------------------- load instance -----------------------------
// load new instance, prototype
public IJobHandler loadNewInstance(int jobId) throws Exception{
if (jobId==0) {
return null;
}
String codeSource = glueLoader.load(jobId);
public IJobHandler loadNewInstance(String codeSource) throws Exception{
if (codeSource!=null && codeSource.trim().length()>0) {
Class<?> clazz = groovyClassLoader.parseClass(codeSource);
if (clazz != null) {

@ -41,18 +41,9 @@
<!-- ********************************* "GlueFactory" 配置, 仅在启动 "GLUE模式任务" 时才需要, 否则可删除 ********************************* -->
<!-- 配置03、GlueFactory -->
<bean id="glueFactory" class="com.xxl.job.core.glue.GlueFactory">
<!-- GLUE源码加载器默认使用系统提供的 "DbGlueLoader", 推荐将其改为公共的RPC服务 -->
<property name="glueLoader" >
<!-- DbGlueLoader, 依赖 "XXL-JOB公共数据源" -->
<bean class="com.xxl.job.core.glue.loader.impl.DbGlueLoader" >
<!-- XXL-JOB公共数据源 -->
<property name="dataSource" ref="xxlJobDataSource" />
</bean>
</property>
</bean>
<bean id="glueFactory" class="com.xxl.job.core.glue.GlueFactory" />
<!-- ********************************* "XXL-JOB公共数据源" 配置, 仅在启动 "DbRegistHelper" 或 "DbGlueLoader" 时才需要, 否则可删除 ********************************* -->
<!-- ********************************* "XXL-JOB公共数据源" 配置, 仅在启动 "DbRegistHelper" 时才需要, 否则可删除 ********************************* -->
<!-- 配置04、XXL-JOB公共数据源 -->
<bean id="xxlJobDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">

Loading…
Cancel
Save