mirror of
https://github.com/PowerJob/PowerJob.git
synced 2025-07-17 00:00:04 +08:00
feat: log full stack info when can't fetch processor #134
This commit is contained in:
parent
0de6a9f4f5
commit
12162f2955
@ -1,15 +1,15 @@
|
|||||||
package com.github.kfcfans.powerjob.worker.common.utils;
|
package com.github.kfcfans.powerjob.worker.common.utils;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spring ApplicationContext 工具类
|
* Spring ApplicationContext 工具类
|
||||||
*
|
*
|
||||||
* @author tjq
|
* @author tjq
|
||||||
* @since 2020/3/16
|
* @since 2020/3/16
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public class SpringUtils {
|
public class SpringUtils {
|
||||||
|
|
||||||
private static boolean supportSpringBean = false;
|
private static boolean supportSpringBean = false;
|
||||||
@ -43,7 +43,9 @@ public class SpringUtils {
|
|||||||
// 小写转大写
|
// 小写转大写
|
||||||
char[] cs = beanName.toCharArray();
|
char[] cs = beanName.toCharArray();
|
||||||
cs[0] += 32;
|
cs[0] += 32;
|
||||||
return (T) context.getBean(String.valueOf(cs));
|
String beanName0 = String.valueOf(cs);
|
||||||
|
log.warn("[SpringUtils] can't get ClassLoader from context[{}], try to load by beanName:{}", context, beanName0);
|
||||||
|
return (T) context.getBean(beanName0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.github.kfcfans.powerjob.worker.core;
|
|||||||
import com.github.kfcfans.powerjob.worker.core.processor.sdk.BasicProcessor;
|
import com.github.kfcfans.powerjob.worker.core.processor.sdk.BasicProcessor;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -37,7 +38,8 @@ public class ProcessorBeanFactory {
|
|||||||
return (BasicProcessor) clz.getDeclaredConstructor().newInstance();
|
return (BasicProcessor) clz.getDeclaredConstructor().newInstance();
|
||||||
|
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
log.warn("[ProcessorBeanFactory] load local Processor(className = {}) failed, reason is {}", className, e.getMessage());
|
log.warn("[ProcessorBeanFactory] load local Processor(className = {}) failed.", className, e);
|
||||||
|
ExceptionUtils.rethrow(e);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
@ -24,6 +24,7 @@ import com.github.kfcfans.powerjob.worker.core.processor.sdk.BasicProcessor;
|
|||||||
import com.google.common.collect.Queues;
|
import com.google.common.collect.Queues;
|
||||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -96,10 +97,10 @@ public class ProcessorTracker {
|
|||||||
initProcessor();
|
initProcessor();
|
||||||
|
|
||||||
log.info("[ProcessorTracker-{}] ProcessorTracker was successfully created!", instanceId);
|
log.info("[ProcessorTracker-{}] ProcessorTracker was successfully created!", instanceId);
|
||||||
}catch (Throwable e) {
|
} catch (Throwable t) {
|
||||||
log.warn("[ProcessorTracker-{}] create ProcessorTracker failed, all tasks submitted here will fail.", instanceId, e);
|
log.warn("[ProcessorTracker-{}] create ProcessorTracker failed, all tasks submitted here will fail.", instanceId, t);
|
||||||
lethal = true;
|
lethal = true;
|
||||||
lethalReason = e.toString();
|
lethalReason = ExceptionUtils.getMessage(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,7 +292,7 @@ public class ProcessorTracker {
|
|||||||
try {
|
try {
|
||||||
processor = SpringUtils.getBean(processorInfo);
|
processor = SpringUtils.getBean(processorInfo);
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
log.warn("[ProcessorTracker-{}] no spring bean of processor(className={}), reason is {}.", instanceId, processorInfo, e.toString());
|
log.warn("[ProcessorTracker-{}] no spring bean of processor(className={}), reason is {}.", instanceId, processorInfo, ExceptionUtils.getMessage(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 反射加载
|
// 反射加载
|
||||||
|
Loading…
x
Reference in New Issue
Block a user