Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 增加目录统计 #1012 #1065

Merged
merged 43 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
31bd3c8
feat: v1 #1012
zacYL Aug 3, 2023
d683bc6
feat: 统计目录size大小 #1012
zacYL Aug 4, 2023
332c525
feat: 存储调整 #1012
zacYL Aug 4, 2023
23c9a85
feat: 数据刷新调整 #1012
zacYL Aug 4, 2023
db00a1d
feat: 数据刷新调整 #1012
zacYL Aug 6, 2023
58168ae
feat: 缓存数据存入调整 #1012
zacYL Aug 6, 2023
e2fbeca
feat: 目录节点大小统计调整 #1012
zacYL Aug 10, 2023
ee68fd7
feat: 目录统计表中增加节点数 #1012
zacYL Aug 10, 2023
7e87a09
feat: 增加统计以及下载接口 #1012
zacYL Aug 11, 2023
4c9f328
feat: 执行计划变更为每周6执行一次 #1012
zacYL Aug 14, 2023
23a52c6
feat: 修复目录层级不全导致数据不准确的问题 #1012
zacYL Aug 14, 2023
ecc02a6
feat: 修复目录层级不全导致数据不准确的问题 #1012
zacYL Aug 14, 2023
a9d1137
feat: 目录size存储回node表中 #1012
zacYL Aug 15, 2023
9158ef0
feat: 删除多余代码 #1012
zacYL Aug 15, 2023
82c6e82
feat: 删除多余代码 #1012
zacYL Aug 15, 2023
8a095e1
Merge branch 'issue_1012' of https://github.com/zacYL/bk-repo into is…
zacYL Aug 15, 2023
caf0b3d
feat: job增加回滚操作 #1012
zacYL Aug 16, 2023
4696c63
feat: 类名调整 #1012
zacYL Aug 16, 2023
4858bfc
feat: 转换报错修复 #1012
zacYL Aug 16, 2023
2141a57
feat: 修改时间不更新 #1012
zacYL Aug 16, 2023
058c515
feat: move节点更新逻辑调整 #1012
zacYL Aug 17, 2023
2a8f1c6
feat: move节点更新逻辑调整 #1012
zacYL Aug 17, 2023
9df76ed
feat: 没有根目录这个节点,所以忽略path为/的节点 #1012
zacYL Aug 17, 2023
13df45c
feat: 增加子job执行策略 #1012
zacYL Aug 17, 2023
093d21b
feat: 去除多余代码 #1012
zacYL Aug 17, 2023
f58e96f
feat: 将实时计算结果更新到db中 #1012
zacYL Aug 18, 2023
082d018
feat: 计算逻辑调整 #1012
zacYL Aug 18, 2023
edfbeea
feat: 测试用例调整 #1012
zacYL Aug 18, 2023
a528e19
feat: 目录统计缓存逻辑调整 #1012
zacYL Aug 18, 2023
1ceaf31
feat: 使用redis存储缓存记录 #1012
zacYL Aug 21, 2023
71cbe6d
feat: 修复ERR unknown command 'KEYS' #1012
zacYL Aug 21, 2023
886716a
feat: redis存储逻辑调整,避免使用keys或者scan命令报错问题 #1012
zacYL Aug 21, 2023
27e8d5c
feat: 代码调整 #1012
zacYL Aug 21, 2023
0390900
feat: 批量操作 #1012
zacYL Aug 21, 2023
d86cf3e
feat: redis key逻辑调整 #1012
zacYL Aug 21, 2023
53f8817
feat: redis存储逻辑调整;执行计划支持每天执行部分表 #1012
zacYL Aug 22, 2023
f22e1ba
feat: 配置调整 #1012
zacYL Aug 22, 2023
eb9d658
feat: 空列表判断 #1012
zacYL Aug 22, 2023
e6c4bf0
feat: 写redis前,先写内存缓存,内存缓存满后再更新到redis #1012
zacYL Aug 22, 2023
f777579
feat: nodenum取值调整 #1012
zacYL Aug 22, 2023
fa03f72
feat: redis设置值方式调整 #1012
zacYL Aug 22, 2023
242bf5b
feat: 存储数据读取redis调整 #1012
zacYL Aug 23, 2023
c12dbf8
feat: 新增节点下非目录节点数量字段 #1012
zacYL Aug 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
/*
* 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.analyst.utils

import com.alibaba.excel.EasyExcel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ const val PIPELINE = "pipeline"
*/
const val REPORT = "report"


/**
* 日志仓库
*/
const val LOG = "log"

/**
* 文件访问请求是否为直接下载
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,19 @@ object PathUtils {
return result
}

/**
* 获取当前路径的所有上级目录列表
*/
fun resolveAncestorFolder(fullPath: String): List<String> {
return resolveAncestor(fullPath).map {
if (it != ROOT) {
it.removeSuffix(StringPool.SLASH)
} else {
it
}
}
}

/**
* 根据fullPath解析文件名称,返回格式abc.txt
*
Expand Down
1 change: 1 addition & 0 deletions src/backend/job/biz-job/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ dependencies {
implementation(project(":common:common-security"))
implementation(project(":common:common-storage:storage-service"))
implementation(project(":common:common-stream"))
implementation(project(":common:common-redis"))
implementation(project(":repository:api-repository"))
implementation(project(":helm:api-helm"))
implementation(project(":oci:api-oci"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ const val CATEGORY = "category"
const val CREATED_DATE = "createdDate"
const val LAST_MODIFIED_DATE = "lastModifiedDate"
const val DELETED_DATE = "deleted"
const val FULLPATH = "fullPath"
const val PATH = "path"

/**
* 缓存类型
*/
const val REDIS_CACHE_TYPE = "redis"
const val MEMORY_CACHE_TYPE = "memory"

/**
* metrics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ abstract class CompositeMongoDbBatchJob<T>(
return CompositeJobContext(enabledChildJobs)
}

override fun onRunCollectionFinished(collectionName: String, context: CompositeJobContext<T>) {
context.childJobs.forEach {
logException { it.onRunCollectionFinished(collectionName, context.childContext(it.getJobName())) }
}
}

protected abstract fun createChildJobs(): List<ChildMongoDbBatchJob<T>>

@Suppress("TooGenericExceptionCaught")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ abstract class MongoDbBatchJob<Entity, Context : JobContext>(

abstract fun entityClass(): Class<Entity>


/**
* 表执行结束回调
* */
open fun onRunCollectionFinished(collectionName: String, context: Context) {}

private val batchSize: Int
get() = properties.batchSize

Expand Down Expand Up @@ -162,6 +168,7 @@ abstract class MongoDbBatchJob<Entity, Context : JobContext>(
} while (querySize == pageSize && isRunning())
}.apply {
val elapsedTime = HumanReadable.time(this)
onRunCollectionFinished(collectionName, context)
logger.info("Job[${getJobName()}]: collection $collectionName run completed,sum [$sum] elapse $elapsedTime")
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* 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.job.batch.context

import com.tencent.bkrepo.job.MEMORY_CACHE_TYPE
import com.tencent.bkrepo.job.batch.base.ChildJobContext
import com.tencent.bkrepo.job.batch.base.JobContext
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.atomic.LongAdder

class FolderChildContext(
parentContent: JobContext,
// 是否执行任务
var runFlag: Boolean = false,
// 缓存类型redis和内存:数据量级大的建议使用redis
var cacheType: String = MEMORY_CACHE_TYPE,
// 表对应项目记录: 主要用于redis缓存生成key使用
var projectMap: ConcurrentHashMap<String, MutableSet<String>> = ConcurrentHashMap(),
// 用于内存缓存下存储目录统计信息
var folderCache: ConcurrentHashMap<String, FolderMetrics> = ConcurrentHashMap()
) : ChildJobContext(parentContent) {

data class FolderMetrics(
var nodeNum: LongAdder = LongAdder(),
var capSize: LongAdder = LongAdder()
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ class ProjectRepoChildContext(
.storageCredentials
?.key ?: "default"
val repo = repoMetrics.getOrPut(row.repoName) { RepoMetrics(row.repoName, credentialsKey) }
repo.size.add(row.size)
if (!row.folder) {
repo.size.add(row.size)
}
repo.num.increment()
repo.addFolderMetrics(row)
repo.addExtensionMetrics(row)
Expand Down Expand Up @@ -94,7 +96,9 @@ class ProjectRepoChildContext(
}
val metric = folderMetrics.getOrPut(firstLevelPath) { FolderMetric(firstLevelPath) }
metric.nodeNum.increment()
metric.capSize.add(row.size)
if (!row.folder) {
metric.capSize.add(row.size)
}
}

fun addExtensionMetrics(row: NodeStatCompositeMongoDbBatchJob.Node) {
Expand Down
Loading
Loading