Note: The information on this page only applies when using Repository 3 with embedded OrientDB. The script was not tested with an external database such as PostgreSQL or H2.
If you encounter a performance related issue using Nexus Repository Manager 3, this article describes what information will be useful to report to Sonatype about your particular installation.
Component and Asset Counts Per Repository
The following Groovy script can be put into an Execute Script scheduled task. It will print component and asset counts to give us a representative size of your search indexes and database size.
Please provide the output of this script along with any performance issue you report.
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 = [:] repository.repositoryManager.browse().each { Repository repo ->
try { 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() result[repo.name] = [components: components, assets: assets]
} catch (Exception e) {
log.warn('Yikes: {}', e.toString())
} finally {
tx.close()
}
} def json = JsonOutput.toJson(result) log.info json return json
After this script runs, it will print a single log message in nexus.log that shows counts per repository - example:
2017-06-06 09:42:19,486-0300 INFO [quartz-4-thread-5] *SYSTEM org.sonatype.nexus.internal.script.ScriptTask - {"nuget.org-proxy":{"components":0,"assets":0},"maven-releases":{"components":0,"assets":0},"releases":{"components":0,"assets":0},"snapshots":{"components":0,"assets":0},"nuget-group":{"components":0,"assets":0},"maven-snapshots":{"components":0,"assets":0},"maven-central":{"components":0,"assets":2},"docker-hosted":{"components":0,"assets":0},"nuget-hosted":{"components":0,"assets":0},"maven-public":{"components":0,"assets":0},"raw-hosted":{"components":1,"assets":1}}