diff --git a/src/backend/replication/api-replication/src/main/kotlin/com/tencent/bkrepo/replication/pojo/remote/request/RemoteConfigCreateRequest.kt b/src/backend/replication/api-replication/src/main/kotlin/com/tencent/bkrepo/replication/pojo/remote/request/RemoteConfigCreateRequest.kt index fb247fa33e..cfe6a9eeac 100644 --- a/src/backend/replication/api-replication/src/main/kotlin/com/tencent/bkrepo/replication/pojo/remote/request/RemoteConfigCreateRequest.kt +++ b/src/backend/replication/api-replication/src/main/kotlin/com/tencent/bkrepo/replication/pojo/remote/request/RemoteConfigCreateRequest.kt @@ -27,6 +27,7 @@ package com.tencent.bkrepo.replication.pojo.remote.request +import com.tencent.bkrepo.replication.pojo.request.ReplicaObjectType import com.tencent.bkrepo.replication.pojo.request.ReplicaType import com.tencent.bkrepo.replication.pojo.task.objects.PackageConstraint import com.tencent.bkrepo.replication.pojo.task.objects.PathConstraint @@ -61,6 +62,8 @@ data class RemoteConfigCreateRequest( val remoteProjectId: String? = null, @ApiModelProperty("远程仓库") val remoteRepoName: String? = null, + @ApiModelProperty("同步对象类型, 只支持clusterId存在的情况", required = true) + val replicaObjectType: ReplicaObjectType? = null, @ApiModelProperty("包限制条件", required = false) val packageConstraints: List? = null, @ApiModelProperty("路径限制条件", required = false) diff --git a/src/backend/replication/api-replication/src/main/kotlin/com/tencent/bkrepo/replication/pojo/remote/request/RemoteConfigUpdateRequest.kt b/src/backend/replication/api-replication/src/main/kotlin/com/tencent/bkrepo/replication/pojo/remote/request/RemoteConfigUpdateRequest.kt index b8c3aba555..369bd34408 100644 --- a/src/backend/replication/api-replication/src/main/kotlin/com/tencent/bkrepo/replication/pojo/remote/request/RemoteConfigUpdateRequest.kt +++ b/src/backend/replication/api-replication/src/main/kotlin/com/tencent/bkrepo/replication/pojo/remote/request/RemoteConfigUpdateRequest.kt @@ -27,6 +27,7 @@ package com.tencent.bkrepo.replication.pojo.remote.request +import com.tencent.bkrepo.replication.pojo.request.ReplicaObjectType import com.tencent.bkrepo.replication.pojo.request.ReplicaType import com.tencent.bkrepo.replication.pojo.task.objects.PackageConstraint import com.tencent.bkrepo.replication.pojo.task.objects.PathConstraint @@ -59,6 +60,8 @@ data class RemoteConfigUpdateRequest( val remoteProjectId: String? = null, @ApiModelProperty("远程仓库") val remoteRepoName: String? = null, + @ApiModelProperty("同步对象类型, 只支持clusterId存在的情况", required = true) + val replicaObjectType: ReplicaObjectType? = null, @ApiModelProperty("包限制条件", required = false) val packageConstraints: List? = null, @ApiModelProperty("路径限制条件", required = false) diff --git a/src/backend/replication/api-replication/src/main/kotlin/com/tencent/bkrepo/replication/pojo/remote/request/RemoteRunOnceTaskCreateRequest.kt b/src/backend/replication/api-replication/src/main/kotlin/com/tencent/bkrepo/replication/pojo/remote/request/RemoteRunOnceTaskCreateRequest.kt index 031c81dd9e..0253e8a1aa 100644 --- a/src/backend/replication/api-replication/src/main/kotlin/com/tencent/bkrepo/replication/pojo/remote/request/RemoteRunOnceTaskCreateRequest.kt +++ b/src/backend/replication/api-replication/src/main/kotlin/com/tencent/bkrepo/replication/pojo/remote/request/RemoteRunOnceTaskCreateRequest.kt @@ -27,6 +27,7 @@ package com.tencent.bkrepo.replication.pojo.remote.request +import com.tencent.bkrepo.replication.pojo.request.ReplicaObjectType import com.tencent.bkrepo.replication.pojo.request.ReplicaType import com.tencent.bkrepo.replication.pojo.task.setting.ReplicaSetting import io.swagger.annotations.ApiModel @@ -57,6 +58,8 @@ data class RemoteRunOnceTaskCreateRequest( val remoteProjectId: String? = null, @ApiModelProperty("远程仓库") val remoteRepoName: String? = null, + @ApiModelProperty("同步对象类型, 只支持clusterId存在的情况", required = true) + val replicaObjectType: ReplicaObjectType? = null, @ApiModelProperty("包名", required = false) val packageName: String? = null, @ApiModelProperty("包版本", required = false) diff --git a/src/backend/replication/api-replication/src/main/kotlin/com/tencent/bkrepo/replication/pojo/task/setting/ReplicaSetting.kt b/src/backend/replication/api-replication/src/main/kotlin/com/tencent/bkrepo/replication/pojo/task/setting/ReplicaSetting.kt index 7894fdb293..0861922d9d 100644 --- a/src/backend/replication/api-replication/src/main/kotlin/com/tencent/bkrepo/replication/pojo/task/setting/ReplicaSetting.kt +++ b/src/backend/replication/api-replication/src/main/kotlin/com/tencent/bkrepo/replication/pojo/task/setting/ReplicaSetting.kt @@ -58,5 +58,9 @@ data class ReplicaSetting( /** * 是否校验文件存储一致性 */ - val storageConsistencyCheck: Boolean = false + val storageConsistencyCheck: Boolean = false, + /** + * 当远程项目或者仓库不存在时是否自动创建 + */ + val automaticCreateRemoteRepo: Boolean = true ) diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/controller/cluster/ClusterReplicaTaskController.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/controller/cluster/ClusterReplicaTaskController.kt index e186796cc5..42efbad60e 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/controller/cluster/ClusterReplicaTaskController.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/controller/cluster/ClusterReplicaTaskController.kt @@ -36,7 +36,7 @@ import com.tencent.bkrepo.replication.pojo.request.ReplicaType import com.tencent.bkrepo.replication.pojo.task.EdgeReplicaTaskRecord import com.tencent.bkrepo.replication.pojo.task.ReplicaTaskInfo import com.tencent.bkrepo.replication.pojo.task.objects.ReplicaObjectInfo -import com.tencent.bkrepo.replication.replica.base.replicator.commitedge.EdgeReplicaContextHolder +import com.tencent.bkrepo.replication.replica.replicator.commitedge.EdgeReplicaContextHolder import com.tencent.bkrepo.replication.service.EdgeReplicaTaskRecordService import com.tencent.bkrepo.replication.service.ReplicaTaskService import org.springframework.web.bind.annotation.RestController diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/controller/service/ArtifactPushController.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/controller/service/ArtifactPushController.kt index 2d92d999eb..8cb7b0145c 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/controller/service/ArtifactPushController.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/controller/service/ArtifactPushController.kt @@ -37,7 +37,7 @@ import com.tencent.bkrepo.common.security.util.SecurityUtils import com.tencent.bkrepo.common.service.util.ResponseBuilder import com.tencent.bkrepo.replication.api.ArtifactPushClient import com.tencent.bkrepo.replication.pojo.remote.request.ArtifactPushRequest -import com.tencent.bkrepo.replication.replica.event.EventBasedReplicaJobExecutor +import com.tencent.bkrepo.replication.replica.type.event.EventBasedReplicaJobExecutor import com.tencent.bkrepo.replication.service.ReplicaTaskService import org.slf4j.LoggerFactory import org.springframework.web.bind.annotation.RestController diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/exception/ArtifactContentReadException.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/exception/ArtifactContentReadException.kt similarity index 95% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/exception/ArtifactContentReadException.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/exception/ArtifactContentReadException.kt index d8bb2629d8..eb60898cd9 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/exception/ArtifactContentReadException.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/exception/ArtifactContentReadException.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.impl.remote.exception +package com.tencent.bkrepo.replication.exception /** * 文件内容读取报错 diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/exception/ArtifactPushException.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/exception/ArtifactPushException.kt similarity index 95% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/exception/ArtifactPushException.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/exception/ArtifactPushException.kt index 90c8820a20..9a1125cd5d 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/exception/ArtifactPushException.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/exception/ArtifactPushException.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.impl.remote.exception +package com.tencent.bkrepo.replication.exception /** * 推送到远端集群异常 */ diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/exception/ArtifactSourceCheckException.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/exception/ArtifactSourceCheckException.kt similarity index 95% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/exception/ArtifactSourceCheckException.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/exception/ArtifactSourceCheckException.kt index e019b957ab..72912e87f0 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/exception/ArtifactSourceCheckException.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/exception/ArtifactSourceCheckException.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.impl.remote.exception +package com.tencent.bkrepo.replication.exception /** * Artifact来源异常 diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/exception/RegexCheckException.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/exception/RegexCheckException.kt similarity index 95% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/exception/RegexCheckException.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/exception/RegexCheckException.kt index 7b11d95aa4..31d44a4052 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/exception/RegexCheckException.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/exception/RegexCheckException.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.impl.remote.exception +package com.tencent.bkrepo.replication.exception /** * 规则校验异常 diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/metrics/ReplicationMetrics.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/metrics/ReplicationMetrics.kt index 3e85db7e59..535ebda315 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/metrics/ReplicationMetrics.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/metrics/ReplicationMetrics.kt @@ -51,12 +51,12 @@ import com.tencent.bkrepo.replication.constant.RUN_ONCE_EXECUTOR_ACTIVE_COUNT import com.tencent.bkrepo.replication.constant.RUN_ONCE_EXECUTOR_ACTIVE_COUNT_DESC import com.tencent.bkrepo.replication.constant.RUN_ONCE_EXECUTOR_QUEUE_SIZE import com.tencent.bkrepo.replication.constant.RUN_ONCE_EXECUTOR_QUEUE_SIZE_DESC -import com.tencent.bkrepo.replication.replica.base.executor.EdgePullThreadPoolExecutor -import com.tencent.bkrepo.replication.replica.base.executor.EventConsumerThreadPoolExecutor -import com.tencent.bkrepo.replication.replica.base.executor.ManualThreadPoolExecutor -import com.tencent.bkrepo.replication.replica.base.executor.OciThreadPoolExecutor -import com.tencent.bkrepo.replication.replica.base.executor.ReplicaThreadPoolExecutor -import com.tencent.bkrepo.replication.replica.base.executor.RunOnceThreadPoolExecutor +import com.tencent.bkrepo.replication.replica.executor.EdgePullThreadPoolExecutor +import com.tencent.bkrepo.replication.replica.executor.EventConsumerThreadPoolExecutor +import com.tencent.bkrepo.replication.replica.executor.ManualThreadPoolExecutor +import com.tencent.bkrepo.replication.replica.executor.OciThreadPoolExecutor +import com.tencent.bkrepo.replication.replica.executor.ReplicaThreadPoolExecutor +import com.tencent.bkrepo.replication.replica.executor.RunOnceThreadPoolExecutor import io.micrometer.core.instrument.Gauge import io.micrometer.core.instrument.MeterRegistry import io.micrometer.core.instrument.binder.MeterBinder diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/interceptor/progress/ProgressInterceptor.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/interceptor/progress/ProgressInterceptor.kt index 42f17317be..d2bd39c4a6 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/interceptor/progress/ProgressInterceptor.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/interceptor/progress/ProgressInterceptor.kt @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. * - * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. * * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. * diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/interceptor/progress/ProgressRequestBody.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/interceptor/progress/ProgressRequestBody.kt index f5b1b97746..d6956d9bd3 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/interceptor/progress/ProgressRequestBody.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/interceptor/progress/ProgressRequestBody.kt @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. * - * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. * * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. * diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/context/FilePushContext.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/context/FilePushContext.kt similarity index 96% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/context/FilePushContext.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/context/FilePushContext.kt index 3020cc4206..c7ed69af26 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/context/FilePushContext.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/context/FilePushContext.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.context +package com.tencent.bkrepo.replication.replica.context import com.tencent.bkrepo.common.api.pojo.Response import okhttp3.OkHttpClient diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/context/ReplicaContext.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/context/ReplicaContext.kt similarity index 91% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/context/ReplicaContext.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/context/ReplicaContext.kt index 5d9836b9f4..c0153585ad 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/context/ReplicaContext.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/context/ReplicaContext.kt @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. * - * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. * * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. * @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.context +package com.tencent.bkrepo.replication.replica.context import com.tencent.bkrepo.common.api.pojo.ClusterArchitecture import com.tencent.bkrepo.common.api.pojo.ClusterNodeType @@ -44,15 +44,15 @@ import com.tencent.bkrepo.replication.pojo.record.ExecutionStatus import com.tencent.bkrepo.replication.pojo.record.ReplicaRecordInfo import com.tencent.bkrepo.replication.pojo.task.ReplicaTaskDetail import com.tencent.bkrepo.replication.pojo.task.objects.ReplicaObjectInfo -import com.tencent.bkrepo.replication.replica.base.OkHttpClientPool import com.tencent.bkrepo.replication.replica.base.interceptor.RetryInterceptor import com.tencent.bkrepo.replication.replica.base.interceptor.SignInterceptor -import com.tencent.bkrepo.replication.replica.base.replicator.ClusterReplicator -import com.tencent.bkrepo.replication.replica.base.replicator.EdgeNodeReplicator -import com.tencent.bkrepo.replication.replica.base.replicator.RemoteReplicator -import com.tencent.bkrepo.replication.replica.base.replicator.Replicator -import com.tencent.bkrepo.replication.replica.base.replicator.commitedge.CenterClusterReplicator -import com.tencent.bkrepo.replication.replica.base.replicator.commitedge.CenterRemoteReplicator +import com.tencent.bkrepo.replication.replica.replicator.Replicator +import com.tencent.bkrepo.replication.replica.replicator.commitedge.CenterClusterReplicator +import com.tencent.bkrepo.replication.replica.replicator.commitedge.CenterRemoteReplicator +import com.tencent.bkrepo.replication.replica.replicator.standalone.ClusterReplicator +import com.tencent.bkrepo.replication.replica.replicator.standalone.EdgeNodeReplicator +import com.tencent.bkrepo.replication.replica.replicator.standalone.RemoteReplicator +import com.tencent.bkrepo.replication.util.OkHttpClientPool import com.tencent.bkrepo.repository.pojo.repo.RepositoryDetail import okhttp3.OkHttpClient import org.slf4j.LoggerFactory diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/context/ReplicaExecutionContext.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/context/ReplicaExecutionContext.kt similarity index 97% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/context/ReplicaExecutionContext.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/context/ReplicaExecutionContext.kt index 3f0f5c8ed9..ceafe53d81 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/context/ReplicaExecutionContext.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/context/ReplicaExecutionContext.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.context +package com.tencent.bkrepo.replication.replica.context import com.tencent.bkrepo.replication.pojo.record.ExecutionStatus import com.tencent.bkrepo.replication.pojo.record.ReplicaProgress diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/executor/AbstractReplicaJobExecutor.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/executor/AbstractReplicaJobExecutor.kt similarity index 94% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/executor/AbstractReplicaJobExecutor.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/executor/AbstractReplicaJobExecutor.kt index 1f2ce54e34..3a27b84c6a 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/executor/AbstractReplicaJobExecutor.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/executor/AbstractReplicaJobExecutor.kt @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. * - * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. * * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. * @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.executor +package com.tencent.bkrepo.replication.replica.executor import com.tencent.bkrepo.common.artifact.event.base.ArtifactEvent import com.tencent.bkrepo.common.service.otel.util.AsyncUtils.trace @@ -36,8 +36,8 @@ import com.tencent.bkrepo.replication.pojo.record.ExecutionResult import com.tencent.bkrepo.replication.pojo.record.ExecutionStatus import com.tencent.bkrepo.replication.pojo.record.ReplicaRecordInfo import com.tencent.bkrepo.replication.pojo.task.ReplicaTaskDetail -import com.tencent.bkrepo.replication.replica.base.ReplicaService -import com.tencent.bkrepo.replication.replica.base.context.ReplicaContext +import com.tencent.bkrepo.replication.replica.type.ReplicaService +import com.tencent.bkrepo.replication.replica.context.ReplicaContext import com.tencent.bkrepo.replication.service.ClusterNodeService import org.slf4j.LoggerFactory import java.util.concurrent.Callable diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/executor/EdgePullThreadPoolExecutor.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/executor/EdgePullThreadPoolExecutor.kt similarity index 97% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/executor/EdgePullThreadPoolExecutor.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/executor/EdgePullThreadPoolExecutor.kt index 62b95266a6..1166532036 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/executor/EdgePullThreadPoolExecutor.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/executor/EdgePullThreadPoolExecutor.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.executor +package com.tencent.bkrepo.replication.replica.executor import com.google.common.util.concurrent.ThreadFactoryBuilder import java.util.concurrent.SynchronousQueue diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/executor/EventConsumerThreadPoolExecutor.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/executor/EventConsumerThreadPoolExecutor.kt similarity index 97% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/executor/EventConsumerThreadPoolExecutor.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/executor/EventConsumerThreadPoolExecutor.kt index 187db3993c..9491e52db6 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/executor/EventConsumerThreadPoolExecutor.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/executor/EventConsumerThreadPoolExecutor.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.executor +package com.tencent.bkrepo.replication.replica.executor import com.google.common.util.concurrent.ThreadFactoryBuilder import java.util.concurrent.ArrayBlockingQueue diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/executor/ManualThreadPoolExecutor.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/executor/ManualThreadPoolExecutor.kt similarity index 97% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/executor/ManualThreadPoolExecutor.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/executor/ManualThreadPoolExecutor.kt index 547fadb77f..97cd568e73 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/executor/ManualThreadPoolExecutor.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/executor/ManualThreadPoolExecutor.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.executor +package com.tencent.bkrepo.replication.replica.executor import com.google.common.util.concurrent.ThreadFactoryBuilder import java.util.concurrent.ArrayBlockingQueue diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/executor/OciThreadPoolExecutor.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/executor/OciThreadPoolExecutor.kt similarity index 97% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/executor/OciThreadPoolExecutor.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/executor/OciThreadPoolExecutor.kt index 942688b166..02994d223e 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/executor/OciThreadPoolExecutor.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/executor/OciThreadPoolExecutor.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.executor +package com.tencent.bkrepo.replication.replica.executor import com.google.common.util.concurrent.ThreadFactoryBuilder import java.util.concurrent.ArrayBlockingQueue diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/executor/ReplicaThreadPoolExecutor.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/executor/ReplicaThreadPoolExecutor.kt similarity index 94% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/executor/ReplicaThreadPoolExecutor.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/executor/ReplicaThreadPoolExecutor.kt index 2890476375..e973c4367b 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/executor/ReplicaThreadPoolExecutor.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/executor/ReplicaThreadPoolExecutor.kt @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. * - * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. * * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. * @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.executor +package com.tencent.bkrepo.replication.replica.executor import com.google.common.util.concurrent.ThreadFactoryBuilder import java.util.concurrent.ArrayBlockingQueue diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/executor/RunOnceThreadPoolExecutor.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/executor/RunOnceThreadPoolExecutor.kt similarity index 97% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/executor/RunOnceThreadPoolExecutor.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/executor/RunOnceThreadPoolExecutor.kt index 9e021eb558..fe95935b83 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/executor/RunOnceThreadPoolExecutor.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/executor/RunOnceThreadPoolExecutor.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.executor +package com.tencent.bkrepo.replication.replica.executor import com.google.common.util.concurrent.ThreadFactoryBuilder import java.util.concurrent.ArrayBlockingQueue diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/replicator/Replicator.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/replicator/Replicator.kt similarity index 93% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/replicator/Replicator.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/replicator/Replicator.kt index 280b64aaed..499ba86739 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/replicator/Replicator.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/replicator/Replicator.kt @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. * - * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. * * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. * @@ -25,9 +25,9 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.replicator +package com.tencent.bkrepo.replication.replica.replicator -import com.tencent.bkrepo.replication.replica.base.context.ReplicaContext +import com.tencent.bkrepo.replication.replica.context.ReplicaContext import com.tencent.bkrepo.repository.pojo.node.NodeInfo import com.tencent.bkrepo.repository.pojo.packages.PackageSummary import com.tencent.bkrepo.repository.pojo.packages.PackageVersion diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/handler/ArtifactReplicationHandler.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/replicator/base/ArtifactReplicationHandler.kt similarity index 98% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/handler/ArtifactReplicationHandler.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/replicator/base/ArtifactReplicationHandler.kt index ee395dce11..5ef8ffeecd 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/handler/ArtifactReplicationHandler.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/replicator/base/ArtifactReplicationHandler.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.handler +package com.tencent.bkrepo.replication.replica.replicator.base import com.tencent.bkrepo.common.api.constant.HttpHeaders import com.tencent.bkrepo.common.api.constant.MediaTypes @@ -43,8 +43,9 @@ import com.tencent.bkrepo.replication.pojo.blob.RequestTag import com.tencent.bkrepo.replication.pojo.remote.DefaultHandlerResult import com.tencent.bkrepo.replication.pojo.remote.RequestProperty import com.tencent.bkrepo.replication.pojo.request.ReplicaType -import com.tencent.bkrepo.replication.replica.base.context.FilePushContext -import com.tencent.bkrepo.replication.replica.base.context.ReplicaContext +import com.tencent.bkrepo.replication.replica.context.FilePushContext +import com.tencent.bkrepo.replication.replica.context.ReplicaContext +import com.tencent.bkrepo.replication.util.DefaultHandler import com.tencent.bkrepo.replication.util.StreamRequestBody import okhttp3.Headers import okhttp3.MediaType.Companion.toMediaTypeOrNull diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/handler/ClusterArtifactReplicationHandler.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/replicator/base/internal/ClusterArtifactReplicationHandler.kt similarity index 97% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/handler/ClusterArtifactReplicationHandler.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/replicator/base/internal/ClusterArtifactReplicationHandler.kt index 278bf09dc9..0c731facad 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/handler/ClusterArtifactReplicationHandler.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/replicator/base/internal/ClusterArtifactReplicationHandler.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.handler +package com.tencent.bkrepo.replication.replica.replicator.base.internal import com.tencent.bkrepo.common.api.constant.HttpStatus import com.tencent.bkrepo.common.api.constant.StringPool @@ -40,12 +40,13 @@ import com.tencent.bkrepo.replication.constant.SHA256 import com.tencent.bkrepo.replication.constant.SIZE import com.tencent.bkrepo.replication.constant.STORAGE_KEY import com.tencent.bkrepo.replication.enums.WayOfPushArtifact +import com.tencent.bkrepo.replication.exception.ArtifactPushException import com.tencent.bkrepo.replication.fdtp.FdtpAFTClientFactory import com.tencent.bkrepo.replication.fdtp.FdtpServerProperties import com.tencent.bkrepo.replication.manager.LocalDataManager import com.tencent.bkrepo.replication.pojo.blob.RequestTag -import com.tencent.bkrepo.replication.replica.base.context.FilePushContext -import com.tencent.bkrepo.replication.replica.base.impl.remote.exception.ArtifactPushException +import com.tencent.bkrepo.replication.replica.context.FilePushContext +import com.tencent.bkrepo.replication.replica.replicator.base.ArtifactReplicationHandler import com.tencent.bkrepo.replication.replica.base.process.ProgressListener import com.tencent.bkrepo.replication.util.StreamRequestBody import io.netty.channel.ChannelProgressiveFuture diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/handler/RemoteClusterArtifactReplicationHandler.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/replicator/base/remote/RemoteClusterArtifactReplicationHandler.kt similarity index 93% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/handler/RemoteClusterArtifactReplicationHandler.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/replicator/base/remote/RemoteClusterArtifactReplicationHandler.kt index 8dec006a3b..0a7cd313fb 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/handler/RemoteClusterArtifactReplicationHandler.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/replicator/base/remote/RemoteClusterArtifactReplicationHandler.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.handler +package com.tencent.bkrepo.replication.replica.replicator.base.remote import com.tencent.bkrepo.common.api.constant.HttpStatus import com.tencent.bkrepo.common.artifact.util.http.UrlFormatter @@ -33,8 +33,9 @@ import com.tencent.bkrepo.replication.config.ReplicationProperties import com.tencent.bkrepo.replication.constant.OCI_BLOBS_UPLOAD_FIRST_STEP_URL import com.tencent.bkrepo.replication.manager.LocalDataManager import com.tencent.bkrepo.replication.pojo.remote.DefaultHandlerResult -import com.tencent.bkrepo.replication.replica.base.context.FilePushContext -import com.tencent.bkrepo.replication.replica.base.context.ReplicaContext +import com.tencent.bkrepo.replication.replica.context.FilePushContext +import com.tencent.bkrepo.replication.replica.context.ReplicaContext +import com.tencent.bkrepo.replication.replica.replicator.base.ArtifactReplicationHandler import org.slf4j.LoggerFactory import org.springframework.stereotype.Component import java.net.URL diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/replicator/commitedge/CenterClusterReplicator.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/replicator/commitedge/CenterClusterReplicator.kt similarity index 91% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/replicator/commitedge/CenterClusterReplicator.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/replicator/commitedge/CenterClusterReplicator.kt index f44831e2bf..6c28ab2e6a 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/replicator/commitedge/CenterClusterReplicator.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/replicator/commitedge/CenterClusterReplicator.kt @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. * - * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. * * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. * @@ -25,15 +25,15 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.replicator.commitedge +package com.tencent.bkrepo.replication.replica.replicator.commitedge import com.tencent.bkrepo.common.service.cluster.ClusterProperties import com.tencent.bkrepo.common.service.cluster.CommitEdgeCenterCondition import com.tencent.bkrepo.replication.config.ReplicationProperties import com.tencent.bkrepo.replication.manager.LocalDataManager -import com.tencent.bkrepo.replication.replica.base.context.ReplicaContext -import com.tencent.bkrepo.replication.replica.base.handler.ClusterArtifactReplicationHandler -import com.tencent.bkrepo.replication.replica.base.replicator.ClusterReplicator +import com.tencent.bkrepo.replication.replica.context.ReplicaContext +import com.tencent.bkrepo.replication.replica.replicator.base.internal.ClusterArtifactReplicationHandler +import com.tencent.bkrepo.replication.replica.replicator.standalone.ClusterReplicator import com.tencent.bkrepo.replication.service.EdgeReplicaTaskRecordService import com.tencent.bkrepo.repository.pojo.node.NodeDetail import com.tencent.bkrepo.repository.pojo.node.NodeInfo diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/replicator/commitedge/CenterRemoteReplicator.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/replicator/commitedge/CenterRemoteReplicator.kt similarity index 91% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/replicator/commitedge/CenterRemoteReplicator.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/replicator/commitedge/CenterRemoteReplicator.kt index 0c88e83fab..58e5ff6be6 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/replicator/commitedge/CenterRemoteReplicator.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/replicator/commitedge/CenterRemoteReplicator.kt @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. * - * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. * * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. * @@ -25,12 +25,12 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.replicator.commitedge +package com.tencent.bkrepo.replication.replica.replicator.commitedge import com.tencent.bkrepo.common.service.cluster.CommitEdgeCenterCondition import com.tencent.bkrepo.replication.config.ReplicationProperties -import com.tencent.bkrepo.replication.replica.base.context.ReplicaContext -import com.tencent.bkrepo.replication.replica.base.replicator.RemoteReplicator +import com.tencent.bkrepo.replication.replica.context.ReplicaContext +import com.tencent.bkrepo.replication.replica.replicator.standalone.RemoteReplicator import com.tencent.bkrepo.replication.service.EdgeReplicaTaskRecordService import com.tencent.bkrepo.repository.pojo.packages.PackageSummary import com.tencent.bkrepo.repository.pojo.packages.PackageVersion diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/replicator/commitedge/EdgeReplicaContextHolder.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/replicator/commitedge/EdgeReplicaContextHolder.kt similarity index 97% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/replicator/commitedge/EdgeReplicaContextHolder.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/replicator/commitedge/EdgeReplicaContextHolder.kt index 3afe6f96f9..025a161444 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/replicator/commitedge/EdgeReplicaContextHolder.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/replicator/commitedge/EdgeReplicaContextHolder.kt @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. * - * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. * * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. * @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.replicator.commitedge +package com.tencent.bkrepo.replication.replica.replicator.commitedge import com.tencent.bkrepo.common.api.exception.ErrorCodeException import com.tencent.bkrepo.common.api.net.speedtest.Counter diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/replicator/ClusterReplicator.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/replicator/standalone/ClusterReplicator.kt similarity index 96% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/replicator/ClusterReplicator.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/replicator/standalone/ClusterReplicator.kt index 903dc4cf1a..47d5e37d12 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/replicator/ClusterReplicator.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/replicator/standalone/ClusterReplicator.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.replicator +package com.tencent.bkrepo.replication.replica.replicator.standalone import com.google.common.base.Throwables import com.tencent.bkrepo.common.api.constant.HttpStatus @@ -39,14 +39,15 @@ import com.tencent.bkrepo.replication.constant.DEFAULT_VERSION import com.tencent.bkrepo.replication.constant.DELAY_IN_SECONDS import com.tencent.bkrepo.replication.constant.RETRY_COUNT import com.tencent.bkrepo.replication.enums.WayOfPushArtifact +import com.tencent.bkrepo.replication.exception.ArtifactPushException import com.tencent.bkrepo.replication.manager.LocalDataManager import com.tencent.bkrepo.replication.pojo.request.PackageVersionExistCheckRequest import com.tencent.bkrepo.replication.pojo.task.setting.ConflictStrategy -import com.tencent.bkrepo.replication.replica.base.context.FilePushContext -import com.tencent.bkrepo.replication.replica.base.context.ReplicaContext -import com.tencent.bkrepo.replication.replica.base.handler.ClusterArtifactReplicationHandler -import com.tencent.bkrepo.replication.replica.base.impl.internal.PackageNodeMappings -import com.tencent.bkrepo.replication.replica.base.impl.remote.exception.ArtifactPushException +import com.tencent.bkrepo.replication.replica.replicator.base.internal.ClusterArtifactReplicationHandler +import com.tencent.bkrepo.replication.replica.repository.internal.PackageNodeMappings +import com.tencent.bkrepo.replication.replica.context.FilePushContext +import com.tencent.bkrepo.replication.replica.context.ReplicaContext +import com.tencent.bkrepo.replication.replica.replicator.Replicator import com.tencent.bkrepo.repository.pojo.metadata.MetadataModel import com.tencent.bkrepo.repository.pojo.node.NodeInfo import com.tencent.bkrepo.repository.pojo.node.service.NodeCreateRequest diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/replicator/EdgeNodeReplicator.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/replicator/standalone/EdgeNodeReplicator.kt similarity index 91% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/replicator/EdgeNodeReplicator.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/replicator/standalone/EdgeNodeReplicator.kt index 3cf3e7c0ea..661e065159 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/replicator/EdgeNodeReplicator.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/replicator/standalone/EdgeNodeReplicator.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.replicator +package com.tencent.bkrepo.replication.replica.replicator.standalone import com.google.common.base.Throwables import com.tencent.bkrepo.common.api.constant.HttpStatus @@ -34,12 +34,13 @@ import com.tencent.bkrepo.replication.config.ReplicationProperties import com.tencent.bkrepo.replication.constant.DELAY_IN_SECONDS import com.tencent.bkrepo.replication.constant.RETRY_COUNT import com.tencent.bkrepo.replication.enums.WayOfPushArtifact +import com.tencent.bkrepo.replication.exception.ArtifactPushException import com.tencent.bkrepo.replication.manager.LocalDataManager -import com.tencent.bkrepo.replication.replica.base.context.FilePushContext -import com.tencent.bkrepo.replication.replica.base.context.ReplicaContext -import com.tencent.bkrepo.replication.replica.base.handler.ClusterArtifactReplicationHandler -import com.tencent.bkrepo.replication.replica.base.impl.internal.PackageNodeMappings -import com.tencent.bkrepo.replication.replica.base.impl.remote.exception.ArtifactPushException +import com.tencent.bkrepo.replication.replica.replicator.base.internal.ClusterArtifactReplicationHandler +import com.tencent.bkrepo.replication.replica.repository.internal.PackageNodeMappings +import com.tencent.bkrepo.replication.replica.context.FilePushContext +import com.tencent.bkrepo.replication.replica.context.ReplicaContext +import com.tencent.bkrepo.replication.replica.replicator.Replicator import com.tencent.bkrepo.repository.pojo.node.NodeInfo import com.tencent.bkrepo.repository.pojo.packages.PackageSummary import com.tencent.bkrepo.repository.pojo.packages.PackageVersion diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/replicator/RemoteReplicator.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/replicator/standalone/RemoteReplicator.kt similarity index 93% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/replicator/RemoteReplicator.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/replicator/standalone/RemoteReplicator.kt index 6f65ec3b76..ff97e31b09 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/replicator/RemoteReplicator.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/replicator/standalone/RemoteReplicator.kt @@ -25,14 +25,15 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.replicator +package com.tencent.bkrepo.replication.replica.replicator.standalone import com.tencent.bkrepo.common.artifact.constant.SOURCE_TYPE import com.tencent.bkrepo.common.artifact.resolve.response.ArtifactChannel -import com.tencent.bkrepo.replication.replica.base.context.ReplicaContext -import com.tencent.bkrepo.replication.replica.base.impl.remote.ArtifactPushMappings -import com.tencent.bkrepo.replication.replica.base.impl.remote.exception.ArtifactSourceCheckException -import com.tencent.bkrepo.replication.replica.base.impl.remote.exception.RegexCheckException +import com.tencent.bkrepo.replication.exception.ArtifactSourceCheckException +import com.tencent.bkrepo.replication.exception.RegexCheckException +import com.tencent.bkrepo.replication.replica.repository.remote.ArtifactPushMappings +import com.tencent.bkrepo.replication.replica.context.ReplicaContext +import com.tencent.bkrepo.replication.replica.replicator.Replicator import com.tencent.bkrepo.repository.pojo.node.NodeInfo import com.tencent.bkrepo.repository.pojo.packages.PackageSummary import com.tencent.bkrepo.repository.pojo.packages.PackageVersion diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/internal/PackageNodeMappings.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/internal/PackageNodeMappings.kt similarity index 84% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/internal/PackageNodeMappings.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/internal/PackageNodeMappings.kt index 152fc3ea89..81e85a72dc 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/internal/PackageNodeMappings.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/internal/PackageNodeMappings.kt @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. * - * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. * * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. * @@ -25,14 +25,14 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.impl.internal +package com.tencent.bkrepo.replication.replica.repository.internal import com.tencent.bkrepo.common.artifact.pojo.RepositoryType import com.tencent.bkrepo.common.service.util.SpringContextUtils -import com.tencent.bkrepo.replication.replica.base.impl.internal.type.DockerPackageNodeMapper -import com.tencent.bkrepo.replication.replica.base.impl.internal.type.MavenPackageNodeMapper -import com.tencent.bkrepo.replication.replica.base.impl.internal.type.NpmPackageNodeMapper -import com.tencent.bkrepo.replication.replica.base.impl.internal.type.PackageNodeMapper +import com.tencent.bkrepo.replication.replica.repository.internal.type.DockerPackageNodeMapper +import com.tencent.bkrepo.replication.replica.repository.internal.type.MavenPackageNodeMapper +import com.tencent.bkrepo.replication.replica.repository.internal.type.NpmPackageNodeMapper +import com.tencent.bkrepo.replication.replica.repository.internal.type.PackageNodeMapper import com.tencent.bkrepo.repository.pojo.packages.PackageSummary import com.tencent.bkrepo.repository.pojo.packages.PackageVersion diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/internal/type/DockerPackageNodeMapper.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/internal/type/DockerPackageNodeMapper.kt similarity index 74% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/internal/type/DockerPackageNodeMapper.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/internal/type/DockerPackageNodeMapper.kt index bfb0450916..a55bbb2ff7 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/internal/type/DockerPackageNodeMapper.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/internal/type/DockerPackageNodeMapper.kt @@ -1,4 +1,31 @@ -package com.tencent.bkrepo.replication.replica.base.impl.internal.type +/* + * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. + * + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. + * + * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. + * + * A copy of the MIT License is included in this file. + * + * + * Terms of the MIT License: + * --------------------------------------------------- + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.tencent.bkrepo.replication.replica.repository.internal.type import com.tencent.bkrepo.common.artifact.exception.ArtifactNotFoundException import com.tencent.bkrepo.common.artifact.pojo.RepositoryType diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/internal/type/MavenPackageNodeMapper.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/internal/type/MavenPackageNodeMapper.kt similarity index 95% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/internal/type/MavenPackageNodeMapper.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/internal/type/MavenPackageNodeMapper.kt index d533a97aa8..1e9195be76 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/internal/type/MavenPackageNodeMapper.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/internal/type/MavenPackageNodeMapper.kt @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. * - * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. * * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. * @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.impl.internal.type +package com.tencent.bkrepo.replication.replica.repository.internal.type import com.tencent.bkrepo.common.artifact.pojo.RepositoryType import com.tencent.bkrepo.repository.api.NodeClient diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/internal/type/NpmPackageNodeMapper.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/internal/type/NpmPackageNodeMapper.kt similarity index 94% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/internal/type/NpmPackageNodeMapper.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/internal/type/NpmPackageNodeMapper.kt index b825d0fedf..2dcdbc28ba 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/internal/type/NpmPackageNodeMapper.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/internal/type/NpmPackageNodeMapper.kt @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. * - * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. * * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. * @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.impl.internal.type +package com.tencent.bkrepo.replication.replica.repository.internal.type import com.tencent.bkrepo.common.artifact.pojo.RepositoryType import com.tencent.bkrepo.common.artifact.util.PackageKeys diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/internal/type/PackageNodeMapper.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/internal/type/PackageNodeMapper.kt similarity index 93% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/internal/type/PackageNodeMapper.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/internal/type/PackageNodeMapper.kt index ff9b4522b3..3a627fa251 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/internal/type/PackageNodeMapper.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/internal/type/PackageNodeMapper.kt @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. * - * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. * * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. * @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.impl.internal.type +package com.tencent.bkrepo.replication.replica.repository.internal.type import com.tencent.bkrepo.common.artifact.pojo.RepositoryType import com.tencent.bkrepo.repository.pojo.packages.PackageSummary diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/ArtifactPushMappings.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/remote/ArtifactPushMappings.kt similarity index 87% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/ArtifactPushMappings.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/remote/ArtifactPushMappings.kt index 7c52558042..ba42e5bd41 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/ArtifactPushMappings.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/remote/ArtifactPushMappings.kt @@ -25,14 +25,14 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.impl.remote +package com.tencent.bkrepo.replication.replica.repository.remote import com.tencent.bkrepo.common.artifact.pojo.RepositoryType import com.tencent.bkrepo.common.service.util.SpringContextUtils -import com.tencent.bkrepo.replication.replica.base.context.ReplicaContext -import com.tencent.bkrepo.replication.replica.base.impl.remote.base.PushClient -import com.tencent.bkrepo.replication.replica.base.impl.remote.type.helm.HelmArtifactPushClient -import com.tencent.bkrepo.replication.replica.base.impl.remote.type.oci.OciArtifactPushClient +import com.tencent.bkrepo.replication.replica.repository.remote.base.PushClient +import com.tencent.bkrepo.replication.replica.repository.remote.type.helm.HelmArtifactPushClient +import com.tencent.bkrepo.replication.replica.repository.remote.type.oci.OciArtifactPushClient +import com.tencent.bkrepo.replication.replica.context.ReplicaContext import com.tencent.bkrepo.repository.pojo.packages.PackageSummary import com.tencent.bkrepo.repository.pojo.packages.PackageVersion diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/base/AuthorizationService.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/remote/base/AuthorizationService.kt similarity index 96% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/base/AuthorizationService.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/remote/base/AuthorizationService.kt index 6579d66fa1..b2abc9a4ae 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/base/AuthorizationService.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/remote/base/AuthorizationService.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.impl.remote.base +package com.tencent.bkrepo.replication.replica.repository.remote.base import com.tencent.bkrepo.replication.pojo.remote.RequestProperty import okhttp3.OkHttpClient diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/base/PushClient.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/remote/base/PushClient.kt similarity index 97% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/base/PushClient.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/remote/base/PushClient.kt index dd5c60a7cc..ecc14e9aee 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/base/PushClient.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/remote/base/PushClient.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.impl.remote.base +package com.tencent.bkrepo.replication.replica.repository.remote.base import com.tencent.bkrepo.common.artifact.pojo.RepositoryType import com.tencent.bkrepo.common.service.cluster.ClusterInfo @@ -34,9 +34,9 @@ import com.tencent.bkrepo.replication.config.ReplicationProperties import com.tencent.bkrepo.replication.manager.LocalDataManager import com.tencent.bkrepo.replication.pojo.blob.RequestTag import com.tencent.bkrepo.replication.pojo.request.ReplicaType -import com.tencent.bkrepo.replication.replica.base.context.ReplicaContext import com.tencent.bkrepo.replication.replica.base.interceptor.RetryInterceptor import com.tencent.bkrepo.replication.replica.base.interceptor.progress.ProgressInterceptor +import com.tencent.bkrepo.replication.replica.context.ReplicaContext import com.tencent.bkrepo.repository.pojo.node.NodeDetail import okhttp3.OkHttpClient import okhttp3.Protocol diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/type/helm/HelmArtifactPushClient.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/remote/type/helm/HelmArtifactPushClient.kt similarity index 96% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/type/helm/HelmArtifactPushClient.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/remote/type/helm/HelmArtifactPushClient.kt index 2e57791dc0..f28f302675 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/type/helm/HelmArtifactPushClient.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/remote/type/helm/HelmArtifactPushClient.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.impl.remote.type.helm +package com.tencent.bkrepo.replication.replica.repository.remote.type.helm import com.tencent.bkrepo.common.api.constant.HttpStatus import com.tencent.bkrepo.common.api.constant.MediaTypes @@ -38,9 +38,9 @@ import com.tencent.bkrepo.replication.config.ReplicationProperties import com.tencent.bkrepo.replication.manager.LocalDataManager import com.tencent.bkrepo.replication.pojo.remote.DefaultHandlerResult import com.tencent.bkrepo.replication.pojo.remote.RequestProperty -import com.tencent.bkrepo.replication.replica.base.context.ReplicaContext -import com.tencent.bkrepo.replication.replica.base.handler.DefaultHandler -import com.tencent.bkrepo.replication.replica.base.impl.remote.base.PushClient +import com.tencent.bkrepo.replication.replica.context.ReplicaContext +import com.tencent.bkrepo.replication.replica.repository.remote.base.PushClient +import com.tencent.bkrepo.replication.util.DefaultHandler import com.tencent.bkrepo.repository.pojo.node.NodeDetail import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.MultipartBody diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/type/helm/HelmAuthorizationService.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/remote/type/helm/HelmAuthorizationService.kt similarity index 92% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/type/helm/HelmAuthorizationService.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/remote/type/helm/HelmAuthorizationService.kt index 541a0e355b..e2895e2639 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/type/helm/HelmAuthorizationService.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/remote/type/helm/HelmAuthorizationService.kt @@ -25,10 +25,10 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.impl.remote.type.helm +package com.tencent.bkrepo.replication.replica.repository.remote.type.helm import com.tencent.bkrepo.replication.pojo.remote.RequestProperty -import com.tencent.bkrepo.replication.replica.base.impl.remote.base.AuthorizationService +import com.tencent.bkrepo.replication.replica.repository.remote.base.AuthorizationService import okhttp3.OkHttpClient import org.springframework.stereotype.Component diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/type/oci/OciArtifactPushClient.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/remote/type/oci/OciArtifactPushClient.kt similarity index 95% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/type/oci/OciArtifactPushClient.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/remote/type/oci/OciArtifactPushClient.kt index 605b8811a1..c6e8f0ddda 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/type/oci/OciArtifactPushClient.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/remote/type/oci/OciArtifactPushClient.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.impl.remote.type.oci +package com.tencent.bkrepo.replication.replica.repository.remote.type.oci import com.tencent.bkrepo.common.api.constant.HttpHeaders import com.tencent.bkrepo.common.api.constant.HttpStatus @@ -44,17 +44,17 @@ import com.tencent.bkrepo.replication.constant.OCI_MANIFEST_JSON_FULL_PATH import com.tencent.bkrepo.replication.constant.OCI_MANIFEST_URL import com.tencent.bkrepo.replication.constant.RETRY_COUNT import com.tencent.bkrepo.replication.enums.WayOfPushArtifact +import com.tencent.bkrepo.replication.exception.ArtifactPushException import com.tencent.bkrepo.replication.manager.LocalDataManager import com.tencent.bkrepo.replication.pojo.docker.OciResponse import com.tencent.bkrepo.replication.pojo.remote.DefaultHandlerResult import com.tencent.bkrepo.replication.pojo.remote.RequestProperty -import com.tencent.bkrepo.replication.replica.base.context.FilePushContext -import com.tencent.bkrepo.replication.replica.base.context.ReplicaContext -import com.tencent.bkrepo.replication.replica.base.executor.OciThreadPoolExecutor -import com.tencent.bkrepo.replication.replica.base.handler.DefaultHandler -import com.tencent.bkrepo.replication.replica.base.handler.RemoteClusterArtifactReplicationHandler -import com.tencent.bkrepo.replication.replica.base.impl.remote.base.PushClient -import com.tencent.bkrepo.replication.replica.base.impl.remote.exception.ArtifactPushException +import com.tencent.bkrepo.replication.replica.replicator.base.remote.RemoteClusterArtifactReplicationHandler +import com.tencent.bkrepo.replication.replica.repository.remote.base.PushClient +import com.tencent.bkrepo.replication.replica.context.FilePushContext +import com.tencent.bkrepo.replication.replica.context.ReplicaContext +import com.tencent.bkrepo.replication.replica.executor.OciThreadPoolExecutor +import com.tencent.bkrepo.replication.util.DefaultHandler import com.tencent.bkrepo.replication.util.ManifestParser import com.tencent.bkrepo.repository.pojo.node.NodeDetail import okhttp3.Headers diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/type/oci/OciAuthorizationService.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/remote/type/oci/OciAuthorizationService.kt similarity index 95% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/type/oci/OciAuthorizationService.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/remote/type/oci/OciAuthorizationService.kt index 989ac50cf1..272a22a428 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/impl/remote/type/oci/OciAuthorizationService.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/repository/remote/type/oci/OciAuthorizationService.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.impl.remote.type.oci +package com.tencent.bkrepo.replication.replica.repository.remote.type.oci import com.tencent.bkrepo.common.api.constant.BEARER_AUTH_PREFIX import com.tencent.bkrepo.common.api.constant.HttpHeaders @@ -38,8 +38,8 @@ import com.tencent.bkrepo.common.api.util.toJsonString import com.tencent.bkrepo.replication.pojo.docker.OciResponse import com.tencent.bkrepo.replication.pojo.remote.BearerToken import com.tencent.bkrepo.replication.pojo.remote.RequestProperty -import com.tencent.bkrepo.replication.replica.base.impl.remote.base.AuthorizationService -import com.tencent.bkrepo.replication.replica.base.impl.remote.exception.ArtifactPushException +import com.tencent.bkrepo.replication.replica.repository.remote.base.AuthorizationService +import com.tencent.bkrepo.replication.exception.ArtifactPushException import com.tencent.bkrepo.replication.util.HttpUtils import okhttp3.OkHttpClient import okhttp3.Response diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/AbstractReplicaService.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/AbstractReplicaService.kt similarity index 90% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/AbstractReplicaService.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/AbstractReplicaService.kt index 2254c2855e..cd534dfab2 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/AbstractReplicaService.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/AbstractReplicaService.kt @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. * - * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. * * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. * @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base +package com.tencent.bkrepo.replication.replica.type import com.google.common.base.Throwables import com.tencent.bkrepo.common.api.pojo.ClusterNodeType @@ -40,8 +40,8 @@ import com.tencent.bkrepo.replication.pojo.task.ReplicaTaskInfo import com.tencent.bkrepo.replication.pojo.task.objects.PackageConstraint import com.tencent.bkrepo.replication.pojo.task.objects.PathConstraint import com.tencent.bkrepo.replication.pojo.task.setting.ErrorStrategy -import com.tencent.bkrepo.replication.replica.base.context.ReplicaContext -import com.tencent.bkrepo.replication.replica.base.context.ReplicaExecutionContext +import com.tencent.bkrepo.replication.replica.context.ReplicaContext +import com.tencent.bkrepo.replication.replica.context.ReplicaExecutionContext import com.tencent.bkrepo.replication.service.ReplicaRecordService import com.tencent.bkrepo.replication.util.ReplicationMetricsRecordUtil.convertToReplicationRecordDetailMetricsRecord import com.tencent.bkrepo.replication.util.ReplicationMetricsRecordUtil.toJson @@ -63,6 +63,53 @@ abstract class AbstractReplicaService( private val localDataManager: LocalDataManager ) : ReplicaService { + /** + * 同步 task Object + */ + protected fun replicaTaskObjects(replicaContext: ReplicaContext) { + with(replicaContext) { + // 检查版本 + replicator.checkVersion(this) + if (task.setting.automaticCreateRemoteRepo) { + // 同步项目信息 + replicator.replicaProject(replicaContext) + // 同步仓库信息 + replicator.replicaRepo(replicaContext) + } + // 按仓库同步 + if (includeAllData(this)) { + replicaByRepo(this) + return + } + replicaTaskObjectConstraints(this) + } + } + + + /** + * 判断是否包含所有仓库数据,进行仓库同步 + */ + open fun includeAllData(context: ReplicaContext): Boolean { + return false + } + + /** + * 同步task object 中的包列表或者paths + */ + open fun replicaTaskObjectConstraints(replicaContext: ReplicaContext) { + with(replicaContext) { + // 按包同步 + taskObject.packageConstraints.orEmpty().forEach { + replicaByPackageConstraint(this, it) + } + // 按路径同步 + taskObject.pathConstraints.orEmpty().forEach { + replicaByPathConstraint(this, it) + } + } + } + + /** * 同步整个仓库数据 */ diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/ReplicaService.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/ReplicaService.kt similarity index 89% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/ReplicaService.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/ReplicaService.kt index 0e38fcb5fc..e71e9f392a 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/ReplicaService.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/ReplicaService.kt @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. * - * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. * * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. * @@ -25,9 +25,9 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base +package com.tencent.bkrepo.replication.replica.type -import com.tencent.bkrepo.replication.replica.base.context.ReplicaContext +import com.tencent.bkrepo.replication.replica.context.ReplicaContext /** * 同步服务接口 diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/edge/EdgeNodeReportJob.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/edge/EdgeNodeReportJob.kt similarity index 96% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/edge/EdgeNodeReportJob.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/edge/EdgeNodeReportJob.kt index 618315a70e..54b30780bc 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/edge/EdgeNodeReportJob.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/edge/EdgeNodeReportJob.kt @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. * - * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. * * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. * @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.edge +package com.tencent.bkrepo.replication.replica.type.edge import com.tencent.bkrepo.common.service.cluster.ClusterProperties import com.tencent.bkrepo.common.service.cluster.CommitEdgeEdgeCondition diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/edge/EdgePullReplicaExecutor.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/edge/EdgePullReplicaExecutor.kt similarity index 98% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/edge/EdgePullReplicaExecutor.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/edge/EdgePullReplicaExecutor.kt index d7fdb65d56..b627606995 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/edge/EdgePullReplicaExecutor.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/edge/EdgePullReplicaExecutor.kt @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. * - * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. * * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. * @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.edge +package com.tencent.bkrepo.replication.replica.type.edge import com.tencent.bkrepo.common.api.constant.MediaTypes import com.tencent.bkrepo.common.api.util.toJsonString @@ -53,7 +53,7 @@ import com.tencent.bkrepo.replication.pojo.task.ReplicaTaskInfo import com.tencent.bkrepo.replication.pojo.task.objects.ReplicaObjectInfo import com.tencent.bkrepo.replication.pojo.task.setting.ConflictStrategy import com.tencent.bkrepo.replication.pojo.task.setting.ErrorStrategy -import com.tencent.bkrepo.replication.replica.base.OkHttpClientPool +import com.tencent.bkrepo.replication.util.OkHttpClientPool import com.tencent.bkrepo.replication.replica.base.interceptor.SignInterceptor import com.tencent.bkrepo.replication.service.ReplicaRecordService import com.tencent.bkrepo.repository.api.ProjectClient diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/edge/EdgePullReplicaTaskEvent.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/edge/EdgePullReplicaTaskEvent.kt similarity index 96% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/edge/EdgePullReplicaTaskEvent.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/edge/EdgePullReplicaTaskEvent.kt index 23c002bba6..e4c3670ead 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/edge/EdgePullReplicaTaskEvent.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/edge/EdgePullReplicaTaskEvent.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.edge +package com.tencent.bkrepo.replication.replica.type.edge data class EdgePullReplicaTaskEvent( val taskId: String, diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/edge/EdgePullReplicaTaskJob.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/edge/EdgePullReplicaTaskJob.kt similarity index 97% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/edge/EdgePullReplicaTaskJob.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/edge/EdgePullReplicaTaskJob.kt index 61262be712..3b71958920 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/edge/EdgePullReplicaTaskJob.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/edge/EdgePullReplicaTaskJob.kt @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. * - * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. * * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. * @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.edge +package com.tencent.bkrepo.replication.replica.type.edge import com.tencent.bkrepo.common.mongo.constant.MIN_OBJECT_ID import com.tencent.bkrepo.common.service.cluster.ClusterProperties @@ -38,7 +38,7 @@ import com.tencent.bkrepo.replication.model.TReplicaTask import com.tencent.bkrepo.replication.pojo.request.ReplicaType import com.tencent.bkrepo.replication.pojo.task.ReplicaStatus import com.tencent.bkrepo.replication.pojo.task.ReplicaTaskInfo -import com.tencent.bkrepo.replication.replica.base.executor.EdgePullThreadPoolExecutor +import com.tencent.bkrepo.replication.replica.executor.EdgePullThreadPoolExecutor import net.javacrumbs.shedlock.core.LockConfiguration import net.javacrumbs.shedlock.core.LockingTaskExecutor import org.slf4j.LoggerFactory diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/edge/EdgeReplicaTaskJob.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/edge/EdgeReplicaTaskJob.kt similarity index 96% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/edge/EdgeReplicaTaskJob.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/edge/EdgeReplicaTaskJob.kt index 48ca0a2f48..197e8a9d6c 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/edge/EdgeReplicaTaskJob.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/edge/EdgeReplicaTaskJob.kt @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. * - * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. * * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. * @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.edge +package com.tencent.bkrepo.replication.replica.type.edge import com.tencent.bkrepo.common.api.constant.HttpStatus import com.tencent.bkrepo.common.api.pojo.Response @@ -42,9 +42,9 @@ import com.tencent.bkrepo.replication.api.cluster.ClusterReplicaTaskClient import com.tencent.bkrepo.replication.config.ReplicationProperties import com.tencent.bkrepo.replication.pojo.record.ExecutionStatus import com.tencent.bkrepo.replication.pojo.task.EdgeReplicaTaskRecord -import com.tencent.bkrepo.replication.replica.base.OkHttpClientPool -import com.tencent.bkrepo.replication.replica.base.context.ReplicaContext -import com.tencent.bkrepo.replication.replica.base.executor.ManualThreadPoolExecutor +import com.tencent.bkrepo.replication.util.OkHttpClientPool +import com.tencent.bkrepo.replication.replica.context.ReplicaContext +import com.tencent.bkrepo.replication.replica.executor.ManualThreadPoolExecutor import com.tencent.bkrepo.replication.replica.base.interceptor.SignInterceptor import com.tencent.bkrepo.repository.api.NodeClient import com.tencent.bkrepo.repository.api.PackageClient diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/event/ArtifactEventConsumer.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/event/ArtifactEventConsumer.kt similarity index 92% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/event/ArtifactEventConsumer.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/event/ArtifactEventConsumer.kt index 32bd4aa5b1..8f834e5de2 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/event/ArtifactEventConsumer.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/event/ArtifactEventConsumer.kt @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. * - * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. * * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. * @@ -25,12 +25,12 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.event +package com.tencent.bkrepo.replication.replica.type.event import com.tencent.bkrepo.common.artifact.event.base.ArtifactEvent import com.tencent.bkrepo.common.artifact.event.base.EventType import com.tencent.bkrepo.common.service.otel.util.AsyncUtils.trace -import com.tencent.bkrepo.replication.replica.base.executor.EventConsumerThreadPoolExecutor +import com.tencent.bkrepo.replication.replica.executor.EventConsumerThreadPoolExecutor import com.tencent.bkrepo.replication.service.ReplicaTaskService import org.springframework.stereotype.Component diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/event/BootAssemblyEventListener.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/event/BootAssemblyEventListener.kt similarity index 95% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/event/BootAssemblyEventListener.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/event/BootAssemblyEventListener.kt index 3cfe27ff78..77184735ee 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/event/BootAssemblyEventListener.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/event/BootAssemblyEventListener.kt @@ -25,14 +25,14 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.event +package com.tencent.bkrepo.replication.replica.type.event import com.tencent.bkrepo.common.artifact.event.base.ArtifactEvent import com.tencent.bkrepo.common.artifact.event.node.NodeCreatedEvent import com.tencent.bkrepo.common.artifact.event.packages.VersionCreatedEvent import com.tencent.bkrepo.common.artifact.event.packages.VersionUpdatedEvent import com.tencent.bkrepo.common.service.otel.util.AsyncUtils.trace -import com.tencent.bkrepo.replication.replica.base.executor.EventConsumerThreadPoolExecutor +import com.tencent.bkrepo.replication.replica.executor.EventConsumerThreadPoolExecutor import com.tencent.bkrepo.replication.service.ReplicaTaskService import org.springframework.context.event.EventListener import org.springframework.stereotype.Component diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/event/EventBasedReplicaJobExecutor.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/event/EventBasedReplicaJobExecutor.kt similarity index 93% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/event/EventBasedReplicaJobExecutor.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/event/EventBasedReplicaJobExecutor.kt index dd26e2ef3e..582f894310 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/event/EventBasedReplicaJobExecutor.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/event/EventBasedReplicaJobExecutor.kt @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. * - * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. * * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. * @@ -25,14 +25,14 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.event +package com.tencent.bkrepo.replication.replica.type.event import com.tencent.bkrepo.common.artifact.event.base.ArtifactEvent import com.tencent.bkrepo.replication.config.ReplicationProperties import com.tencent.bkrepo.replication.manager.LocalDataManager import com.tencent.bkrepo.replication.pojo.record.ReplicaRecordInfo import com.tencent.bkrepo.replication.pojo.task.ReplicaTaskDetail -import com.tencent.bkrepo.replication.replica.base.executor.AbstractReplicaJobExecutor +import com.tencent.bkrepo.replication.replica.executor.AbstractReplicaJobExecutor import com.tencent.bkrepo.replication.service.ClusterNodeService import com.tencent.bkrepo.replication.service.ReplicaRecordService import org.slf4j.LoggerFactory diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/event/EventBasedReplicaService.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/event/EventBasedReplicaService.kt similarity index 90% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/event/EventBasedReplicaService.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/event/EventBasedReplicaService.kt index b7759aecc4..3b1be75afe 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/event/EventBasedReplicaService.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/event/EventBasedReplicaService.kt @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. * - * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. * * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. * @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.event +package com.tencent.bkrepo.replication.replica.type.event import com.tencent.bkrepo.common.api.pojo.ClusterNodeType import com.tencent.bkrepo.common.artifact.event.base.EventType @@ -35,8 +35,8 @@ import com.tencent.bkrepo.replication.constant.RETRY_COUNT import com.tencent.bkrepo.replication.manager.LocalDataManager import com.tencent.bkrepo.replication.pojo.task.objects.PackageConstraint import com.tencent.bkrepo.replication.pojo.task.objects.PathConstraint -import com.tencent.bkrepo.replication.replica.base.AbstractReplicaService -import com.tencent.bkrepo.replication.replica.base.context.ReplicaContext +import com.tencent.bkrepo.replication.replica.type.AbstractReplicaService +import com.tencent.bkrepo.replication.replica.context.ReplicaContext import com.tencent.bkrepo.replication.service.ReplicaRecordService import org.springframework.stereotype.Component @@ -53,7 +53,9 @@ class EventBasedReplicaService( with(context) { // 同步仓库 retry(times = RETRY_COUNT, delayInSeconds = DELAY_IN_SECONDS) { - replicator.replicaRepo(this) + if (task.setting.automaticCreateRemoteRepo) { + replicator.replicaRepo(this) + } } when (event.type) { EventType.NODE_CREATED -> { diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/event/EventConsumer.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/event/EventConsumer.kt similarity index 97% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/event/EventConsumer.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/event/EventConsumer.kt index 1c97bc725f..f5c63981b6 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/event/EventConsumer.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/event/EventConsumer.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.event +package com.tencent.bkrepo.replication.replica.type.event import com.tencent.bkrepo.common.artifact.event.base.ArtifactEvent import com.tencent.bkrepo.common.artifact.event.base.EventType diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/manual/ManualBasedReplicaService.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/manual/ManualBasedReplicaService.kt similarity index 51% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/manual/ManualBasedReplicaService.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/manual/ManualBasedReplicaService.kt index a31f732ec0..c7cb865ece 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/manual/ManualBasedReplicaService.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/manual/ManualBasedReplicaService.kt @@ -25,14 +25,17 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.manual +package com.tencent.bkrepo.replication.replica.type.manual import com.tencent.bkrepo.common.service.otel.util.AsyncUtils.trace import com.tencent.bkrepo.replication.config.ReplicationProperties import com.tencent.bkrepo.replication.manager.LocalDataManager -import com.tencent.bkrepo.replication.replica.base.AbstractReplicaService -import com.tencent.bkrepo.replication.replica.base.context.ReplicaContext -import com.tencent.bkrepo.replication.replica.base.executor.ManualThreadPoolExecutor +import com.tencent.bkrepo.replication.pojo.request.ReplicaObjectType +import com.tencent.bkrepo.replication.pojo.task.objects.PackageConstraint +import com.tencent.bkrepo.replication.pojo.task.objects.PathConstraint +import com.tencent.bkrepo.replication.replica.context.ReplicaContext +import com.tencent.bkrepo.replication.replica.executor.ManualThreadPoolExecutor +import com.tencent.bkrepo.replication.replica.type.AbstractReplicaService import com.tencent.bkrepo.replication.service.ReplicaRecordService import org.springframework.stereotype.Component import java.util.concurrent.Callable @@ -50,40 +53,70 @@ class ManualBasedReplicaService( ) : AbstractReplicaService(replicaRecordService, localDataManager) { private val executor = ManualThreadPoolExecutor.instance override fun replica(context: ReplicaContext) { - val semaphore = Semaphore(replicationProperties.manualConcurrencyNum) - with(context) { + replicaTaskObjects(context) + } + + /** + * 是否包含所有仓库数据 + */ + override fun includeAllData(context: ReplicaContext): Boolean { + return context.taskObject.packageConstraints.isNullOrEmpty() && + context.taskObject.pathConstraints.isNullOrEmpty() && + context.task.replicaObjectType == ReplicaObjectType.REPOSITORY + } + + /** + * 同步task object 中的包列表或者paths + */ + override fun replicaTaskObjectConstraints(replicaContext: ReplicaContext) { + with(replicaContext) { + val semaphore = Semaphore(replicationProperties.manualConcurrencyNum) + // 按包同步 val futureList = mutableListOf>() - taskObject.packageConstraints.orEmpty().forEach { - semaphore.acquire() - futureList.add( - executor.submit( - Callable{ - try { - replicaByPackageConstraint(this, it) - } finally { - semaphore.release() - } - }.trace() - ) - ) - } + // 按包同步 + mapEachTaskObject(semaphore, futureList, taskObject.packageConstraints.orEmpty(), replicaContext) // 按路径同步 - taskObject.pathConstraints.orEmpty().forEach { - semaphore.acquire() - futureList.add( - executor.submit( - Callable { - try { - replicaByPathConstraint(this, it) - } finally { - semaphore.release() - } - }.trace() - ) - ) - } + mapEachTaskObject(semaphore, futureList, taskObject.pathConstraints.orEmpty(), replicaContext) + futureList.forEach { it.get() } } } + + + /** + * 遍历执行所有分发任务 + */ + private fun mapEachTaskObject( + semaphore: Semaphore, futureList: MutableList>, + taskObjects: List, context: ReplicaContext + ) { + for (taskObject in taskObjects) { + semaphore.acquire() + futureList.add( + executor.submit( + Callable{ + try { + replicaTaskObject(context, taskObject) + } finally { + semaphore.release() + } + }.trace() + ) + ) + } + } + + /** + * 分发具体内容 + */ + private fun replicaTaskObject(replicaContext: ReplicaContext, constraint: Any) { + if (constraint is PathConstraint) { + replicaByPathConstraint(replicaContext, constraint) + } + if (constraint is PackageConstraint) { + replicaByPackageConstraint(replicaContext, constraint) + } + } + } diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/manual/ManualReplicaJobExecutor.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/manual/ManualReplicaJobExecutor.kt similarity index 97% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/manual/ManualReplicaJobExecutor.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/manual/ManualReplicaJobExecutor.kt index a997ebf55c..1b099b6057 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/manual/ManualReplicaJobExecutor.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/manual/ManualReplicaJobExecutor.kt @@ -25,14 +25,14 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.manual +package com.tencent.bkrepo.replication.replica.type.manual import com.tencent.bkrepo.replication.config.ReplicationProperties import com.tencent.bkrepo.replication.manager.LocalDataManager import com.tencent.bkrepo.replication.pojo.record.ExecutionStatus import com.tencent.bkrepo.replication.pojo.task.ReplicaStatus import com.tencent.bkrepo.replication.pojo.task.ReplicaTaskDetail -import com.tencent.bkrepo.replication.replica.base.executor.AbstractReplicaJobExecutor +import com.tencent.bkrepo.replication.replica.executor.AbstractReplicaJobExecutor import com.tencent.bkrepo.replication.service.ClusterNodeService import com.tencent.bkrepo.replication.service.ReplicaRecordService import com.tencent.bkrepo.replication.service.impl.ReplicaRecordServiceImpl.Companion.isCronJob diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/schedule/ReplicaTaskScheduler.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/schedule/ReplicaTaskScheduler.kt similarity index 96% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/schedule/ReplicaTaskScheduler.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/schedule/ReplicaTaskScheduler.kt index 78838c1db9..5d3a12091c 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/schedule/ReplicaTaskScheduler.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/schedule/ReplicaTaskScheduler.kt @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. * - * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. * * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. * @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.schedule +package com.tencent.bkrepo.replication.replica.type.schedule import org.quartz.JobDetail import org.quartz.JobKey diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/schedule/ScheduledReplicaJob.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/schedule/ScheduledReplicaJob.kt similarity index 95% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/schedule/ScheduledReplicaJob.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/schedule/ScheduledReplicaJob.kt index 26eb88654d..e468d928bf 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/schedule/ScheduledReplicaJob.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/schedule/ScheduledReplicaJob.kt @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. * - * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. * * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. * @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.schedule +package com.tencent.bkrepo.replication.replica.type.schedule import com.tencent.bkrepo.common.service.util.SpringContextUtils import net.javacrumbs.shedlock.core.LockConfiguration diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/schedule/ScheduledReplicaJobExecutor.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/schedule/ScheduledReplicaJobExecutor.kt similarity index 96% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/schedule/ScheduledReplicaJobExecutor.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/schedule/ScheduledReplicaJobExecutor.kt index 3f16b7447b..c76a213e5b 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/schedule/ScheduledReplicaJobExecutor.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/schedule/ScheduledReplicaJobExecutor.kt @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. * - * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. * * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. * @@ -25,13 +25,13 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.schedule +package com.tencent.bkrepo.replication.replica.type.schedule import com.tencent.bkrepo.replication.config.ReplicationProperties import com.tencent.bkrepo.replication.manager.LocalDataManager import com.tencent.bkrepo.replication.pojo.record.ExecutionStatus import com.tencent.bkrepo.replication.pojo.task.ReplicaTaskInfo -import com.tencent.bkrepo.replication.replica.base.executor.AbstractReplicaJobExecutor +import com.tencent.bkrepo.replication.replica.executor.AbstractReplicaJobExecutor import com.tencent.bkrepo.replication.service.ClusterNodeService import com.tencent.bkrepo.replication.service.ReplicaRecordService import com.tencent.bkrepo.replication.service.ReplicaTaskService diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/schedule/ScheduledReplicaService.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/schedule/ScheduledReplicaService.kt similarity index 70% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/schedule/ScheduledReplicaService.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/schedule/ScheduledReplicaService.kt index 79ff8f1f87..6b83a8dacf 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/schedule/ScheduledReplicaService.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/schedule/ScheduledReplicaService.kt @@ -25,11 +25,11 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.schedule +package com.tencent.bkrepo.replication.replica.type.schedule import com.tencent.bkrepo.replication.manager.LocalDataManager -import com.tencent.bkrepo.replication.replica.base.AbstractReplicaService -import com.tencent.bkrepo.replication.replica.base.context.ReplicaContext +import com.tencent.bkrepo.replication.replica.type.AbstractReplicaService +import com.tencent.bkrepo.replication.replica.context.ReplicaContext import com.tencent.bkrepo.replication.service.ReplicaRecordService import org.springframework.stereotype.Component @@ -43,33 +43,13 @@ class ScheduledReplicaService( ) : AbstractReplicaService(replicaRecordService, localDataManager) { override fun replica(context: ReplicaContext) { - with(context) { - // 检查版本 - replicator.checkVersion(this) - // 同步项目 - replicator.replicaProject(this) - // 同步仓库 - replicator.replicaRepo(this) - // 按仓库同步 - if (includeAllData(this)) { - replicaByRepo(this) - return - } - // 按包同步 - taskObject.packageConstraints.orEmpty().forEach { - replicaByPackageConstraint(this, it) - } - // 按路径同步 - taskObject.pathConstraints.orEmpty().forEach { - replicaByPathConstraint(this, it) - } - } + replicaTaskObjects(context) } /** * 是否包含所有仓库数据 */ - private fun includeAllData(context: ReplicaContext): Boolean { + override fun includeAllData(context: ReplicaContext): Boolean { return context.taskObject.packageConstraints.isNullOrEmpty() && context.taskObject.pathConstraints.isNullOrEmpty() } diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/schedule/TaskReloadManager.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/schedule/TaskReloadManager.kt similarity index 94% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/schedule/TaskReloadManager.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/schedule/TaskReloadManager.kt index c056572277..19314ef843 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/schedule/TaskReloadManager.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/schedule/TaskReloadManager.kt @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. * - * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. * * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. * @@ -25,13 +25,13 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.schedule +package com.tencent.bkrepo.replication.replica.type.schedule import com.tencent.bkrepo.common.service.cluster.StandaloneJob import com.tencent.bkrepo.replication.pojo.task.ReplicaTaskInfo import com.tencent.bkrepo.replication.pojo.task.setting.ExecutionStrategy -import com.tencent.bkrepo.replication.replica.schedule.ReplicaTaskScheduler.Companion.JOB_DATA_TASK_KEY -import com.tencent.bkrepo.replication.replica.schedule.ReplicaTaskScheduler.Companion.REPLICA_JOB_GROUP +import com.tencent.bkrepo.replication.replica.type.schedule.ReplicaTaskScheduler.Companion.JOB_DATA_TASK_KEY +import com.tencent.bkrepo.replication.replica.type.schedule.ReplicaTaskScheduler.Companion.REPLICA_JOB_GROUP import com.tencent.bkrepo.replication.service.ReplicaTaskService import org.quartz.CronScheduleBuilder import org.quartz.JobBuilder diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/service/EdgeReplicaTaskRecordService.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/service/EdgeReplicaTaskRecordService.kt index a317f5b362..aa6705b8c6 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/service/EdgeReplicaTaskRecordService.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/service/EdgeReplicaTaskRecordService.kt @@ -29,7 +29,7 @@ package com.tencent.bkrepo.replication.service import com.tencent.bkrepo.replication.pojo.record.ExecutionStatus import com.tencent.bkrepo.replication.pojo.task.EdgeReplicaTaskRecord -import com.tencent.bkrepo.replication.replica.base.context.ReplicaContext +import com.tencent.bkrepo.replication.replica.context.ReplicaContext import com.tencent.bkrepo.repository.pojo.node.NodeDetail import com.tencent.bkrepo.repository.pojo.packages.PackageSummary import com.tencent.bkrepo.repository.pojo.packages.PackageVersion diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/service/impl/EdgeReplicaTaskRecordServiceImpl.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/service/impl/EdgeReplicaTaskRecordServiceImpl.kt index 9c61728148..d0c3c649b8 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/service/impl/EdgeReplicaTaskRecordServiceImpl.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/service/impl/EdgeReplicaTaskRecordServiceImpl.kt @@ -35,7 +35,7 @@ import com.tencent.bkrepo.replication.exception.ReplicationMessageCode import com.tencent.bkrepo.replication.model.TEdgeReplicaTaskRecord import com.tencent.bkrepo.replication.pojo.record.ExecutionStatus import com.tencent.bkrepo.replication.pojo.task.EdgeReplicaTaskRecord -import com.tencent.bkrepo.replication.replica.base.context.ReplicaContext +import com.tencent.bkrepo.replication.replica.context.ReplicaContext import com.tencent.bkrepo.replication.service.EdgeReplicaTaskRecordService import com.tencent.bkrepo.repository.pojo.node.NodeDetail import com.tencent.bkrepo.repository.pojo.packages.PackageSummary diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/service/impl/RemoteNodeServiceImpl.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/service/impl/RemoteNodeServiceImpl.kt index 4cb6ffba58..0b08923d27 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/service/impl/RemoteNodeServiceImpl.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/service/impl/RemoteNodeServiceImpl.kt @@ -61,9 +61,9 @@ import com.tencent.bkrepo.replication.pojo.task.objects.ReplicaObjectInfo import com.tencent.bkrepo.replication.pojo.task.request.ReplicaTaskCreateRequest import com.tencent.bkrepo.replication.pojo.task.request.ReplicaTaskUpdateRequest import com.tencent.bkrepo.replication.pojo.task.setting.ConflictStrategy -import com.tencent.bkrepo.replication.replica.base.executor.RunOnceThreadPoolExecutor -import com.tencent.bkrepo.replication.replica.event.EventBasedReplicaJobExecutor -import com.tencent.bkrepo.replication.replica.manual.ManualReplicaJobExecutor +import com.tencent.bkrepo.replication.replica.executor.RunOnceThreadPoolExecutor +import com.tencent.bkrepo.replication.replica.type.event.EventBasedReplicaJobExecutor +import com.tencent.bkrepo.replication.replica.type.manual.ManualReplicaJobExecutor import com.tencent.bkrepo.replication.service.ClusterNodePermissionService import com.tencent.bkrepo.replication.service.ClusterNodeService import com.tencent.bkrepo.replication.service.RemoteNodeService @@ -99,24 +99,7 @@ class RemoteNodeServiceImpl( ): List { return requests.configs.map { validateName(it.name) - val realName = NAME.format(projectId, repoName, it.name) - val tClusterNode = if (it.clusterId.isNullOrEmpty()) { - val oldCluster = clusterNodeService.getByClusterName(realName) - if (oldCluster == null) { - clusterNodeService.create( - SecurityUtils.getUserId(), buildClusterNodeCreateRequest(projectId, repoName, it) - ) - } else { - val updateRequest = convertCreateToUpdate(it) - clusterNodeService.update( - buildClusterNodeUpdateRequest(projectId, repoName, it.name, updateRequest) - ) - } - } else { - clusterNodeService.getByClusterId(it.clusterId!!) - ?: throw ErrorCodeException(ReplicationMessageCode.CLUSTER_NODE_NOT_FOUND, it.clusterId!!) - } - + val tClusterNode = createClusterInfo(projectId, repoName, it) createOrUpdateTask( projectId = projectId, repoName = repoName, @@ -231,34 +214,6 @@ class RemoteNodeServiceImpl( } - private fun createWithRemoteClient( - projectId: String, repoName: String, - request: RemoteRunOnceTaskCreateRequest - ): Boolean { - val host = if (!request.clusterId.isNullOrEmpty()) { - val clusterInfo = clusterNodeService.getByClusterId(request.clusterId!!) - ?: throw ErrorCodeException(ReplicationMessageCode.CLUSTER_NODE_NOT_FOUND, request.clusterId!!) - clusterInfo.url - } else { - addProtocol(request.registry!!).toString() - } - buildExecuteClientWithHost(host)?.let { - try{ - it.createRunOnceTask(projectId, repoName, request) - return true - } catch (e: Exception) { - // fegin连不上时需要降级为本地执行 - logger.warn("Cloud not run task on remote node, will run with current node") - } - } - return false - } - - private fun buildExecuteClientWithHost(host: String) : ReplicaTaskOperationClient? { - return replicaNodeDispatchService.findReplicaClientByHost( - host, ReplicaTaskOperationClient::class.java - ) - } // dispatch 默认为TRUE, fegin调用时为FALSE,避免feign调用时再次进行配置判断 override fun executeRunOnceTask(projectId: String, repoName: String, name: String, dispatch: Boolean) { @@ -273,34 +228,6 @@ class RemoteNodeServiceImpl( } - /** - * 执行成功返回true,fegin连不上时需要降级为本地执行,返回false - */ - private fun executeWithRemoteClient( - projectId: String, repoName: String, name: String, - taskDetail: ReplicaTaskDetail - ): Boolean { - buildExecuteClient(taskDetail)?.let { - try{ - it.executeRunOnceTask(projectId, repoName, name) - return true - } catch (e: Exception) { - // fegin连不上时需要降级为本地执行 - logger.warn("Cloud not run task on remote node, will run with current node") - } - } - return false - } - - - private fun buildExecuteClient( - taskDetail: ReplicaTaskDetail - ) : ReplicaTaskOperationClient? { - return replicaNodeDispatchService.findReplicaClient( - taskDetail, ReplicaTaskOperationClient::class.java - ) - } - override fun getRunOnceTaskResult(projectId: String, repoName: String, name: String): ReplicaRecordInfo? { val taskInfo = getReplicaTaskInfo(projectId, repoName, name) val record = replicaRecordService.findLatestRecord(taskInfo.key) @@ -323,38 +250,35 @@ class RemoteNodeServiceImpl( deleteByTaskName(taskName) } - private fun deleteByTaskName(taskName: String) { - logger.info("Task $taskName will be deleted!") - replicaTaskService.getByTaskName(taskName)?.let { - if (it.status!! != ReplicaStatus.COMPLETED && it.replicaType != ReplicaType.RUN_ONCE) { - logger.warn("The name $taskName of runonce task is still running") - throw ErrorCodeException(CommonMessageCode.REQUEST_DENIED, taskName) - } - clusterNodeService.getByClusterName(taskName)?.let { node -> - clusterNodeService.deleteById(node.id!!) - } - replicaTaskService.deleteByTaskKey(it.key) - } - } - - private fun getTaskDetail( + /** + * 根据分发任务内容创建对应的集群信息 + */ + private fun createClusterInfo( projectId: String, repoName: String, - name: String - ): ReplicaTaskDetail { - val taskInfo = getReplicaTaskInfo(projectId, repoName, name) - return replicaTaskService.getDetailByTaskKey(taskInfo.key) + request: RemoteConfigCreateRequest + ): ClusterNodeInfo { + val realName = NAME.format(projectId, repoName, request.name) + // clusterId为空的情况默认为remote集群 + return if (request.clusterId.isNullOrEmpty()) { + val oldCluster = clusterNodeService.getByClusterName(realName) + if (oldCluster == null) { + clusterNodeService.create( + SecurityUtils.getUserId(), buildClusterNodeCreateRequest(projectId, repoName, request) + ) + } else { + val updateRequest = convertCreateToUpdate(request) + clusterNodeService.update( + buildClusterNodeUpdateRequest(projectId, repoName, request.name, updateRequest) + ) + } + } else { + // clusterId不为空则任务是通过集群,同构集群都是在任务创建前已经创建 + clusterNodeService.getByClusterId(request.clusterId!!) + ?: throw ErrorCodeException(ReplicationMessageCode.CLUSTER_NODE_NOT_FOUND, request.clusterId!!) + } } - private fun getReplicaTaskInfo( - projectId: String, - repoName: String, - name: String - ): ReplicaTaskInfo { - val realName = NAME.format(projectId, repoName, name) - return replicaTaskService.getByTaskName(realName) - ?: throw ErrorCodeException(CommonMessageCode.RESOURCE_NOT_FOUND, name) - } /** * 当远端集群创建后,创建/更新对应的任务 @@ -372,29 +296,12 @@ class RemoteNodeServiceImpl( ) val repositoryDetail = localDataManager.findRepoByName(projectId, repoName) - if (pathConstraints.isNullOrEmpty() && packageConstraints.isNullOrEmpty() - && replicaType == ReplicaType.RUN_ONCE) { - throw ErrorCodeException(CommonMessageCode.PARAMETER_INVALID, "Package or path") - } - val replicaTaskObjects = listOf( - ReplicaObjectInfo( - localRepoName = repoName, - repoType = repositoryDetail.type, - remoteProjectId = remoteProjectId, - remoteRepoName = remoteRepoName, - packageConstraints = packageConstraints, - pathConstraints = pathConstraints - ) + // 只有在同构集群内部才可以通过一次性分发任务进行仓库同步 + validateReplicaObject(request, clusterInfo) + val replicaObjectType = getReplicaObjectType(request) + val replicaTaskObjects = buildReplicaTaskObjects( + repoName, repositoryDetail.type, replicaObjectType, request ) - val replicaObjectType = if (replicaType == ReplicaType.RUN_ONCE) { - if (!pathConstraints.isNullOrEmpty()) { - ReplicaObjectType.PATH - } else { - ReplicaObjectType.PACKAGE - } - } else { - ReplicaObjectType.REPOSITORY - } var task = replicaTaskService.getByTaskName(NAME.format(projectId, repoName, name)) if (task == null) { val taskCreateRequest = ReplicaTaskCreateRequest( @@ -439,6 +346,72 @@ class RemoteNodeServiceImpl( } } + /** + * 校验分发内容 + */ + private fun validateReplicaObject( + request: RemoteConfigCreateRequest, + clusterInfo: ClusterNodeInfo + ) { + with(request) { + // 兼容历史数据,replicaObjectType为空的情况 + if (pathConstraints.isNullOrEmpty() && packageConstraints.isNullOrEmpty() && + clusterInfo.type == ClusterNodeType.REMOTE) { + throw ErrorCodeException(CommonMessageCode.PARAMETER_INVALID, "Package or path") + } + + if (pathConstraints.isNullOrEmpty() && packageConstraints.isNullOrEmpty() && + replicaObjectType != ReplicaObjectType.REPOSITORY) { + throw ErrorCodeException(CommonMessageCode.PARAMETER_INVALID, "Package or path") + } + } + } + + + /** + * 获取对应分发任务的内容类型 + */ + private fun getReplicaObjectType(request: RemoteConfigCreateRequest): ReplicaObjectType { + with(request) { + if (replicaObjectType != null) return replicaObjectType!! + return if (replicaType == ReplicaType.RUN_ONCE) { + if (!pathConstraints.isNullOrEmpty()) { + ReplicaObjectType.PATH + } else { + ReplicaObjectType.PACKAGE + } + } else { + ReplicaObjectType.REPOSITORY + } + } + } + + private fun buildReplicaTaskObjects( + repoName: String, + repoType: RepositoryType, + replicaObjectType: ReplicaObjectType, + request: RemoteConfigCreateRequest + ): List { + with(request) { + val taskObjects = mutableListOf() + val (packageConstraints, pathConstraints) = if (replicaObjectType == ReplicaObjectType.REPOSITORY) { + Pair(null, null) + } else { + Pair(packageConstraints, pathConstraints) + } + taskObjects.add(ReplicaObjectInfo( + localRepoName = repoName, + repoType = repoType, + remoteProjectId = remoteProjectId, + remoteRepoName = remoteRepoName, + packageConstraints = packageConstraints, + pathConstraints = pathConstraints + )) + return taskObjects + } + } + + private fun getRemoteInfoByName( projectId: String, repoName: String, @@ -456,6 +429,103 @@ class RemoteNodeServiceImpl( } } + private fun getTaskDetail( + projectId: String, + repoName: String, + name: String + ): ReplicaTaskDetail { + val taskInfo = getReplicaTaskInfo(projectId, repoName, name) + return replicaTaskService.getDetailByTaskKey(taskInfo.key) + } + + + + private fun createWithRemoteClient( + projectId: String, repoName: String, + request: RemoteRunOnceTaskCreateRequest + ): Boolean { + val host = if (!request.clusterId.isNullOrEmpty()) { + val clusterInfo = clusterNodeService.getByClusterId(request.clusterId!!) + ?: throw ErrorCodeException(ReplicationMessageCode.CLUSTER_NODE_NOT_FOUND, request.clusterId!!) + clusterInfo.url + } else { + addProtocol(request.registry!!).toString() + } + buildExecuteClientWithHost(host)?.let { + try{ + it.createRunOnceTask(projectId, repoName, request) + return true + } catch (e: Exception) { + // fegin连不上时需要降级为本地执行 + logger.warn("Cloud not run task on remote node, will run with current node") + } + } + return false + } + + private fun buildExecuteClientWithHost(host: String) : ReplicaTaskOperationClient? { + return replicaNodeDispatchService.findReplicaClientByHost( + host, ReplicaTaskOperationClient::class.java + ) + } + + + /** + * 执行成功返回true,fegin连不上时需要降级为本地执行,返回false + */ + private fun executeWithRemoteClient( + projectId: String, repoName: String, name: String, + taskDetail: ReplicaTaskDetail + ): Boolean { + buildExecuteClient(taskDetail)?.let { + try{ + it.executeRunOnceTask(projectId, repoName, name) + return true + } catch (e: Exception) { + // fegin连不上时需要降级为本地执行 + logger.warn("Cloud not run task on remote node, will run with current node") + } + } + return false + } + + + private fun buildExecuteClient( + taskDetail: ReplicaTaskDetail + ) : ReplicaTaskOperationClient? { + return replicaNodeDispatchService.findReplicaClient( + taskDetail, ReplicaTaskOperationClient::class.java + ) + } + + + + private fun getReplicaTaskInfo( + projectId: String, + repoName: String, + name: String + ): ReplicaTaskInfo { + val realName = NAME.format(projectId, repoName, name) + return replicaTaskService.getByTaskName(realName) + ?: throw ErrorCodeException(CommonMessageCode.RESOURCE_NOT_FOUND, name) + } + + + private fun deleteByTaskName(taskName: String) { + logger.info("Task $taskName will be deleted!") + replicaTaskService.getByTaskName(taskName)?.let { + if (it.status!! != ReplicaStatus.COMPLETED && it.replicaType != ReplicaType.RUN_ONCE) { + logger.warn("The name $taskName of runonce task is still running") + throw ErrorCodeException(CommonMessageCode.REQUEST_DENIED, taskName) + } + clusterNodeService.getByClusterName(taskName)?.let { node -> + clusterNodeService.deleteById(node.id!!) + } + replicaTaskService.deleteByTaskKey(it.key) + } + } + + private fun buildClusterNodeCreateRequest( projectId: String, repoName: String, @@ -530,6 +600,7 @@ class RemoteNodeServiceImpl( remoteUserPassword = remoteUserPassword, remoteProjectId = remoteProjectId, remoteRepoName = remoteRepoName, + replicaObjectType = replicaObjectType, packageConstraints = packageConstraints, pathConstraints = pathConstraints, replicaType = replicaType, @@ -551,6 +622,7 @@ class RemoteNodeServiceImpl( remoteUserUsername = remoteUserUsername, remoteUserPassword = remoteUserPassword, packageConstraints = packageConstraints, + replicaObjectType = replicaObjectType, pathConstraints = pathConstraints, replicaType = replicaType, setting = setting, @@ -577,6 +649,7 @@ class RemoteNodeServiceImpl( remoteUserPassword = remoteUserPassword, remoteProjectId = remoteProjectId, remoteRepoName = remoteRepoName, + replicaObjectType = replicaObjectType, packageConstraints = packageConstraints, pathConstraints = pathConstraints, replicaType = replicaType, diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/service/impl/ReplicaExtServiceImpl.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/service/impl/ReplicaExtServiceImpl.kt index 0b62dfb9b3..2e9430f19e 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/service/impl/ReplicaExtServiceImpl.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/service/impl/ReplicaExtServiceImpl.kt @@ -56,9 +56,9 @@ import com.tencent.bkrepo.replication.pojo.task.objects.PackageConstraint import com.tencent.bkrepo.replication.pojo.task.objects.PathConstraint import com.tencent.bkrepo.replication.pojo.task.setting.ConflictStrategy import com.tencent.bkrepo.replication.pojo.task.setting.ReplicaSetting -import com.tencent.bkrepo.replication.replica.base.OkHttpClientPool -import com.tencent.bkrepo.replication.replica.base.context.ReplicaContext.Companion.READ_TIMEOUT -import com.tencent.bkrepo.replication.replica.base.context.ReplicaContext.Companion.WRITE_TIMEOUT +import com.tencent.bkrepo.replication.util.OkHttpClientPool +import com.tencent.bkrepo.replication.replica.context.ReplicaContext.Companion.READ_TIMEOUT +import com.tencent.bkrepo.replication.replica.context.ReplicaContext.Companion.WRITE_TIMEOUT import com.tencent.bkrepo.replication.service.RemoteNodeService import com.tencent.bkrepo.replication.service.ReplicaExtService import com.tencent.bkrepo.repository.api.NodeClient diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/service/impl/ReplicaTaskServiceImpl.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/service/impl/ReplicaTaskServiceImpl.kt index d8332ac286..01f651d857 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/service/impl/ReplicaTaskServiceImpl.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/service/impl/ReplicaTaskServiceImpl.kt @@ -56,11 +56,11 @@ import com.tencent.bkrepo.replication.pojo.task.request.ReplicaTaskCreateRequest import com.tencent.bkrepo.replication.pojo.task.request.ReplicaTaskUpdateRequest import com.tencent.bkrepo.replication.pojo.task.request.TaskPageParam import com.tencent.bkrepo.replication.pojo.task.setting.ExecutionStrategy -import com.tencent.bkrepo.replication.replica.edge.EdgePullReplicaExecutor -import com.tencent.bkrepo.replication.replica.schedule.ReplicaTaskScheduler -import com.tencent.bkrepo.replication.replica.schedule.ReplicaTaskScheduler.Companion.JOB_DATA_TASK_KEY -import com.tencent.bkrepo.replication.replica.schedule.ReplicaTaskScheduler.Companion.REPLICA_JOB_GROUP -import com.tencent.bkrepo.replication.replica.schedule.ScheduledReplicaJob +import com.tencent.bkrepo.replication.replica.type.edge.EdgePullReplicaExecutor +import com.tencent.bkrepo.replication.replica.type.schedule.ReplicaTaskScheduler +import com.tencent.bkrepo.replication.replica.type.schedule.ReplicaTaskScheduler.Companion.JOB_DATA_TASK_KEY +import com.tencent.bkrepo.replication.replica.type.schedule.ReplicaTaskScheduler.Companion.REPLICA_JOB_GROUP +import com.tencent.bkrepo.replication.replica.type.schedule.ScheduledReplicaJob import com.tencent.bkrepo.replication.service.ClusterNodeService import com.tencent.bkrepo.replication.service.ReplicaRecordService import com.tencent.bkrepo.replication.service.ReplicaTaskService diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/handler/DefaultHandler.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/util/DefaultHandler.kt similarity index 95% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/handler/DefaultHandler.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/util/DefaultHandler.kt index 7b301a3ceb..f62dc089cb 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/handler/DefaultHandler.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/util/DefaultHandler.kt @@ -25,15 +25,14 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.replication.replica.base.handler +package com.tencent.bkrepo.replication.util import com.tencent.bkrepo.common.api.constant.HttpHeaders import com.tencent.bkrepo.common.api.util.JsonUtils import com.tencent.bkrepo.common.api.util.toJsonString +import com.tencent.bkrepo.replication.exception.ArtifactPushException import com.tencent.bkrepo.replication.pojo.remote.DefaultHandlerResult import com.tencent.bkrepo.replication.pojo.remote.RequestProperty -import com.tencent.bkrepo.replication.replica.base.impl.remote.exception.ArtifactPushException -import com.tencent.bkrepo.replication.util.HttpUtils import okhttp3.OkHttpClient import okhttp3.Response diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/OkHttpClientPool.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/util/OkHttpClientPool.kt similarity index 50% rename from src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/OkHttpClientPool.kt rename to src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/util/OkHttpClientPool.kt index e6bb5caa62..d639aa9b1a 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/base/OkHttpClientPool.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/util/OkHttpClientPool.kt @@ -1,4 +1,31 @@ -package com.tencent.bkrepo.replication.replica.base +/* + * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. + * + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. + * + * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. + * + * A copy of the MIT License is included in this file. + * + * + * Terms of the MIT License: + * --------------------------------------------------- + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.tencent.bkrepo.replication.util import com.tencent.bkrepo.common.service.cluster.ClusterInfo import com.tencent.bkrepo.common.service.util.okhttp.HttpClientBuilderFactory diff --git a/src/backend/replication/biz-replication/src/test/kotlin/com/tencent/bkrepo/replication/QuartzJobReloadTest.kt b/src/backend/replication/biz-replication/src/test/kotlin/com/tencent/bkrepo/replication/QuartzJobReloadTest.kt index 43278ca818..0799a4d68c 100644 --- a/src/backend/replication/biz-replication/src/test/kotlin/com/tencent/bkrepo/replication/QuartzJobReloadTest.kt +++ b/src/backend/replication/biz-replication/src/test/kotlin/com/tencent/bkrepo/replication/QuartzJobReloadTest.kt @@ -27,8 +27,8 @@ package com.tencent.bkrepo.replication -import com.tencent.bkrepo.replication.replica.schedule.ReplicaTaskScheduler -import com.tencent.bkrepo.replication.replica.schedule.ReplicaTaskScheduler.Companion.REPLICA_JOB_GROUP +import com.tencent.bkrepo.replication.replica.type.schedule.ReplicaTaskScheduler +import com.tencent.bkrepo.replication.replica.type.schedule.ReplicaTaskScheduler.Companion.REPLICA_JOB_GROUP import org.junit.jupiter.api.Test import org.quartz.InterruptableJob import org.quartz.JobBuilder diff --git a/src/backend/replication/biz-replication/src/test/kotlin/com/tencent/bkrepo/replication/service/TaskReloadManagerTest.kt b/src/backend/replication/biz-replication/src/test/kotlin/com/tencent/bkrepo/replication/service/TaskReloadManagerTest.kt index d340d30271..daa60fed05 100644 --- a/src/backend/replication/biz-replication/src/test/kotlin/com/tencent/bkrepo/replication/service/TaskReloadManagerTest.kt +++ b/src/backend/replication/biz-replication/src/test/kotlin/com/tencent/bkrepo/replication/service/TaskReloadManagerTest.kt @@ -42,9 +42,9 @@ import com.tencent.bkrepo.replication.pojo.task.objects.ReplicaObjectInfo import com.tencent.bkrepo.replication.pojo.task.request.ReplicaTaskCreateRequest import com.tencent.bkrepo.replication.pojo.task.setting.ExecutionPlan import com.tencent.bkrepo.replication.pojo.task.setting.ReplicaSetting -import com.tencent.bkrepo.replication.replica.schedule.ReplicaTaskScheduler -import com.tencent.bkrepo.replication.replica.schedule.ScheduledReplicaJobExecutor -import com.tencent.bkrepo.replication.replica.schedule.TaskReloadManager +import com.tencent.bkrepo.replication.replica.type.schedule.ReplicaTaskScheduler +import com.tencent.bkrepo.replication.replica.type.schedule.ScheduledReplicaJobExecutor +import com.tencent.bkrepo.replication.replica.type.schedule.TaskReloadManager import com.tencent.bkrepo.replication.service.impl.ReplicaTaskServiceImpl import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll