0

从 Nexus Repository Manager OSS 2.14.3 升级到 3.2.1 后,作为验证数据升级的一部分,我无法弄清楚如何计算存储在特定 blob 存储下的每个存储库中的人工制品数量。从界面手动计算它是不切实际的,因为我们在生产中拥有超过 10K 的人工制品。

计数 2.x 中的人工制品(总共包含 3 个人工制品)

[root@977d4b9b2a70 local]# ll sonatype-work/nexus/storage/releases/sample/1/1/1-1*zip        
-rw-r--r-- 1 root root 152818 May  2 06:38 sonatype-work/nexus/storage/releases/sample/1/1/1-1-1.zip
-rw-r--r-- 1 root root 145119 May  2 06:38 sonatype-work/nexus/storage/releases/sample/1/1/1-1-2.zip
-rw-r--r-- 1 root root   1152 May  2 06:38 sonatype-work/nexus/storage/releases/sample/1/1/1-1.zip
[root@977d4b9b2a70 local]# ll sonatype-work/nexus/storage/releases/sample/1/1/1-1*zip | wc -l
3
[root@977d4b9b2a70 local]#

计算 3.x 中的人工制品(从 2.x 升级相同的存储库内容后)

[root@977d4b9b2a70 local]# ll sonatype-work/nexus3/blobs/releases/content/ | wc -l
14
[root@977d4b9b2a70 local]# ll sonatype-work/nexus3/blobs/releases/content/        
total 52
drwxr-xr-x 2 root root 4096 May  2 06:42 tmp
drwxr-xr-x 3 root root 4096 May  2 06:42 vol-12
drwxr-xr-x 3 root root 4096 May  2 06:42 vol-13
drwxr-xr-x 4 root root 4096 May  2 06:42 vol-16
drwxr-xr-x 4 root root 4096 May  2 06:42 vol-22
drwxr-xr-x 3 root root 4096 May  2 06:42 vol-24
drwxr-xr-x 3 root root 4096 May  2 06:42 vol-31
drwxr-xr-x 4 root root 4096 May  2 06:42 vol-34
drwxr-xr-x 3 root root 4096 May  2 06:42 vol-36
drwxr-xr-x 3 root root 4096 May  2 06:42 vol-37
drwxr-xr-x 3 root root 4096 May  2 06:42 vol-41
drwxr-xr-x 4 root root 4096 May  2 06:42 vol-42
drwxr-xr-x 3 root root 4096 May  2 06:42 vol-43
[root@977d4b9b2a70 local]#

为什么后者显示计数为14。我知道从 3.x 开始,人工制品被存储为 BLOBS 而不是文件。

有没有其他方法可以使用终端计算 3.x 中每个 blob 存储下存储的人工制品数量。

4

1 回答 1

1

我发现了一个计算存储库中资产和组件数量的 groovy 脚本,您可以通过Execute Script task在 Nexus 3.x ui 中运行此脚本。

import org.sonatype.nexus.repository.Repository
import org.sonatype.nexus.repository.storage.Query
import org.sonatype.nexus.repository.storage.StorageFacet

import groovy.json.JsonOutput

def result = [:]

def totalComponents = 0
def totalAssets = 0

repository.repositoryManager.browse().each { Repository repo ->
  def tx = repo.facet(StorageFacet).txSupplier().get()
  tx.begin()
  def components = 
  tx.countComponents(Query.builder().where('1').eq(1).build(), [repo])
  def assets = tx.countAssets(Query.builder().where('1').eq(1).build(), 
                             [repo])
  tx.commit()
  totalComponents += components
  totalAssets += assets
  result[repo.name] = [components: components, assets: assets]
}

result["_totals"] = [components : totalComponents, assets : totalAssets]

def json = JsonOutput.toJson(result)
log.info json
return json
于 2017-05-09T16:40:06.207 回答