From 78ade12ae64a18f6850fd2fa1bc97c77dcd0deb7 Mon Sep 17 00:00:00 2001 From: zacYL <100330102+zacYL@users.noreply.github.com> Date: Tue, 6 Aug 2024 16:34:17 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=A7=A3=E5=86=B3=E5=8D=95=E4=BD=93?= =?UTF-8?q?=E7=B1=BB=E5=8A=A0=E8=BD=BD=E5=86=B2=E7=AA=81#2461?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 解决单体类加载冲突#2461 * feat: 解决DdcMeterBinder循环依赖#2461 * feat: 解决BDZipManager循环依赖#2461 * feat: 解决循环依赖#2461 * feat: 解决单体类加载报错#2461 --- .../bkrepo/analyst/configuration/ScannerConfiguration.kt | 6 +++--- .../{ScanEventConsumer.kt => AnalystScanEventConsumer.kt} | 4 ++-- .../tencent/bkrepo/archive/core/archive/ArchiveManager.kt | 5 ++++- .../tencent/bkrepo/archive/core/compress/BDZipManager.kt | 6 +++++- .../kotlin/com/tencent/bkrepo/ddc/metrics/DdcMeterBinder.kt | 6 +++++- .../tencent/bkrepo/webhook/config/WebHookConsumerConfig.kt | 6 +++--- ...factEventConsumer.kt => WebhookArtifactEventConsumer.kt} | 4 ++-- 7 files changed, 24 insertions(+), 13 deletions(-) rename src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/event/{ScanEventConsumer.kt => AnalystScanEventConsumer.kt} (98%) rename src/backend/webhook/biz-webhook/src/main/kotlin/com/tencent/bkrepo/webhook/executor/{ArtifactEventConsumer.kt => WebhookArtifactEventConsumer.kt} (97%) diff --git a/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/configuration/ScannerConfiguration.kt b/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/configuration/ScannerConfiguration.kt index 902b98c4a2..03e0c4b654 100644 --- a/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/configuration/ScannerConfiguration.kt +++ b/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/configuration/ScannerConfiguration.kt @@ -30,7 +30,7 @@ package com.tencent.bkrepo.analyst.configuration import com.tencent.bkrepo.analysis.executor.api.ExecutorClient import com.tencent.bkrepo.analyst.dispatcher.SubtaskDispatcherFactory import com.tencent.bkrepo.analyst.dispatcher.SubtaskPoller -import com.tencent.bkrepo.analyst.event.ScanEventConsumer +import com.tencent.bkrepo.analyst.event.AnalystScanEventConsumer import com.tencent.bkrepo.analyst.service.ExecutionClusterService import com.tencent.bkrepo.analyst.service.ScannerService import com.tencent.bkrepo.analyst.service.impl.OperateLogServiceImpl @@ -91,10 +91,10 @@ class ScannerConfiguration { @Bean("scanEventConsumer") fun scanEventConsumer( - scanEventConsumer: ScanEventConsumer + analystScanEventConsumer: AnalystScanEventConsumer ): Consumer { return Consumer { - scanEventConsumer.accept(it) + analystScanEventConsumer.accept(it) } } } diff --git a/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/event/ScanEventConsumer.kt b/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/event/AnalystScanEventConsumer.kt similarity index 98% rename from src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/event/ScanEventConsumer.kt rename to src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/event/AnalystScanEventConsumer.kt index aea9aa3757..d0bd3fccd7 100644 --- a/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/event/ScanEventConsumer.kt +++ b/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/event/AnalystScanEventConsumer.kt @@ -63,7 +63,7 @@ import org.springframework.stereotype.Component * 对应binding name为scanEventConsumer-in-0 */ @Component -class ScanEventConsumer( +class AnalystScanEventConsumer( private val spdxLicenseService: SpdxLicenseService, private val scanService: ScanService, private val scannerService: ScannerService, @@ -287,6 +287,6 @@ class ScanEventConsumer( } companion object { - private val logger = LoggerFactory.getLogger(ScanEventConsumer::class.java) + private val logger = LoggerFactory.getLogger(AnalystScanEventConsumer::class.java) } } diff --git a/src/backend/archive/biz-archive/src/main/kotlin/com/tencent/bkrepo/archive/core/archive/ArchiveManager.kt b/src/backend/archive/biz-archive/src/main/kotlin/com/tencent/bkrepo/archive/core/archive/ArchiveManager.kt index 2cd61c9812..115cd43037 100644 --- a/src/backend/archive/biz-archive/src/main/kotlin/com/tencent/bkrepo/archive/core/archive/ArchiveManager.kt +++ b/src/backend/archive/biz-archive/src/main/kotlin/com/tencent/bkrepo/archive/core/archive/ArchiveManager.kt @@ -39,7 +39,6 @@ import java.util.function.Function class ArchiveManager( private val archiveProperties: ArchiveProperties, private val fileProvider: PriorityFileProvider, - private val storageService: StorageService, ) : Function> { @Autowired @Lazy @@ -49,6 +48,10 @@ class ArchiveManager( @Lazy private lateinit var archiveFileRepository: ArchiveFileRepository + @Autowired + @Lazy + private lateinit var storageService: StorageService + private val tika = Tika() private val compressPool = ArchiveUtils.newFixedAndCachedThreadPool( archiveProperties.compress.compressThreads, diff --git a/src/backend/archive/biz-archive/src/main/kotlin/com/tencent/bkrepo/archive/core/compress/BDZipManager.kt b/src/backend/archive/biz-archive/src/main/kotlin/com/tencent/bkrepo/archive/core/compress/BDZipManager.kt index 55f29c148b..237bc9e393 100644 --- a/src/backend/archive/biz-archive/src/main/kotlin/com/tencent/bkrepo/archive/core/compress/BDZipManager.kt +++ b/src/backend/archive/biz-archive/src/main/kotlin/com/tencent/bkrepo/archive/core/compress/BDZipManager.kt @@ -42,7 +42,6 @@ import java.util.function.Function @Component class BDZipManager( private val archiveProperties: ArchiveProperties, - private val storageService: StorageService, private val fileProvider: PriorityFileProvider, ) : Function> { @Autowired @@ -53,6 +52,11 @@ class BDZipManager( @Lazy private lateinit var fileReferenceClient: FileReferenceClient + @Autowired + @Lazy + private lateinit var storageService: StorageService + + @Autowired @Lazy private lateinit var compressFileRepository: CompressFileRepository diff --git a/src/backend/ddc/biz-ddc/src/main/kotlin/com/tencent/bkrepo/ddc/metrics/DdcMeterBinder.kt b/src/backend/ddc/biz-ddc/src/main/kotlin/com/tencent/bkrepo/ddc/metrics/DdcMeterBinder.kt index ca82e52e8f..843e0159de 100644 --- a/src/backend/ddc/biz-ddc/src/main/kotlin/com/tencent/bkrepo/ddc/metrics/DdcMeterBinder.kt +++ b/src/backend/ddc/biz-ddc/src/main/kotlin/com/tencent/bkrepo/ddc/metrics/DdcMeterBinder.kt @@ -34,7 +34,7 @@ import io.micrometer.core.instrument.binder.MeterBinder import org.springframework.stereotype.Component @Component -class DdcMeterBinder(private val registry: MeterRegistry) : MeterBinder { +class DdcMeterBinder : MeterBinder { /** * ref inline加载耗时 */ @@ -65,7 +65,11 @@ class DdcMeterBinder(private val registry: MeterRegistry) : MeterBinder { */ lateinit var legacyRefStoreTimer: Timer + private lateinit var registry: MeterRegistry + + override fun bindTo(registry: MeterRegistry) { + this.registry = registry refInlineLoadTimer = Timer .builder(DDC_REF_LOAD) .tag("inline", "true") diff --git a/src/backend/webhook/biz-webhook/src/main/kotlin/com/tencent/bkrepo/webhook/config/WebHookConsumerConfig.kt b/src/backend/webhook/biz-webhook/src/main/kotlin/com/tencent/bkrepo/webhook/config/WebHookConsumerConfig.kt index 69c3fb482b..2cfc9438c3 100644 --- a/src/backend/webhook/biz-webhook/src/main/kotlin/com/tencent/bkrepo/webhook/config/WebHookConsumerConfig.kt +++ b/src/backend/webhook/biz-webhook/src/main/kotlin/com/tencent/bkrepo/webhook/config/WebHookConsumerConfig.kt @@ -32,7 +32,7 @@ package com.tencent.bkrepo.webhook.config import com.tencent.bkrepo.common.artifact.event.base.ArtifactEvent -import com.tencent.bkrepo.webhook.executor.ArtifactEventConsumer +import com.tencent.bkrepo.webhook.executor.WebhookArtifactEventConsumer import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.messaging.Message @@ -43,10 +43,10 @@ class WebHookConsumerConfig { @Bean("artifactEventWebhook") fun artifactEventConsumer( - artifactEventConsumer: ArtifactEventConsumer + webhookArtifactEventConsumer: WebhookArtifactEventConsumer ): Consumer> { return Consumer { - artifactEventConsumer.accept(it) + webhookArtifactEventConsumer.accept(it) } } } \ No newline at end of file diff --git a/src/backend/webhook/biz-webhook/src/main/kotlin/com/tencent/bkrepo/webhook/executor/ArtifactEventConsumer.kt b/src/backend/webhook/biz-webhook/src/main/kotlin/com/tencent/bkrepo/webhook/executor/WebhookArtifactEventConsumer.kt similarity index 97% rename from src/backend/webhook/biz-webhook/src/main/kotlin/com/tencent/bkrepo/webhook/executor/ArtifactEventConsumer.kt rename to src/backend/webhook/biz-webhook/src/main/kotlin/com/tencent/bkrepo/webhook/executor/WebhookArtifactEventConsumer.kt index c452d61dc0..cf53776ed4 100644 --- a/src/backend/webhook/biz-webhook/src/main/kotlin/com/tencent/bkrepo/webhook/executor/ArtifactEventConsumer.kt +++ b/src/backend/webhook/biz-webhook/src/main/kotlin/com/tencent/bkrepo/webhook/executor/WebhookArtifactEventConsumer.kt @@ -49,7 +49,7 @@ import java.util.regex.Pattern * 事件消息消费者 */ @Component -class ArtifactEventConsumer( +class WebhookArtifactEventConsumer( private val webHookDao: WebHookDao, private val webHookExecutor: WebHookExecutor, private val webHookProperties: WebHookProperties @@ -140,6 +140,6 @@ class ArtifactEventConsumer( } companion object { - private val logger = LoggerFactory.getLogger(ArtifactEventConsumer::class.java) + private val logger = LoggerFactory.getLogger(WebhookArtifactEventConsumer::class.java) } }