Search in sources :

Example 1 with ConcurrentHashSet

use of org.infinispan.commons.util.concurrent.ConcurrentHashSet in project indy by Commonjava.

the class KojiMavenMetadataProvider method executeKojiMetadataLookup.

@Measure
private Metadata executeKojiMetadataLookup(ProjectRef ga, String path) throws KojiClientException, IndyWorkflowException {
    Logger logger = LoggerFactory.getLogger(getClass());
    // short-term caches to help improve performance a bit by avoiding xml-rpc calls.
    List<KojiArchiveInfo> archives = kojiContentProvider.listArchivesMatching(ga, null);
    Map<Integer, KojiBuildArchiveCollection> seenBuildArchives = new ConcurrentHashMap<>();
    Set<Integer> seenBuilds = new ConcurrentHashSet<>();
    DrainingExecutorCompletionService<SingleVersion> svc = new DrainingExecutorCompletionService<>(kojiMDService);
    detectOverloadVoid(() -> {
        for (KojiArchiveInfo archive : archives) {
            svc.submit(archiveScanner(path, ga, archive, seenBuilds, seenBuildArchives));
        }
    });
    Set<SingleVersion> versions = new ConcurrentHashSet<>();
    try {
        svc.drain(v -> {
            if (v != null) {
                versions.add(v);
            }
        });
    } catch (InterruptedException | ExecutionException e) {
        logger.warn("Failed to scan for Koji metadata related to: " + ga, e);
    }
    if (versions.isEmpty()) {
        logger.debug("No versions found in Koji builds for metadata: {}", path);
        return null;
    }
    List<SingleVersion> sortedVersions = new ArrayList<>(versions);
    Collections.sort(sortedVersions);
    Metadata md = new Metadata();
    md.setGroupId(ga.getGroupId());
    md.setArtifactId(ga.getArtifactId());
    Versioning versioning = new Versioning();
    versioning.setRelease(sortedVersions.get(versions.size() - 1).renderStandard());
    versioning.setLatest(sortedVersions.get(versions.size() - 1).renderStandard());
    versioning.setVersions(sortedVersions.stream().map(SingleVersion::renderStandard).collect(Collectors.toList()));
    Date lastUpdated = Calendar.getInstance(TimeZone.getTimeZone("UTC")).getTime();
    versioning.setLastUpdated(new SimpleDateFormat(LAST_UPDATED_FORMAT).format(lastUpdated));
    md.setVersioning(versioning);
    return md;
}
Also used : ArrayList(java.util.ArrayList) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Metadata(org.apache.maven.artifact.repository.metadata.Metadata) Logger(org.slf4j.Logger) KojiArchiveInfo(com.redhat.red.build.koji.model.xmlrpc.KojiArchiveInfo) Date(java.util.Date) DrainingExecutorCompletionService(org.commonjava.cdi.util.weft.DrainingExecutorCompletionService) Versioning(org.apache.maven.artifact.repository.metadata.Versioning) KojiBuildArchiveCollection(com.redhat.red.build.koji.model.xmlrpc.KojiBuildArchiveCollection) ConcurrentHashSet(org.infinispan.commons.util.concurrent.ConcurrentHashSet) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) SingleVersion(org.commonjava.atlas.maven.ident.version.SingleVersion) ExecutionException(java.util.concurrent.ExecutionException) SimpleDateFormat(java.text.SimpleDateFormat) Measure(org.commonjava.o11yphant.metrics.annotation.Measure)

Aggregations

KojiArchiveInfo (com.redhat.red.build.koji.model.xmlrpc.KojiArchiveInfo)1 KojiBuildArchiveCollection (com.redhat.red.build.koji.model.xmlrpc.KojiBuildArchiveCollection)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ExecutionException (java.util.concurrent.ExecutionException)1 Metadata (org.apache.maven.artifact.repository.metadata.Metadata)1 Versioning (org.apache.maven.artifact.repository.metadata.Versioning)1 SingleVersion (org.commonjava.atlas.maven.ident.version.SingleVersion)1 DrainingExecutorCompletionService (org.commonjava.cdi.util.weft.DrainingExecutorCompletionService)1 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)1 Measure (org.commonjava.o11yphant.metrics.annotation.Measure)1 ConcurrentHashSet (org.infinispan.commons.util.concurrent.ConcurrentHashSet)1 Logger (org.slf4j.Logger)1