forked from TencentBlueKing/bk-repo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 优化系统GC功能 TencentBlueKing#1600 * feat: 归档服务支持异步任务 TencentBlueKing#1600 * feat: 支持任务可取消 TencentBlueKing#1600 * feat: 优化压缩文件引用逻辑 TencentBlueKing#1600 * feat: 优化GC相关job TencentBlueKing#1600 * feat: merge master TencentBlueKing#1600 * feat: 节点聚类分析时,增加采样调查 TencentBlueKing#1600 * feat: 优化job db查询 TencentBlueKing#1600
- Loading branch information
1 parent
7476d57
commit 8ab0821
Showing
51 changed files
with
580 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 11 additions & 1 deletion
12
...ive/biz-archive/src/main/kotlin/com/tencent/bkrepo/archive/config/ArchiveConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,18 @@ | ||
package com.tencent.bkrepo.archive.config | ||
|
||
import com.tencent.bkrepo.common.security.http.core.HttpAuthSecurity | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties | ||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
import org.springframework.context.annotation.Import | ||
|
||
@EnableConfigurationProperties(ArchiveProperties::class) | ||
@Import(ArchiveShutdownConfiguration::class) | ||
@Configuration | ||
class ArchiveConfiguration | ||
class ArchiveConfiguration { | ||
|
||
@Bean | ||
fun httpAuthSecurity(): HttpAuthSecurity { | ||
return HttpAuthSecurity().withPrefix("/archive") | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...archive/src/main/kotlin/com/tencent/bkrepo/archive/config/ArchiveShutdownConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.tencent.bkrepo.archive.config | ||
|
||
import com.tencent.bkrepo.archive.job.Cancellable | ||
import com.tencent.bkrepo.common.service.shutdown.ServiceShutdownHook | ||
import org.slf4j.LoggerFactory | ||
import org.springframework.beans.factory.ObjectProvider | ||
|
||
/** | ||
* 归档服务关机相关配置 | ||
* */ | ||
class ArchiveShutdownConfiguration(cancellable: ObjectProvider<Cancellable>) { | ||
|
||
init { | ||
ServiceShutdownHook.add { | ||
cancellable.stream().forEach { | ||
it.cancel() | ||
logger.info("Shutdown job[${it.javaClass.simpleName}].") | ||
} | ||
} | ||
} | ||
|
||
companion object { | ||
private val logger = LoggerFactory.getLogger(ArchiveShutdownConfiguration::class.java) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...chive/src/main/kotlin/com/tencent/bkrepo/archive/controller/user/SystemAdminController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.tencent.bkrepo.archive.controller.user | ||
|
||
import com.tencent.bkrepo.archive.service.SystemAdminService | ||
import com.tencent.bkrepo.common.security.permission.Principal | ||
import com.tencent.bkrepo.common.security.permission.PrincipalType | ||
import org.springframework.web.bind.annotation.PutMapping | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RequestParam | ||
import org.springframework.web.bind.annotation.RestController | ||
|
||
@Principal(PrincipalType.ADMIN) | ||
@RestController | ||
@RequestMapping("/api/archive/admin") | ||
class SystemAdminController( | ||
private val systemAdminService: SystemAdminService, | ||
) { | ||
@PutMapping("/stop") | ||
fun stop(@RequestParam jobName: String) { | ||
systemAdminService.stop(jobName) | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...hive/biz-archive/src/main/kotlin/com/tencent/bkrepo/archive/job/AsyncBaseJobSubscriber.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.tencent.bkrepo.archive.job | ||
|
||
import java.util.concurrent.ThreadPoolExecutor | ||
import java.util.concurrent.atomic.AtomicBoolean | ||
import java.util.concurrent.atomic.AtomicInteger | ||
import java.util.concurrent.locks.Condition | ||
import java.util.concurrent.locks.ReentrantLock | ||
|
||
open class AsyncBaseJobSubscriber<T>(val executor: ThreadPoolExecutor) : BaseJobSubscriber<T>() { | ||
|
||
private val lock: ReentrantLock = ReentrantLock() | ||
private val executeComplete: Condition = lock.newCondition() | ||
private val committedTask: AtomicInteger = AtomicInteger(0) | ||
private val commitComplete: AtomicBoolean = AtomicBoolean(false) | ||
|
||
override fun hookOnNext(value: T) { | ||
committedTask.incrementAndGet() | ||
executor.execute { | ||
try { | ||
super.hookOnNext(value) | ||
} finally { | ||
val committed = committedTask.decrementAndGet() | ||
if (commitComplete.get() && committed == 0) { | ||
lock.lock() | ||
try { | ||
executeComplete.signal() | ||
} finally { | ||
lock.unlock() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
override fun hookOnComplete() { | ||
commitComplete.set(true) | ||
if (committedTask.get() != 0) { | ||
lock.lock() | ||
try { | ||
executeComplete.await() | ||
} finally { | ||
lock.unlock() | ||
} | ||
} | ||
super.hookOnComplete() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...backend/archive/biz-archive/src/main/kotlin/com/tencent/bkrepo/archive/job/Cancellable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.tencent.bkrepo.archive.job | ||
|
||
/** | ||
* 可取消的操作 | ||
* */ | ||
interface Cancellable { | ||
/** | ||
* 取消 | ||
* */ | ||
fun cancel() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.