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;
}
Aggregations