GLUE任务调度时,执行器校验是否支持GLUE模式任务,校验GlueFactory的glueloader是否存在;

v1.5
xueli.xue 8 years ago
parent 2acaf0c284
commit 552949167e

@ -43,6 +43,9 @@ public class GlueFactory implements ApplicationContextAware {
public void setGlueLoader(GlueLoader glueLoader) { public void setGlueLoader(GlueLoader glueLoader) {
this.glueLoader = glueLoader; this.glueLoader = glueLoader;
} }
public static boolean isActive() {
return GlueFactory.glueFactory.glueLoader!=null;
}
// ----------------------------- spring support ----------------------------- // ----------------------------- spring support -----------------------------
private static ApplicationContext applicationContext; private static ApplicationContext applicationContext;
@ -122,7 +125,7 @@ public class GlueFactory implements ApplicationContextAware {
} }
// // load instance, singleton // // load instance, singleton
public static String generateInstanceCacheKey(String job_group, String job_name){ private static String generateInstanceCacheKey(String job_group, String job_name){
return job_group.concat("_").concat(job_name).concat("_instance"); return job_group.concat("_").concat(job_name).concat("_instance");
} }
public IJobHandler loadInstance(String job_group, String job_name) throws Exception{ public IJobHandler loadInstance(String job_group, String job_name) throws Exception{

@ -1,5 +1,6 @@
package com.xxl.job.core.router.action; package com.xxl.job.core.router.action;
import com.xxl.job.core.glue.GlueFactory;
import com.xxl.job.core.handler.IJobHandler; import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.impl.GlueJobHandler; import com.xxl.job.core.handler.impl.GlueJobHandler;
import com.xxl.job.core.router.HandlerRouter; import com.xxl.job.core.router.HandlerRouter;
@ -25,7 +26,7 @@ public class RunAction extends IAction {
if (!requestModel.isGlueSwitch()) { if (!requestModel.isGlueSwitch()) {
// bean model // bean model
// handler instance // valid handler instance
IJobHandler jobHandler = HandlerRouter.loadJobHandler(requestModel.getExecutorHandler()); IJobHandler jobHandler = HandlerRouter.loadJobHandler(requestModel.getExecutorHandler());
if (jobHandler==null) { if (jobHandler==null) {
return new ResponseModel(ResponseModel.FAIL, "job handler for jobKey=[" + jobKey + "] not found."); return new ResponseModel(ResponseModel.FAIL, "job handler for jobKey=[" + jobKey + "] not found.");
@ -46,6 +47,12 @@ public class RunAction extends IAction {
} }
} else { } else {
// glue model // glue model
// valid glueloader
if (!GlueFactory.isActive()) {
return new ResponseModel(ResponseModel.FAIL, "glueLoader for jobKey=[" + jobKey + "] not found.");
}
if (jobThread == null) { if (jobThread == null) {
jobThread = HandlerRouter.registJobThread(jobKey, new GlueJobHandler(requestModel.getJobGroup(), requestModel.getJobName())); jobThread = HandlerRouter.registJobThread(jobKey, new GlueJobHandler(requestModel.getJobGroup(), requestModel.getJobName()));
} else { } else {

@ -16,8 +16,9 @@
<property name="port" value="9999" /> <property name="port" value="9999" />
</bean> </bean>
<!-- glue factory -->
<bean id="glueFactory" class="com.xxl.job.core.glue.GlueFactory"> <bean id="glueFactory" class="com.xxl.job.core.glue.GlueFactory">
<property name="cacheTimeout" value="5000" /> <property name="cacheTimeout" value="10000" />
<property name="glueLoader" ref="dbGlueLoader" /> <!-- GLUE 代码加载器推荐将该服务配置成RPC服务 --> <property name="glueLoader" ref="dbGlueLoader" /> <!-- GLUE 代码加载器推荐将该服务配置成RPC服务 -->
</bean> </bean>

Loading…
Cancel
Save