Skip to content

Commit

Permalink
feat: 解决单体类加载冲突TencentBlueKing#2461
Browse files Browse the repository at this point in the history
* feat: 解决单体类加载冲突TencentBlueKing#2461

* feat: 解决DdcMeterBinder循环依赖TencentBlueKing#2461

* feat: 解决BDZipManager循环依赖TencentBlueKing#2461

* feat: 解决循环依赖TencentBlueKing#2461

* feat: 解决单体类加载报错TencentBlueKing#2461
  • Loading branch information
zacYL committed Aug 6, 2024
1 parent 1e18e8f commit 78ade12
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -91,10 +91,10 @@ class ScannerConfiguration {

@Bean("scanEventConsumer")
fun scanEventConsumer(
scanEventConsumer: ScanEventConsumer
analystScanEventConsumer: AnalystScanEventConsumer
): Consumer<ArtifactEvent> {
return Consumer {
scanEventConsumer.accept(it)
analystScanEventConsumer.accept(it)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -287,6 +287,6 @@ class ScanEventConsumer(
}

companion object {
private val logger = LoggerFactory.getLogger(ScanEventConsumer::class.java)
private val logger = LoggerFactory.getLogger(AnalystScanEventConsumer::class.java)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import java.util.function.Function
class ArchiveManager(
private val archiveProperties: ArchiveProperties,
private val fileProvider: PriorityFileProvider,
private val storageService: StorageService,
) : Function<TArchiveFile, Mono<TaskResult>> {
@Autowired
@Lazy
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<TCompressFile, Mono<TaskResult>> {
@Autowired
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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加载耗时
*/
Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -43,10 +43,10 @@ class WebHookConsumerConfig {

@Bean("artifactEventWebhook")
fun artifactEventConsumer(
artifactEventConsumer: ArtifactEventConsumer
webhookArtifactEventConsumer: WebhookArtifactEventConsumer
): Consumer<Message<ArtifactEvent>> {
return Consumer {
artifactEventConsumer.accept(it)
webhookArtifactEventConsumer.accept(it)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -140,6 +140,6 @@ class ArtifactEventConsumer(
}

companion object {
private val logger = LoggerFactory.getLogger(ArtifactEventConsumer::class.java)
private val logger = LoggerFactory.getLogger(WebhookArtifactEventConsumer::class.java)
}
}

0 comments on commit 78ade12

Please sign in to comment.