0

After upgrading from Nexus Repository Manager OSS 2.14.3 to 3.2.1 I'm not able to figure out how to count the number of artefacts in each repository stored under specific blob store as part of verifying the data upgrade. Counting it manually from the interface isn't practical as we have more than 10K artefacts in the production.

Counting artefacts in 2.x (Contains 3 artefacts in total)

[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]#

Counting artefacts in 3.x (After upgrading the same repository contents from 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]#

Why is the later showing the count as 14. I understand that from 3.x onwards the artefacts are getting stored as BLOBS instead of files.

Is there any other way to figure out the number of artefacts stored under each blob store in 3.x using terminal.

Sudheesh.M.S
  • 498
  • 1
  • 7
  • 13

1 Answers1

1

I found a groovy script that count the number of assets and components in a repositroy, you can run this script via Execute Script task in 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
Ron Badur
  • 1,873
  • 2
  • 15
  • 34