这是能够编译的,主要模块是process , work , dispatch
This commit is contained in:
parent
800c441aa5
commit
a92027c25e
180
.idea/CopilotChatHistory.xml
generated
180
.idea/CopilotChatHistory.xml
generated
File diff suppressed because one or more lines are too long
8
.idea/compiler.xml
generated
8
.idea/compiler.xml
generated
@ -22,6 +22,8 @@
|
||||
<module name="module-ci-environment" />
|
||||
<module name="spring-boot-starter-monitor" />
|
||||
<module name="module-system-biz" />
|
||||
<module name="module-ci-process-biz" />
|
||||
<module name="module-ci-dispatch-api" />
|
||||
<module name="module-system-api" />
|
||||
<module name="spring-boot-starter-mq" />
|
||||
<module name="module-ci-quality" />
|
||||
@ -47,7 +49,6 @@
|
||||
<module name="module-ci-event" />
|
||||
<module name="module-ci-repository" />
|
||||
<module name="spring-boot-starter-web" />
|
||||
<module name="module-ci-common" />
|
||||
<module name="spring-boot-starter-excel" />
|
||||
<module name="spring-boot-starter-biz-tenant" />
|
||||
<module name="module-ci-ticket" />
|
||||
@ -61,8 +62,8 @@
|
||||
<module name="ci-common-public" target="17" />
|
||||
<module name="common-pipeline" target="17" />
|
||||
<module name="common-public" target="17" />
|
||||
<module name="module-ci-common" target="17" />
|
||||
<module name="module-ci-commons" target="17" />
|
||||
<module name="module-ci-process" target="17" />
|
||||
<module name="pipeline-ci-api" target="17" />
|
||||
<module name="pipeline-ci-common" target="17" />
|
||||
<module name="pipeline-ci-process-api" target="17" />
|
||||
@ -82,12 +83,13 @@
|
||||
<module name="module-ci-common" options="-parameters" />
|
||||
<module name="module-ci-common-pipeline" options="-parameters" />
|
||||
<module name="module-ci-commons" options="-parameters" />
|
||||
<module name="module-ci-dispatch-api" options="-parameters" />
|
||||
<module name="module-ci-environment" options="-parameters" />
|
||||
<module name="module-ci-event" options="-parameters" />
|
||||
<module name="module-ci-log" options="-parameters" />
|
||||
<module name="module-ci-market" options="-parameters" />
|
||||
<module name="module-ci-process" options="-parameters" />
|
||||
<module name="module-ci-process-api" options="-parameters" />
|
||||
<module name="module-ci-process-biz" options="-parameters" />
|
||||
<module name="module-ci-project" options="-parameters" />
|
||||
<module name="module-ci-quality" options="-parameters" />
|
||||
<module name="module-ci-repository" options="-parameters" />
|
||||
|
14
.idea/encodings.xml
generated
14
.idea/encodings.xml
generated
@ -53,6 +53,8 @@
|
||||
<file url="file://$PROJECT_DIR$/modules/module-ci-commons/pipline-ci-common/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/modules/module-ci-commons/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/modules/module-ci-commons/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/modules/module-ci-dispatch-api/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/modules/module-ci-dispatch-api/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/modules/module-ci-environment/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/modules/module-ci-environment/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/modules/module-ci-event/src/main/java" charset="UTF-8" />
|
||||
@ -63,12 +65,12 @@
|
||||
<file url="file://$PROJECT_DIR$/modules/module-ci-market/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/modules/module-ci-process-api/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/modules/module-ci-process-api/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/modules/module-ci-process/pipeline-ci-common/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/modules/module-ci-process/pipeline-ci-common/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/modules/module-ci-process/pipeline-ci-process-api/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/modules/module-ci-process/pipeline-ci-process-api/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/modules/module-ci-process/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/modules/module-ci-process/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/modules/module-ci-process-biz/pipeline-ci-common/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/modules/module-ci-process-biz/pipeline-ci-common/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/modules/module-ci-process-biz/pipeline-ci-process-api/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/modules/module-ci-process-biz/pipeline-ci-process-api/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/modules/module-ci-process-biz/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/modules/module-ci-process-biz/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/modules/module-ci-project/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/modules/module-ci-project/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/modules/module-ci-quality/src/main/java" charset="UTF-8" />
|
||||
|
6
.idea/misc.xml
generated
6
.idea/misc.xml
generated
@ -28,8 +28,8 @@
|
||||
</component>
|
||||
<component name="FrameworkDetectionExcludesConfiguration">
|
||||
<file type="web" url="file://$PROJECT_DIR$/modules/module-ci-commons/pipeline-ci-common" />
|
||||
<file type="web" url="file://$PROJECT_DIR$/modules/module-ci-process/ci-process-api" />
|
||||
<file type="web" url="file://$PROJECT_DIR$/modules/module-ci-process/ci-process-base" />
|
||||
<file type="web" url="file://$PROJECT_DIR$/modules/module-ci-process-biz/ci-process-api" />
|
||||
<file type="web" url="file://$PROJECT_DIR$/modules/module-ci-process-biz/ci-process-base" />
|
||||
</component>
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
@ -55,12 +55,12 @@
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$/modules/ci-commons/pipeline-ci-api/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/modules/ci-commons/pipline-ci-common/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/modules/module-ci-common/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/modules/module-ci-commons/ci-common-pipeline/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/modules/module-ci-commons/ci-common-public/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/modules/module-ci-commons/ci-common/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/modules/module-ci-commons/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/modules/module-ci-process/pipeline-ci-process-api/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/modules/module-ci-process/pom.xml" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
|
10
dependencies/.flattened-pom.xml
vendored
10
dependencies/.flattened-pom.xml
vendored
@ -195,11 +195,6 @@
|
||||
<artifactId>module-system-biz</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cd.casic.boot</groupId>
|
||||
<artifactId>module-ci-common</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cd.casic.boot</groupId>
|
||||
<artifactId>module-ci-common-pipeline</artifactId>
|
||||
@ -260,6 +255,11 @@
|
||||
<artifactId>module-ci-worker</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cd.casic.pipeline</groupId>
|
||||
<artifactId>module-ci-dispatch-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.mouzt</groupId>
|
||||
<artifactId>bizlog-sdk</artifactId>
|
||||
|
12
dependencies/pom.xml
vendored
12
dependencies/pom.xml
vendored
@ -220,12 +220,6 @@
|
||||
</dependency>
|
||||
<!--ci-pipeline-dependency-->
|
||||
|
||||
<dependency>
|
||||
<groupId>cd.casic.boot</groupId>
|
||||
<artifactId>module-ci-common</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cd.casic.boot</groupId>
|
||||
<artifactId>module-ci-common-pipeline</artifactId>
|
||||
@ -298,6 +292,12 @@
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cd.casic.pipeline</groupId>
|
||||
<artifactId>module-ci-dispatch-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!---->
|
||||
<dependency>
|
||||
<groupId>io.github.mouzt</groupId>
|
||||
|
@ -17,7 +17,23 @@
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cd.casic.boot</groupId>
|
||||
<artifactId>module-ci-common</artifactId>
|
||||
<artifactId>commons</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cd.casic.boot</groupId>
|
||||
<artifactId>spring-boot-starter-mybatis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.networknt</groupId>
|
||||
<artifactId>json-schema-validator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cd.casic.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
package cd.casic.ci.common.pipeline;
|
||||
|
||||
import cd.casic.ci.common.functions.ExpressionOutput;
|
||||
import cd.casic.ci.common.functions.IFunctionInfo;
|
||||
import cd.casic.ci.common.pojo.NamedValueInfo;
|
||||
import cd.casic.ci.common.pipeline.functions.ExpressionOutput;
|
||||
import cd.casic.ci.common.pipeline.functions.IFunctionInfo;
|
||||
import cd.casic.ci.common.pipeline.pojo.NamedValueInfo;
|
||||
import cd.casic.ci.common.pipeline.dialect.IPipelineDialect;
|
||||
import cd.casic.ci.common.pipeline.utils.ObjectReplaceEnvVarUtil;
|
||||
import cn.hutool.core.lang.Pair;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package cd.casic.ci.common.pipeline;
|
||||
|
||||
import cd.casic.ci.common.functions.ExpressionOutput;
|
||||
import cd.casic.ci.common.functions.IFunctionInfo;
|
||||
import cd.casic.ci.common.pojo.NamedValueInfo;
|
||||
import cd.casic.ci.common.pipeline.functions.ExpressionOutput;
|
||||
import cd.casic.ci.common.pipeline.functions.IFunctionInfo;
|
||||
import cd.casic.ci.common.pipeline.pojo.NamedValueInfo;
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import com.networknt.schema.ExecutionContext;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.constant;
|
||||
package cd.casic.ci.common.pipeline.constant;
|
||||
|
||||
/**
|
||||
* @Classname BaseConstant
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.constant;
|
||||
package cd.casic.ci.common.pipeline.constant;
|
||||
|
||||
/**
|
||||
* @Author:mianbin
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.constant;
|
||||
package cd.casic.ci.common.pipeline.constant;
|
||||
|
||||
/**
|
||||
* @Author:mianbin
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.constant;
|
||||
package cd.casic.ci.common.pipeline.constant;
|
||||
|
||||
/**
|
||||
* @Author:mianbin
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.constant;
|
||||
package cd.casic.ci.common.pipeline.constant;
|
||||
|
||||
/**
|
||||
* @Classname LeafAllocConstant
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.constant;
|
||||
package cd.casic.ci.common.pipeline.constant;
|
||||
|
||||
|
||||
/**
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.constant;
|
||||
package cd.casic.ci.common.pipeline.constant;
|
||||
|
||||
/**
|
||||
* @Author:mianbin
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.constant;
|
||||
package cd.casic.ci.common.pipeline.constant;
|
||||
|
||||
/**
|
||||
* @Author:mianbin
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.constant;
|
||||
package cd.casic.ci.common.pipeline.constant;
|
||||
|
||||
/**
|
||||
* @author by mianbin
|
@ -1,6 +1,6 @@
|
||||
package cd.casic.ci.common.pipeline.container;
|
||||
|
||||
import cd.casic.ci.common.pipeline.type.agent.AgentType;
|
||||
import cd.casic.ci.common.pipeline.pojo.agent.AgentType;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.enums;
|
||||
package cd.casic.ci.common.pipeline.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.enums;
|
||||
package cd.casic.ci.common.pipeline.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.enums;
|
||||
package cd.casic.ci.common.pipeline.enums;
|
||||
|
||||
/**
|
||||
* @Classname StyleEnum
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.enums;
|
||||
package cd.casic.ci.common.pipeline.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.enums;
|
||||
package cd.casic.ci.common.pipeline.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.enums;
|
||||
package cd.casic.ci.common.pipeline.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.enums;
|
||||
package cd.casic.ci.common.pipeline.enums;
|
||||
|
||||
import cd.casic.framework.commons.core.IntArrayValuable;
|
||||
import lombok.AllArgsConstructor;
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.enums;
|
||||
package cd.casic.ci.common.pipeline.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.enums;
|
||||
package cd.casic.ci.common.pipeline.enums;
|
||||
|
||||
import cd.casic.framework.commons.core.IntArrayValuable;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.enums;
|
||||
package cd.casic.ci.common.pipeline.enums;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.enums;
|
||||
package cd.casic.ci.common.pipeline.enums;
|
||||
|
||||
/**
|
||||
* @Author:mianbin
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.enums;
|
||||
package cd.casic.ci.common.pipeline.enums;
|
||||
|
||||
/**
|
||||
* @author by mianbin
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.enums;
|
||||
package cd.casic.ci.common.pipeline.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.enums;
|
||||
package cd.casic.ci.common.pipeline.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.enums;
|
||||
package cd.casic.ci.common.pipeline.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.enums;
|
||||
package cd.casic.ci.common.pipeline.enums;
|
||||
|
||||
import cd.casic.framework.commons.exception.ServerException;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.enums;
|
||||
package cd.casic.ci.common.pipeline.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.enums;
|
||||
package cd.casic.ci.common.pipeline.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.enums;
|
||||
package cd.casic.ci.common.pipeline.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.enums;
|
||||
package cd.casic.ci.common.pipeline.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.enums;
|
||||
package cd.casic.ci.common.pipeline.enums;
|
||||
|
||||
|
||||
/**
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.enums;
|
||||
package cd.casic.ci.common.pipeline.enums;
|
||||
|
||||
/**
|
||||
* @author mianbin
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.enums;
|
||||
package cd.casic.ci.common.pipeline.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.enums;
|
||||
package cd.casic.ci.common.pipeline.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.enums;
|
||||
package cd.casic.ci.common.pipeline.enums;
|
||||
|
||||
import cd.casic.framework.commons.core.IntArrayValuable;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.functions;
|
||||
package cd.casic.ci.common.pipeline.functions;
|
||||
|
||||
/**
|
||||
* @author by mianbin
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.functions;
|
||||
package cd.casic.ci.common.pipeline.functions;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.functions;
|
||||
package cd.casic.ci.common.pipeline.functions;
|
||||
|
||||
/**
|
||||
* @author by mianbin
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.functions;
|
||||
package cd.casic.ci.common.pipeline.functions;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
|
@ -1,5 +1,5 @@
|
||||
package cd.casic.ci.common.pipeline.matrix;
|
||||
import cd.casic.ci.common.utils.YamlUtil;
|
||||
import cd.casic.ci.common.pipeline.utils.YamlUtil;
|
||||
import cd.casic.ci.common.pipeline.utils.MatrixContextUtils;
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.pojo;
|
||||
package cd.casic.ci.common.pipeline.pojo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
@ -1,7 +1,7 @@
|
||||
package cd.casic.ci.common.pipeline.pojo;
|
||||
|
||||
import cd.casic.ci.common.enums.ScmType;
|
||||
import cd.casic.ci.common.pipeline.enums.BuildFormPropertyType;
|
||||
import cd.casic.ci.common.pipeline.enums.ScmType;
|
||||
import cd.casic.ci.common.pipeline.pojo.cascade.BuildCascadeProps;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.pojo;
|
||||
package cd.casic.ci.common.pipeline.pojo;
|
||||
|
||||
/**
|
||||
* @author by mianbin
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.pojo;
|
||||
package cd.casic.ci.common.pipeline.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
@ -1,6 +1,6 @@
|
||||
package cd.casic.ci.common.pojo;
|
||||
package cd.casic.ci.common.pipeline.pojo;
|
||||
|
||||
import cd.casic.ci.common.functions.INamedValueInfo;
|
||||
import cd.casic.ci.common.pipeline.functions.INamedValueInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.pojo;
|
||||
package cd.casic.ci.common.pipeline.pojo;
|
||||
|
||||
/**
|
||||
* @author by mianbin
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.pojo;
|
||||
package cd.casic.ci.common.pipeline.pojo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.pojo;
|
||||
package cd.casic.ci.common.pipeline.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
@ -0,0 +1,34 @@
|
||||
package cd.casic.ci.common.pipeline.pojo.agent;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author by mianbin
|
||||
* @Classname AgentArchType
|
||||
* @Description TODO
|
||||
* @Date 2025/4/8 19:25
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum AgentArchType {
|
||||
ARM64("arm64"),
|
||||
MIPS64("mips64"),
|
||||
AMD64("amd64");
|
||||
|
||||
private final String arch;
|
||||
|
||||
public static AgentArchType parse(String arch) {
|
||||
if (AMD64.arch.equals(arch)) {
|
||||
return AMD64;
|
||||
}
|
||||
if (ARM64.arch.equals(arch)) {
|
||||
return ARM64;
|
||||
}
|
||||
if (MIPS64.arch.equals(arch)) {
|
||||
return MIPS64;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
package cd.casic.ci.common.pipeline.pojo.agent;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author by mianbin
|
||||
* @Classname AgentErrorExitData
|
||||
* @Description TODO
|
||||
* @Date 2025/4/8 19:27
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class AgentErrorExitData {
|
||||
private final String errorEnum;
|
||||
private final String message;
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package cd.casic.ci.common.pipeline.pojo.agent;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author by mianbin
|
||||
* @Classname AgentPropsInfo
|
||||
* @Description TODO
|
||||
* @Date 2025/4/8 19:28
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "Agent属性信息")
|
||||
public class AgentPropsInfo {
|
||||
@Schema(description = "agent运行系统的架构信息")
|
||||
private String arch;
|
||||
|
||||
@Schema(description = "jdk版本信息")
|
||||
private List<String> jdkVersion;
|
||||
|
||||
@Schema(description = "docker init 文件升级信息")
|
||||
private DockerInitFileInfo dockerInitFileInfo;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.pipeline.type.agent;
|
||||
package cd.casic.ci.common.pipeline.pojo.agent;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
@ -0,0 +1,25 @@
|
||||
package cd.casic.ci.common.pipeline.pojo.agent;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* @author by mianbin
|
||||
* @Classname Credential
|
||||
* @Description TODO
|
||||
* @Date 2025/4/8 16:30
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class Credential {
|
||||
private String user;
|
||||
private String password;
|
||||
private String credentialId;
|
||||
private String acrossTemplateId;
|
||||
private String jobId;
|
||||
private String credentialProjectId;
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package cd.casic.ci.common.pipeline.pojo.agent;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author by mianbin
|
||||
* @Classname DockerInitFileInfo
|
||||
* @Description TODO
|
||||
* @Date 2025/4/8 19:30
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "docker init 文件升级信息")
|
||||
public class DockerInitFileInfo {
|
||||
@Schema(description = "文件md5值")
|
||||
private String fileMd5;
|
||||
@Schema(description = "目前只支持linux机器,所以其他系统不需要检查")
|
||||
private boolean needUpgrade;
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package cd.casic.ci.common.pipeline.pojo.agent;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author by mianbin
|
||||
* @Classname DockerOptions
|
||||
* @Description TODO
|
||||
* @Date 2025/4/8 16:30
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class DockerOptions {
|
||||
private List<String> volumes;
|
||||
private List<String> mounts;
|
||||
private String gpus;
|
||||
private Boolean privileged;
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
package cd.casic.ci.common.pipeline.pojo.agent;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.assertj.core.util.Lists;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author by mianbin
|
||||
* @Classname NewHeartbeatInfo
|
||||
* @Description TODO
|
||||
* @Date 2025/4/8 19:31
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "心跳信息模型")
|
||||
public class NewHeartbeatInfo {
|
||||
@Schema(description = "主版本")
|
||||
private String masterVersion;
|
||||
@Schema(description = "从属版本")
|
||||
private String slaveVersion;
|
||||
@Schema(description = "主机名")
|
||||
private String hostName;
|
||||
@Schema(description = "构建机模型")
|
||||
private String agentIp;
|
||||
@Schema(description = "并行任务计数")
|
||||
private int parallelTaskCount;
|
||||
@Schema(description = "构建机安装路径")
|
||||
private String agentInstallPath;
|
||||
@Schema(description = "启动者")
|
||||
private String startedUser;
|
||||
@Schema(description = "第三方构建信息列表")
|
||||
private List<ThirdPartyBuildInfo> taskList;
|
||||
@Schema(description = "Agent属性信息")
|
||||
private AgentPropsInfo props;
|
||||
@Schema(description = "构建机id")
|
||||
private Long agentId;
|
||||
@Schema(description = "项目id")
|
||||
private String projectId;
|
||||
@Schema(description = "心跳时间戳")
|
||||
private Long heartbeatTime;
|
||||
@Schema(description = "忙碌运行中任务数量")
|
||||
@Builder.Default
|
||||
private int busyTaskSize = 0;
|
||||
@Schema(description = "docker并行任务计数")
|
||||
private Integer dockerParallelTaskCount;
|
||||
@Schema(description = "docker构建信息列表")
|
||||
private List<ThirdPartyDockerBuildInfo> dockerTaskList;
|
||||
@Schema(description = "忙碌运行docker中任务数量")
|
||||
@Builder.Default
|
||||
private int dockerBusyTaskSize = 0;
|
||||
@Schema(description = "Agent退出的错误信息")
|
||||
private AgentErrorExitData errorExitData;
|
||||
|
||||
public static NewHeartbeatInfo dummyHeartbeat(String projectId, Long agentId) {
|
||||
return NewHeartbeatInfo.builder()
|
||||
.masterVersion("")
|
||||
.slaveVersion("")
|
||||
.hostName("")
|
||||
.agentIp("")
|
||||
.parallelTaskCount(0)
|
||||
.agentInstallPath("")
|
||||
.startedUser("")
|
||||
.taskList(Lists.emptyList())
|
||||
.props(new AgentPropsInfo("", null, null))
|
||||
.agentId(agentId)
|
||||
.projectId(projectId)
|
||||
.heartbeatTime(System.currentTimeMillis())
|
||||
.dockerParallelTaskCount(0)
|
||||
.dockerTaskList(List.of())
|
||||
.build();
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.pipeline.type.agent;
|
||||
package cd.casic.ci.common.pipeline.pojo.agent;
|
||||
|
||||
import cd.casic.ci.common.pipeline.type.DispatchType;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.pipeline.type.agent;
|
||||
package cd.casic.ci.common.pipeline.pojo.agent;
|
||||
|
||||
import cd.casic.ci.common.pipeline.type.docker.ImageType;
|
||||
import cd.casic.ci.common.pipeline.utils.EnvUtils;
|
||||
@ -7,7 +7,6 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -54,59 +53,3 @@ public class ThirdPartyAgentDockerInfo {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
class Credential {
|
||||
private String user;
|
||||
private String password;
|
||||
private String credentialId;
|
||||
private String acrossTemplateId;
|
||||
private String jobId;
|
||||
private String credentialProjectId;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
class DockerOptions {
|
||||
private List<String> volumes;
|
||||
private List<String> mounts;
|
||||
private String gpus;
|
||||
private Boolean privileged;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
class ThirdPartyAgentDockerInfoStoreImage {
|
||||
private String imageName;
|
||||
private String imageCode;
|
||||
private String imageVersion;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
class ThirdPartyAgentDockerInfoDispatch {
|
||||
private String agentId;
|
||||
private String secretKey;
|
||||
private String image;
|
||||
private Credential credential;
|
||||
private DockerOptions options;
|
||||
private String imagePullPolicy;
|
||||
|
||||
public ThirdPartyAgentDockerInfoDispatch(String agentId, String secretKey, ThirdPartyAgentDockerInfo info) {
|
||||
this.agentId = agentId;
|
||||
this.secretKey = secretKey;
|
||||
this.image = info.getImage();
|
||||
this.credential = info.getCredential();
|
||||
this.options = info.getOptions();
|
||||
this.imagePullPolicy = info.getImagePullPolicy();
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package cd.casic.ci.common.pipeline.pojo.agent;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* @author by mianbin
|
||||
* @Classname ThirdPartyAgentDockerInfoDispatch
|
||||
* @Description TODO
|
||||
* @Date 2025/4/8 16:31
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class ThirdPartyAgentDockerInfoDispatch {
|
||||
private String agentId;
|
||||
private String secretKey;
|
||||
private String image;
|
||||
private Credential credential;
|
||||
private DockerOptions options;
|
||||
private String imagePullPolicy;
|
||||
|
||||
public ThirdPartyAgentDockerInfoDispatch(String agentId, String secretKey, ThirdPartyAgentDockerInfo info) {
|
||||
this.agentId = agentId;
|
||||
this.secretKey = secretKey;
|
||||
this.image = info.getImage();
|
||||
this.credential = info.getCredential();
|
||||
this.options = info.getOptions();
|
||||
this.imagePullPolicy = info.getImagePullPolicy();
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package cd.casic.ci.common.pipeline.pojo.agent;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* @author by mianbin
|
||||
* @Classname ThirdPartyAgentDockerInfoStoreImage
|
||||
* @Description TODO
|
||||
* @Date 2025/4/8 16:31
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class ThirdPartyAgentDockerInfoStoreImage {
|
||||
private String imageName;
|
||||
private String imageCode;
|
||||
private String imageVersion;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.pipeline.type.agent;
|
||||
package cd.casic.ci.common.pipeline.pojo.agent;
|
||||
|
||||
import cd.casic.ci.common.pipeline.type.BuildType;
|
||||
import cd.casic.ci.common.pipeline.utils.EnvUtils;
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.pipeline.type.agent;
|
||||
package cd.casic.ci.common.pipeline.pojo.agent;
|
||||
|
||||
import cd.casic.ci.common.pipeline.type.BuildType;
|
||||
import cd.casic.ci.common.pipeline.utils.EnvUtils;
|
@ -0,0 +1,27 @@
|
||||
package cd.casic.ci.common.pipeline.pojo.agent;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author by mianbin
|
||||
* @Classname ThirdPartyAgentUpgradeByVersionInfo
|
||||
* @Description TODO
|
||||
* @Date 2025/4/9 10:58
|
||||
*/
|
||||
@Data
|
||||
public class ThirdPartyAgentUpgradeByVersionInfo {
|
||||
@Schema(description = "worker版本")
|
||||
private String workerVersion;
|
||||
|
||||
@Schema(description = "go agent 版本")
|
||||
private String goAgentVersion;
|
||||
|
||||
@Schema(description = "jdk版本")
|
||||
private List<String> jdkVersion;
|
||||
|
||||
@Schema(description = "docker init 文件升级信息")
|
||||
private DockerInitFileInfo dockerInitFileInfo;
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package cd.casic.ci.common.pipeline.pojo.agent;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author by mianbin
|
||||
* @Classname ThirdPartyBuildInfo
|
||||
* @Description TODO
|
||||
* @Date 2025/4/8 19:41
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "第三方构建信息")
|
||||
public class ThirdPartyBuildInfo {
|
||||
@Schema(description = "项目id")
|
||||
private String projectId;
|
||||
@Schema(description = "构建id")
|
||||
private String buildId;
|
||||
@Schema(description = "构建机编排序号")
|
||||
private String vmSeqId;
|
||||
@Schema(description = "工作空间")
|
||||
private String workspace;
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package cd.casic.ci.common.pipeline.pojo.agent;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author by mianbin
|
||||
* @Classname ThirdPartyDockerBuildInfo
|
||||
* @Description TODO
|
||||
* @Date 2025/4/8 19:42
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "第三方构建Docker信息")
|
||||
public class ThirdPartyDockerBuildInfo {
|
||||
@Schema(description = "项目id")
|
||||
private String projectId;
|
||||
@Schema(description = "构建id")
|
||||
private String buildId;
|
||||
@Schema(description = "构建机编排序号")
|
||||
private String vmSeqId;
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package cd.casic.ci.common.pipeline.pojo.agent;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author by mianbin
|
||||
* @Classname UpgradeItem
|
||||
* @Description TODO
|
||||
* @Date 2025/4/8 19:42
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "需要升级的项")
|
||||
public class UpgradeItem {
|
||||
@Schema(description = "升级go agent")
|
||||
private boolean agent;
|
||||
|
||||
@Schema(description = "升级worker")
|
||||
private boolean worker;
|
||||
|
||||
@Schema(description = "升级jdk")
|
||||
private boolean jdk;
|
||||
|
||||
@Schema(description = "升级docker init 脚本")
|
||||
private boolean dockerInitFile;
|
||||
}
|
@ -1,9 +1,8 @@
|
||||
package cd.casic.ci.common.pipeline.pojo.cascade;
|
||||
|
||||
import cd.casic.ci.common.enums.ScmType;
|
||||
import cd.casic.ci.common.pipeline.enums.BuildFormPropertyType;
|
||||
import cd.casic.ci.common.pipeline.enums.ScmType;
|
||||
import cd.casic.ci.common.pipeline.pojo.BuildFormValue;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@ -20,7 +19,7 @@ import java.util.stream.Collectors;
|
||||
* @Filename:RepoRefCascadeParam
|
||||
* @description:Todo
|
||||
*/
|
||||
@Data
|
||||
|
||||
public class RepoRefCascadeParam extends CascadeParam {
|
||||
public static final String SELECTOR_KEY_REPO_NAME = "repo-name";
|
||||
public static final String SELECTOR_KEY_BRANCH = "branch";
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cd.casic.ci.common.pipeline.pojo.element.agent;
|
||||
|
||||
import cd.casic.ci.common.enums.RepositoryType;
|
||||
import cd.casic.ci.common.pipeline.enums.CodePullStrategy;
|
||||
import cd.casic.ci.common.pipeline.enums.RepositoryType;
|
||||
import cd.casic.ci.common.pipeline.pojo.element.Element;
|
||||
import cd.casic.ci.common.pipeline.pojo.git.GitPullMode;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cd.casic.ci.common.pipeline.pojo.element.agent;
|
||||
|
||||
import cd.casic.ci.common.enums.RepositoryType;
|
||||
import cd.casic.ci.common.pipeline.enums.CodePullStrategy;
|
||||
import cd.casic.ci.common.pipeline.enums.RepositoryType;
|
||||
import cd.casic.ci.common.pipeline.pojo.element.Element;
|
||||
import cd.casic.ci.common.pipeline.pojo.git.GitPullMode;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cd.casic.ci.common.pipeline.pojo.element.agent;
|
||||
|
||||
import cd.casic.ci.common.enums.RepositoryType;
|
||||
import cd.casic.ci.common.pipeline.enums.CodePullStrategy;
|
||||
import cd.casic.ci.common.pipeline.enums.RepositoryType;
|
||||
import cd.casic.ci.common.pipeline.enums.SVNVersion;
|
||||
import cd.casic.ci.common.pipeline.enums.SvnDepth;
|
||||
import cd.casic.ci.common.pipeline.pojo.element.Element;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cd.casic.ci.common.pipeline.pojo.element.agent;
|
||||
|
||||
import cd.casic.ci.common.enums.RepositoryType;
|
||||
import cd.casic.ci.common.pipeline.enums.CodePullStrategy;
|
||||
import cd.casic.ci.common.pipeline.enums.RepositoryType;
|
||||
import cd.casic.ci.common.pipeline.pojo.element.Element;
|
||||
import cd.casic.ci.common.pipeline.pojo.git.GitPullMode;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
|
@ -9,7 +9,7 @@ import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static cd.casic.ci.common.constant.CommonConstants.*;
|
||||
import static cd.casic.ci.common.pipeline.constant.CommonConstants.*;
|
||||
|
||||
/**
|
||||
* @Author:mianbin
|
||||
|
@ -8,8 +8,8 @@ import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static cd.casic.ci.common.constant.CommonConstants.KEY_ELEMENT_ENABLE;
|
||||
import static cd.casic.ci.common.constant.CommonConstants.KEY_TASK_ATOM;
|
||||
import static cd.casic.ci.common.pipeline.constant.CommonConstants.KEY_ELEMENT_ENABLE;
|
||||
import static cd.casic.ci.common.pipeline.constant.CommonConstants.KEY_TASK_ATOM;
|
||||
|
||||
/**
|
||||
* @Author:mianbin
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cd.casic.ci.common.pipeline.pojo.element.trigger;
|
||||
|
||||
import cd.casic.ci.common.enums.TriggerRepositoryType;
|
||||
import cd.casic.ci.common.pipeline.enums.StartType;
|
||||
import cd.casic.ci.common.pipeline.enums.TriggerRepositoryType;
|
||||
import cd.casic.ci.common.pipeline.pojo.element.ElementProp;
|
||||
import cd.casic.ci.common.pipeline.pojo.element.trigger.enums.CodeEventType;
|
||||
import cd.casic.ci.common.pipeline.pojo.element.trigger.enums.PathFilterType;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cd.casic.ci.common.pipeline.pojo.element.trigger;
|
||||
|
||||
import cd.casic.ci.common.enums.TriggerRepositoryType;
|
||||
import cd.casic.ci.common.pipeline.enums.StartType;
|
||||
import cd.casic.ci.common.pipeline.enums.TriggerRepositoryType;
|
||||
import cd.casic.ci.common.pipeline.pojo.element.trigger.enums.CodeEventType;
|
||||
import cd.casic.ci.common.pipeline.pojo.element.trigger.enums.PathFilterType;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cd.casic.ci.common.pipeline.pojo.element.trigger;
|
||||
|
||||
import cd.casic.ci.common.enums.TriggerRepositoryType;
|
||||
import cd.casic.ci.common.pipeline.enums.StartType;
|
||||
import cd.casic.ci.common.pipeline.enums.TriggerRepositoryType;
|
||||
import cd.casic.ci.common.pipeline.pojo.element.ElementProp;
|
||||
import cd.casic.ci.common.pipeline.pojo.element.trigger.enums.CodeEventType;
|
||||
import cd.casic.ci.common.pipeline.pojo.element.trigger.enums.PathFilterType;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cd.casic.ci.common.pipeline.pojo.element.trigger;
|
||||
|
||||
import cd.casic.ci.common.enums.TriggerRepositoryType;
|
||||
import cd.casic.ci.common.pipeline.enums.StartType;
|
||||
import cd.casic.ci.common.pipeline.enums.TriggerRepositoryType;
|
||||
import cd.casic.ci.common.pipeline.pojo.element.ElementProp;
|
||||
import cd.casic.ci.common.pipeline.pojo.element.trigger.enums.CodeEventType;
|
||||
import cd.casic.ci.common.pipeline.utils.TriggerElementPropUtils;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cd.casic.ci.common.pipeline.pojo.element.trigger;
|
||||
|
||||
import cd.casic.ci.common.enums.TriggerRepositoryType;
|
||||
import cd.casic.ci.common.pipeline.enums.StartType;
|
||||
import cd.casic.ci.common.pipeline.enums.TriggerRepositoryType;
|
||||
import cd.casic.ci.common.pipeline.pojo.element.ElementProp;
|
||||
import cd.casic.ci.common.pipeline.pojo.element.trigger.enums.PathFilterType;
|
||||
import cd.casic.ci.common.pipeline.utils.TriggerElementPropUtils;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cd.casic.ci.common.pipeline.pojo.element.trigger;
|
||||
|
||||
import cd.casic.ci.common.enums.TriggerRepositoryType;
|
||||
import cd.casic.ci.common.pipeline.enums.StartType;
|
||||
import cd.casic.ci.common.pipeline.enums.TriggerRepositoryType;
|
||||
import cd.casic.ci.common.pipeline.pojo.element.ElementProp;
|
||||
import cd.casic.ci.common.pipeline.pojo.element.trigger.enums.CodeEventType;
|
||||
import cd.casic.ci.common.pipeline.pojo.element.trigger.enums.PathFilterType;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cd.casic.ci.common.pipeline.pojo.element.trigger;
|
||||
|
||||
import cd.casic.ci.common.enums.TriggerRepositoryType;
|
||||
import cd.casic.ci.common.pipeline.enums.StartType;
|
||||
import cd.casic.ci.common.pipeline.enums.TriggerRepositoryType;
|
||||
import cd.casic.ci.common.pipeline.pojo.element.Element;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.experimental.Accessors;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cd.casic.ci.common.pipeline.pojo.element.trigger.enums;
|
||||
|
||||
import cd.casic.ci.common.enums.ScmType;
|
||||
|
||||
import cd.casic.ci.common.pipeline.enums.ScmType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package cd.casic.ci.common.pipeline.pojo.setting;
|
||||
|
||||
import cd.casic.ci.common.pojo.PipelineAsCodeSettings;
|
||||
import cd.casic.ci.common.pipeline.pojo.PipelineAsCodeSettings;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cd.casic.ci.common.pipeline.type;
|
||||
|
||||
|
||||
import cd.casic.ci.common.pojo.OS;
|
||||
import cd.casic.ci.common.pipeline.pojo.OS;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cd.casic.ci.common.pipeline.type;
|
||||
|
||||
import cd.casic.ci.common.pipeline.type.agent.ThirdPartyAgentEnvDispatchType;
|
||||
import cd.casic.ci.common.pipeline.type.agent.ThirdPartyAgentIDDispatchType;
|
||||
import cd.casic.ci.common.pipeline.pojo.agent.ThirdPartyAgentEnvDispatchType;
|
||||
import cd.casic.ci.common.pipeline.pojo.agent.ThirdPartyAgentIDDispatchType;
|
||||
import cd.casic.ci.common.pipeline.type.docker.DockerDispatchType;
|
||||
import cd.casic.ci.common.pipeline.type.kubernetes.KubernetesDispatchType;
|
||||
import cd.casic.ci.common.pipeline.utils.EnvUtils;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package cd.casic.ci.common.pipeline.utils;
|
||||
|
||||
import cd.casic.ci.common.utils.YamlUtil;
|
||||
import cd.casic.framework.commons.exception.ServerException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cd.casic.ci.common.utils;
|
||||
package cd.casic.ci.common.pipeline.utils;
|
||||
|
||||
import cd.casic.framework.commons.util.reflect.ReflectUtil;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
@ -1,15 +0,0 @@
|
||||
package cd.casic.ci.common.operationid;
|
||||
|
||||
import cd.casic.ci.common.operationid.entity.LeafAlloc;
|
||||
import cd.casic.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author by mianbin
|
||||
* @Classname LeafAllocMapper
|
||||
* @Description TODO
|
||||
* @Date 2025/3/19 10:41
|
||||
*/
|
||||
@Mapper
|
||||
public interface LeafAllocMapper extends BaseMapperX<LeafAlloc> {
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package cd.casic.ci.common.operationid;
|
||||
|
||||
|
||||
import cd.casic.ci.common.operationid.entity.LeafAlloc;
|
||||
|
||||
import java.util.List;
|
||||
/**
|
||||
* @author by mianbin
|
||||
* @Classname LeafAllocService
|
||||
* @Description TODO
|
||||
* @Date 2025/3/19 10:41
|
||||
*/
|
||||
public interface LeafAllocService {
|
||||
|
||||
List<LeafAlloc> getAllLeafAllocs();
|
||||
|
||||
LeafAlloc updateMaxIdAndGetLeafAlloc(String key);
|
||||
|
||||
LeafAlloc updateMaxIdByCustomStepAndGetLeafAlloc(LeafAlloc leafAlloc);
|
||||
|
||||
List<String> getAllKeys();
|
||||
|
||||
boolean create(LeafAlloc leafAlloc);
|
||||
|
||||
boolean update(LeafAlloc leafAlloc);
|
||||
|
||||
boolean batchCreate(List<LeafAlloc> leafAllocs);
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
package cd.casic.ci.common.operationid;
|
||||
|
||||
|
||||
import cd.casic.ci.common.operationid.entity.LeafAlloc;
|
||||
import cd.casic.framework.commons.exception.ServiceException;
|
||||
import cd.casic.framework.commons.exception.enums.GlobalErrorCodeConstants;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author by mianbin
|
||||
* @Classname LeafAllocServiceImpl
|
||||
* @Description TODO
|
||||
* @Date 2025/3/19 10:41
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class LeafAllocServiceImpl implements LeafAllocService {
|
||||
|
||||
@Resource
|
||||
private LeafAllocMapper leafAllocMapper;
|
||||
|
||||
@Override
|
||||
public List<LeafAlloc> getAllLeafAllocs() {
|
||||
List<LeafAlloc> leafAllocs = leafAllocMapper.selectList();
|
||||
return CollUtil.emptyIfNull(leafAllocs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LeafAlloc updateMaxIdAndGetLeafAlloc(String key) {
|
||||
LeafAlloc leafAlloc = leafAllocMapper.selectOne(LeafAlloc::getKey, key);
|
||||
leafAlloc.setMaxId(leafAlloc.getMaxId() + leafAlloc.getStep());
|
||||
return leafAllocMapper.updateById(leafAlloc) > 0 ? leafAlloc : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LeafAlloc updateMaxIdByCustomStepAndGetLeafAlloc(LeafAlloc condition) {
|
||||
LambdaQueryWrapper<LeafAlloc> wrapper = Wrappers.<LeafAlloc>lambdaQuery().eq(LeafAlloc::getKey, condition.getKey());
|
||||
condition.setMaxId(condition.getMaxId() + condition.getStep());
|
||||
return leafAllocMapper.updateById(condition) > 0 ? condition : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAllKeys() {
|
||||
return leafAllocMapper.selectList().stream().map(LeafAlloc::getKey).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean create(LeafAlloc leafAlloc) {
|
||||
LeafAlloc one = leafAllocMapper.selectOne(LeafAlloc::getKey, leafAlloc.getKey());
|
||||
if (one != null) {
|
||||
throw new ServiceException(GlobalErrorCodeConstants.ID_DUPLICATION);
|
||||
}
|
||||
return leafAllocMapper.insert(leafAlloc) > 0 ? true : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(LeafAlloc leafAlloc) {
|
||||
LeafAlloc one = leafAllocMapper.selectOne(LeafAlloc::getKey, leafAlloc.getKey(), LeafAlloc::getId, leafAlloc.getId());
|
||||
if (one != null) {
|
||||
throw new ServiceException(GlobalErrorCodeConstants.ID_DUPLICATION);
|
||||
}
|
||||
one.setUpdateTime(DateUtil.toLocalDateTime(new Date()));
|
||||
return leafAllocMapper.updateById(one) > 0 ? true : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean batchCreate(List<LeafAlloc> leafAllocs) {
|
||||
return leafAllocMapper.insertBatch(leafAllocs);
|
||||
}
|
||||
}
|
@ -1,303 +0,0 @@
|
||||
package cd.casic.ci.common.operationid;
|
||||
|
||||
|
||||
import cd.casic.ci.common.constant.LeafAllocConstant;
|
||||
import cd.casic.ci.common.operationid.entity.Segment;
|
||||
import cd.casic.ci.common.operationid.entity.SegmentBuffer;
|
||||
import cd.casic.ci.common.operationid.entity.LeafAlloc;
|
||||
import cd.casic.framework.commons.exception.ErrorCode;
|
||||
import cd.casic.framework.commons.exception.ServiceException;
|
||||
import cd.casic.framework.commons.util.generator.IdGenerator;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
/**
|
||||
* @author by mianbin
|
||||
* @Classname SegmentIdGeneratorImpl
|
||||
* @Description TODO
|
||||
* @Date 2025/3/19 10:41
|
||||
*/
|
||||
@Slf4j
|
||||
public class SegmentIdGeneratorImpl implements IdGenerator {
|
||||
|
||||
/**
|
||||
* IDCache未初始化成功时的异常码
|
||||
*/
|
||||
private static final long EXCEPTION_ID_IDCACHE_INIT_FALSE = -1;
|
||||
/**
|
||||
* key不存在时的异常码
|
||||
*/
|
||||
private static final long EXCEPTION_ID_KEY_NOT_EXISTS = -2;
|
||||
/**
|
||||
* SegmentBuffer中的两个Segment均未从DB中装载时的异常码
|
||||
*/
|
||||
private static final long EXCEPTION_ID_TWO_SEGMENTS_ARE_NULL = -3;
|
||||
/**
|
||||
* 最大步长不超过100,0000
|
||||
*/
|
||||
private static final int MAX_STEP = 1000000;
|
||||
/**
|
||||
* 一个Segment维持时间为15分钟
|
||||
*/
|
||||
private static final long SEGMENT_DURATION = 15 * 60 * 1000L;
|
||||
private volatile boolean initOK = false;
|
||||
private final Map<String, SegmentBuffer> cache = new ConcurrentHashMap<>();
|
||||
|
||||
private LeafAllocService leafAllocService;
|
||||
|
||||
private ThreadPoolExecutor threadPoolExecutor;
|
||||
|
||||
private ScheduledExecutorService scheduledExecutorService;
|
||||
|
||||
public SegmentIdGeneratorImpl(LeafAllocService leafAllocService, ThreadPoolExecutor threadPoolExecutor,
|
||||
ScheduledExecutorService scheduledExecutorService) {
|
||||
this.leafAllocService = leafAllocService;
|
||||
this.threadPoolExecutor = threadPoolExecutor;
|
||||
this.scheduledExecutorService = scheduledExecutorService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean init() {
|
||||
log.info("Init ...");
|
||||
// 确保加载到kv后才初始化成功
|
||||
updateCacheFromDb();
|
||||
initSave();
|
||||
initOK = true;
|
||||
updateCacheFromDbAtEveryMinute();
|
||||
return initOK;
|
||||
}
|
||||
|
||||
private void initSave() {
|
||||
try {
|
||||
Class<LeafAllocConstant> clazz = LeafAllocConstant.class;
|
||||
Field[] fields = clazz.getFields();
|
||||
List<LeafAlloc> notExist = new ArrayList<>();
|
||||
for (Field field : fields) {
|
||||
String str = (String) field.get(null);
|
||||
if (!cache.containsKey(str)) {
|
||||
LeafAlloc leafAlloc = new LeafAlloc();
|
||||
leafAlloc.setKey(str);
|
||||
leafAlloc.setMaxId(1L);
|
||||
leafAlloc.setStep(50);
|
||||
notExist.add(leafAlloc);
|
||||
}
|
||||
}
|
||||
|
||||
if (!notExist.isEmpty()) {
|
||||
leafAllocService.batchCreate(notExist);
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> batchGenerateSegmentId(String key, Integer num) {
|
||||
|
||||
List<Long> res = new ArrayList<>();
|
||||
while (num-- > 0) {
|
||||
res.add(get(key));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
private void updateCacheFromDbAtEveryMinute() {
|
||||
|
||||
scheduledExecutorService.scheduleWithFixedDelay(this::updateCacheFromDb, 60, 60, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
private void updateCacheFromDb() {
|
||||
log.info("update cache from db");
|
||||
try {
|
||||
List<String> dbTags = leafAllocService.getAllKeys();
|
||||
if (dbTags == null || dbTags.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<String> cacheTags = new ArrayList<>(cache.keySet());
|
||||
Set<String> insertTagsSet = new HashSet<>(dbTags);
|
||||
Set<String> removeTagsSet = new HashSet<>(cacheTags);
|
||||
//db中新加的tags灌进cache
|
||||
for (String tmp : cacheTags) {
|
||||
insertTagsSet.remove(tmp);
|
||||
}
|
||||
for (String tag : insertTagsSet) {
|
||||
SegmentBuffer buffer = new SegmentBuffer();
|
||||
buffer.setKey(tag);
|
||||
Segment segment = buffer.getCurrent();
|
||||
segment.setValue(new AtomicLong(0));
|
||||
segment.setMax(0);
|
||||
segment.setStep(0);
|
||||
cache.put(tag, buffer);
|
||||
log.info("Add tag {} from db to IdCache, SegmentBuffer {}", tag, buffer);
|
||||
}
|
||||
//cache中已失效的tags从cache删除
|
||||
for (String tmp : dbTags) {
|
||||
removeTagsSet.remove(tmp);
|
||||
}
|
||||
for (String tag : removeTagsSet) {
|
||||
cache.remove(tag);
|
||||
log.info("Remove tag {} from IdCache", tag);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("update cache from db exception", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long get(final String key) {
|
||||
if (!initOK) {
|
||||
throw new ServiceException(ErrorCode.builder().msg("IDCache未初始化成功").code(0).build());
|
||||
}
|
||||
if (cache.containsKey(key)) {
|
||||
SegmentBuffer buffer = cache.get(key);
|
||||
if (!buffer.isInitOk()) {
|
||||
synchronized (buffer) {
|
||||
if (!buffer.isInitOk()) {
|
||||
try {
|
||||
updateSegmentFromDb(key, buffer.getCurrent());
|
||||
log.info("Init buffer. Update leafkey {} {} from db", key, buffer.getCurrent());
|
||||
buffer.setInitOk(true);
|
||||
} catch (Exception e) {
|
||||
log.warn("Init buffer {} exception", buffer.getCurrent(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return getIdFromSegmentBuffer(cache.get(key));
|
||||
}
|
||||
log.warn("key({})不存在", key);
|
||||
throw new ServiceException(ErrorCode.builder().msg(String.format("key(%s)不存在", key)).code(0).build());
|
||||
}
|
||||
|
||||
public void updateSegmentFromDb(String key, Segment segment) {
|
||||
SegmentBuffer buffer = segment.getBuffer();
|
||||
LeafAlloc leafAlloc;
|
||||
if (!buffer.isInitOk()) {
|
||||
leafAlloc = leafAllocService.updateMaxIdAndGetLeafAlloc(key);
|
||||
buffer.setStep(leafAlloc.getStep());
|
||||
//leafAlloc中的step为DB中的step
|
||||
buffer.setMinStep(leafAlloc.getStep());
|
||||
} else if (buffer.getUpdateTimestamp() == 0) {
|
||||
leafAlloc = leafAllocService.updateMaxIdAndGetLeafAlloc(key);
|
||||
buffer.setUpdateTimestamp(System.currentTimeMillis());
|
||||
buffer.setStep(leafAlloc.getStep());
|
||||
//leafAlloc中的step为DB中的step
|
||||
buffer.setMinStep(leafAlloc.getStep());
|
||||
} else {
|
||||
long duration = System.currentTimeMillis() - buffer.getUpdateTimestamp();
|
||||
int nextStep = buffer.getStep();
|
||||
if (duration < SEGMENT_DURATION) {
|
||||
if (nextStep * 2 > MAX_STEP) {
|
||||
//do nothing
|
||||
} else {
|
||||
nextStep = nextStep * 2;
|
||||
}
|
||||
} else if (duration < SEGMENT_DURATION * 2) {
|
||||
//do nothing with nextStep
|
||||
} else {
|
||||
nextStep = nextStep / 2 >= buffer.getMinStep() ? nextStep / 2 : nextStep;
|
||||
}
|
||||
log.info("leafKey[{}], step[{}], duration[{}mins], nextStep[{}]", key, buffer.getStep(), String.format("%.2f", ((double) duration / (1000 * 60))), nextStep);
|
||||
LeafAlloc temp = new LeafAlloc();
|
||||
temp.setKey(key);
|
||||
temp.setStep(nextStep);
|
||||
leafAlloc = leafAllocService.updateMaxIdByCustomStepAndGetLeafAlloc(temp);
|
||||
buffer.setUpdateTimestamp(System.currentTimeMillis());
|
||||
buffer.setStep(nextStep);
|
||||
//leafAlloc的step为DB中的step
|
||||
buffer.setMinStep(leafAlloc.getStep());
|
||||
}
|
||||
// must set value before set max
|
||||
long value = leafAlloc.getMaxId() - buffer.getStep();
|
||||
segment.getValue().set(value);
|
||||
segment.setMax(leafAlloc.getMaxId());
|
||||
segment.setStep(buffer.getStep());
|
||||
}
|
||||
|
||||
public Long getIdFromSegmentBuffer(final SegmentBuffer buffer) {
|
||||
while (true) {
|
||||
buffer.rLock().lock();
|
||||
try {
|
||||
final Segment segment = buffer.getCurrent();
|
||||
if (!buffer.isNextReady() && (segment.getIdle() < 0.9 * segment.getStep()) && buffer.getThreadRunning().compareAndSet(false, true)) {
|
||||
threadPoolExecutor.execute(() -> {
|
||||
Segment next = buffer.getSegments()[buffer.nextPos()];
|
||||
boolean updateOk = false;
|
||||
try {
|
||||
updateSegmentFromDb(buffer.getKey(), next);
|
||||
updateOk = true;
|
||||
log.info("update segment {} from db {}", buffer.getKey(), next);
|
||||
} catch (Exception e) {
|
||||
log.warn(buffer.getKey() + " updateSegmentFromDb exception", e);
|
||||
} finally {
|
||||
if (updateOk) {
|
||||
buffer.wLock().lock();
|
||||
buffer.setNextReady(true);
|
||||
buffer.getThreadRunning().set(false);
|
||||
buffer.wLock().unlock();
|
||||
} else {
|
||||
buffer.getThreadRunning().set(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
long value = segment.getValue().getAndIncrement();
|
||||
if (value < segment.getMax()) {
|
||||
return value;
|
||||
}
|
||||
} finally {
|
||||
buffer.rLock().unlock();
|
||||
}
|
||||
waitAndSleep(buffer);
|
||||
buffer.wLock().lock();
|
||||
try {
|
||||
final Segment segment = buffer.getCurrent();
|
||||
long value = segment.getValue().getAndIncrement();
|
||||
if (value < segment.getMax()) {
|
||||
return value;
|
||||
}
|
||||
if (buffer.isNextReady()) {
|
||||
buffer.switchPos();
|
||||
buffer.setNextReady(false);
|
||||
} else {
|
||||
log.error("Both two segments in {} are not ready! ,请稍后再试", buffer);
|
||||
}
|
||||
} finally {
|
||||
buffer.wLock().unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void waitAndSleep(SegmentBuffer buffer) {
|
||||
int roll = 0;
|
||||
while (buffer.getThreadRunning().get()) {
|
||||
roll += 1;
|
||||
if (roll > 10000) {
|
||||
try {
|
||||
TimeUnit.MILLISECONDS.sleep(10);
|
||||
break;
|
||||
} catch (InterruptedException e) {
|
||||
log.warn("Thread {} Interrupted", Thread.currentThread().getName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<LeafAlloc> getAllLeafAllocs() {
|
||||
return leafAllocService.getAllLeafAllocs();
|
||||
}
|
||||
|
||||
public Map<String, SegmentBuffer> getCache() {
|
||||
return cache;
|
||||
}
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
package cd.casic.ci.common.operationid.entity;
|
||||
|
||||
import cd.casic.framework.commons.util.validation.ValidGroup;
|
||||
import cd.casic.framework.mybatis.core.dataobject.BaseDO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Null;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @author mianbin
|
||||
* @Classname LeafAlloc
|
||||
* @Description 业务id实体
|
||||
* @Date 2025/3/18 14:16
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(description = "生成唯一id的实体")
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
public class LeafAlloc extends BaseDO {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "主键")
|
||||
@Null(message = "新增id需为空", groups = ValidGroup.Create.class)
|
||||
@NotNull(message = "修改id不能为空", groups = ValidGroup.Update.class)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 业务key
|
||||
*/
|
||||
@Schema(description = "业务key", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "key不能为空")
|
||||
private String key;
|
||||
|
||||
/**
|
||||
* 当前已分配的最大id
|
||||
*/
|
||||
@Schema(description = "当前已分配的最大id(新增建议从1开始)", requiredMode = Schema.RequiredMode.REQUIRED, defaultValue = "1")
|
||||
@NotNull(message = "maxId不能为空")
|
||||
@Size(min = 1, message = "最小为1")
|
||||
private Long maxId;
|
||||
|
||||
/**
|
||||
* 初始步长,也是动态调整的最小步长
|
||||
*/
|
||||
@Schema(description = "初始步长,也是动态调整的最小步长(从数据库一次获取的id数量)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "step不能为空")
|
||||
@Size(min = 1, message = "最小为1")
|
||||
private Integer step;
|
||||
|
||||
/**
|
||||
* 业务key描述
|
||||
*/
|
||||
@Schema(description = "业务key描述", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
private String description;
|
||||
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user