自测问题修复
This commit is contained in:
parent
e2affe4487
commit
b55f5b529c
@ -12,8 +12,5 @@ import java.lang.annotation.*;
|
||||
@Indexed
|
||||
@Component
|
||||
public @interface Plugin {
|
||||
@AliasFor("value")
|
||||
String taskType() default "";
|
||||
@AliasFor("taskType")
|
||||
String value() default "";
|
||||
String taskType();
|
||||
}
|
||||
|
@ -50,8 +50,8 @@ public class DefaultRunContextManager implements RunContextManager {
|
||||
PipBaseElement contextDef = context.getContextDef();
|
||||
String id = contextDef.getId();
|
||||
BaseRunContext parentContext = context.getParentContext();
|
||||
if (context instanceof PipelineRunContext) {
|
||||
contextMap.put(id,(PipelineRunContext)context);
|
||||
if (context instanceof PipelineRunContext pipelineRunContext) {
|
||||
contextMap.put(id,pipelineRunContext);
|
||||
} else {
|
||||
if (parentContext==null) {
|
||||
throw new ServiceException(GlobalErrorCodeConstants.PIPELINE_ERROR.getCode(),"注册context失败");
|
||||
|
@ -16,6 +16,7 @@ import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
|
||||
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
import org.springframework.core.type.filter.AnnotationTypeFilter;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -57,7 +58,7 @@ public class DefaultWorkerManager extends AbstractRedisStreamMessageListener<Tas
|
||||
if (bean instanceof BaseWorker worker) {
|
||||
Plugin annotation = worker.getClass().getAnnotation(Plugin.class);
|
||||
String taskType = annotation.taskType();
|
||||
if (StringUtils.isEmpty(taskType)) {
|
||||
if (StringUtils.isNotEmpty(taskType)) {
|
||||
taskTypeWorkerMap.put(taskType,worker);
|
||||
}
|
||||
}
|
||||
|
@ -35,10 +35,13 @@ public class PipelineRunContext extends BaseRunContext{
|
||||
* pipeline 底下有多个阶段,多个阶段包含多个task 不保存第二级context
|
||||
* */
|
||||
@Override
|
||||
public BaseRunContext getRunContext(String stageId) {
|
||||
public BaseRunContext getRunContext(String id) {
|
||||
if (this.getContextDef().getId().equals(id)) {
|
||||
return this;
|
||||
}
|
||||
Map<String, BaseRunContext> childContext = getChildContext();
|
||||
for (Map.Entry<String, BaseRunContext> entry : childContext.entrySet()) {
|
||||
BaseRunContext childRunContext = entry.getValue().getRunContext(stageId);
|
||||
BaseRunContext childRunContext = entry.getValue().getRunContext(id);
|
||||
if (childRunContext!=null) {
|
||||
return childRunContext;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import cd.casic.ci.process.process.dataObject.base.PipBaseElement;
|
||||
import cd.casic.ci.process.process.dataObject.stage.PipStage;
|
||||
import cd.casic.framework.commons.exception.ServiceException;
|
||||
import cd.casic.framework.commons.exception.enums.GlobalErrorCodeConstants;
|
||||
import cd.casic.framework.commons.util.collection.CollectionUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
@ -11,17 +12,17 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class SecondStageRunContext extends BaseRunContext{
|
||||
public SecondStageRunContext(PipStage contextDef, PipelineRunContext parentContext, Map<String, Object> localVariables) {
|
||||
super(contextDef, parentContext, LocalDateTime.now(), parentContext.getResourceId(), parentContext.getTargetId(), parentContext.getTargetType(), parentContext.getGlobalVariables(), localVariables, new ConcurrentHashMap<>(contextDef.getStageList().size()));
|
||||
super(contextDef, parentContext, LocalDateTime.now(), parentContext.getResourceId(), parentContext.getTargetId(), parentContext.getTargetType(), parentContext.getGlobalVariables(), localVariables, new ConcurrentHashMap<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseRunContext getRunContext(String taskId) {
|
||||
if (this.getContextDef().getId().equals(taskId)) {
|
||||
public BaseRunContext getRunContext(String id) {
|
||||
if (this.getContextDef().getId().equals(id)) {
|
||||
return this;
|
||||
}
|
||||
Map<String, BaseRunContext> childContext = getChildContext();
|
||||
for (Map.Entry<String, BaseRunContext> entry : childContext.entrySet()) {
|
||||
BaseRunContext childRunContext = entry.getValue().getRunContext(taskId);
|
||||
BaseRunContext childRunContext = entry.getValue().getRunContext(id);
|
||||
if (childRunContext!=null) {
|
||||
return childRunContext;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
|
||||
@Data
|
||||
|
||||
public abstract class BaseWorker implements Runnable{
|
||||
// 一些属性
|
||||
@Resource
|
||||
|
@ -9,7 +9,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Plugin("testTask")
|
||||
@Plugin(taskType = "testTask")
|
||||
public class TestWorker extends BaseWorker{
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user