use of org.commonjava.o11yphant.metrics.annotation.Measure in project indy by Commonjava.
the class CassandraNotFoundCache method clearMissing.
@Override
@Measure
public void clearMissing(final Location location) {
StoreKey key = ((KeyedLocation) location).getKey();
BoundStatement bound = preparedDeleteByStore.bind(key.toString());
session.execute(bound);
clearInMemoryCache(location);
}
use of org.commonjava.o11yphant.metrics.annotation.Measure in project indy by Commonjava.
the class FoloRecordCache method recordArtifact.
/**
* Add a new artifact upload/download item to given affected store within a tracked-content record. If the tracked-content record doesn't exist,
* or doesn't contain the specified affected store, values will be created on-demand.
* @param entry The TrackedContentEntry which will be cached
* @return True if a new record was stored, otherwise false
*/
@Override
@Measure
public synchronized boolean recordArtifact(final TrackedContentEntry entry) throws FoloContentException, IndyWorkflowException {
if (sealedRecordCache.containsKey(entry.getTrackingKey())) {
throw new FoloContentException("Tracking record: {} is already sealed!", entry.getTrackingKey());
}
Logger logger = LoggerFactory.getLogger(getClass());
logger.debug("Adding tracking entry: {}", entry);
return inProgressRecordCache.executeCache((cache) -> {
TrackedContentEntry existing = cache.get(entry);
if (existing != null) {
existing.merge(entry);
cache.put(existing, existing);
} else {
cache.put(entry, entry);
}
return true;
});
}
use of org.commonjava.o11yphant.metrics.annotation.Measure in project indy by Commonjava.
the class PromotionManager method promoteToGroup.
@Measure
public GroupPromoteResult promoteToGroup(GroupPromoteRequest request, String user, String baseUrl) throws PromotionException, IndyWorkflowException {
RequestContextHelper.setContext(PROMOTION_ID, request.getPromotionId());
RequestContextHelper.setContext(PROMOTION_TYPE, GROUP_PROMOTION);
RequestContextHelper.setContext(PROMOTION_SOURCE, request.getSource().toString());
RequestContextHelper.setContext(PROMOTION_TARGET, request.getTargetKey().toString());
if (!storeManager.hasArtifactStore(request.getSource())) {
String error = String.format("Cannot promote from missing source: %s", request.getSource());
logger.warn(error);
return new GroupPromoteResult(request, error);
}
final StoreKey targetKey = getTargetKey(request.getTarget().getName(), request.getTarget().getPackageType());
if (!storeManager.hasArtifactStore(targetKey)) {
String error = String.format("No such target group: %s.", request.getTarget());
logger.warn(error);
return new GroupPromoteResult(request, error);
}
Future<GroupPromoteResult> future = submitGroupPromoteRequest(request, user, baseUrl);
if (request.isAsync()) {
return new GroupPromoteResult(request).accepted();
} else {
try {
return future.get();
} catch (InterruptedException | ExecutionException e) {
logger.error("Group promotion failed: " + request.getSource() + " -> " + request.getTargetKey(), e);
throw new PromotionException("Execution of group promotion failed.", e);
}
}
}
use of org.commonjava.o11yphant.metrics.annotation.Measure in project indy by Commonjava.
the class PromotionValidationTools method readLocalPom.
@Measure
public MavenPomView readLocalPom(final String path, final ValidationRequest request) throws IndyWorkflowException, GalleyMavenException {
ArtifactRef artifactRef = getArtifact(path);
if (artifactRef == null) {
throw new IndyWorkflowException("Invalid artifact path: %s. Could not parse ArtifactRef from path.", path);
}
Transfer transfer = retrieve(request.getSourceRepository(), path);
return pomReader.readLocalPom(artifactRef.asProjectVersionRef(), transfer, MavenPomView.ALL_PROFILES);
}
use of org.commonjava.o11yphant.metrics.annotation.Measure in project indy by Commonjava.
the class KojiBuildAuthority method isAuthorized.
@Measure
public boolean isAuthorized(String path, EventMetadata eventMetadata, ProjectRef ref, KojiBuildInfo build, KojiSessionInfo session, Map<Integer, KojiBuildArchiveCollection> seenBuildArchives) throws KojiClientException {
ArtifactStore authoritativeStore = getAuthoritativeStore();
if (authoritativeStore != null) {
KojiBuildArchiveCollection archiveCollection = seenBuildArchives.get(build.getId());
if (archiveCollection == null) {
List<KojiArchiveInfo> archiveList = kojiContentProvider.listArchivesForBuild(build.getId(), session);
archiveCollection = new KojiBuildArchiveCollection(build, archiveList);
seenBuildArchives.put(build.getId(), archiveCollection);
}
if (archiveCollection == null) {
throw new KojiClientException("Failed to retrieve archives for build: %s", build);
}
// @formatter:off
Predicate<KojiArchiveInfo> archiveInfoFilter = (archive) -> EXCLUDED_FILE_ENDINGS.stream().allMatch(ending -> !archive.getFilename().endsWith(ending));
List<KojiArchiveInfo> sortedArchives = archiveCollection.getArchives().stream().filter(archiveInfoFilter).sorted((a1, a2) -> {
TypePriority t1 = TypePriority.get(a1.getExtension());
TypePriority t2 = TypePriority.get(a2.getExtension());
return Integer.valueOf(t1.ordinal()).compareTo(t2.ordinal());
}).collect(Collectors.toList());
for (KojiArchiveInfo archive : sortedArchives) {
try {
if (isMavenArtifact(archive)) {
// skip non-Maven artifacts
continue;
}
if (containsPlaceholders(archive)) {
return false;
}
String artifactPath = ArtifactPathUtils.formatArtifactPath(archive.asArtifact(), typeMapper);
String md5 = checksumArtifact(authoritativeStore, artifactPath, eventMetadata);
if (isNotBlank(md5)) {
// FIXME: not sure if all koji archives are using md5 as checksum type for maven build
String kojiMd5 = archive.getChecksum();
Logger logger = LoggerFactory.getLogger(getClass());
logger.info("Checking checksum for {} (path: {}) in auth store {}, auth store checksum:{}, koji build check sum:{}", ref, path, authoritativeStore, md5, kojiMd5);
if (!md5.equals(kojiMd5)) {
// if checksum is not the same, it means the artifact in koji is DIFFERENT from the one in the authoritative store. Reject this.
return false;
}
}
} catch (Exception e) {
Logger logger = LoggerFactory.getLogger(getClass());
logger.error("SHOULD NEVER HAPPEN: Failed to transform artifact to path: " + e.getMessage(), e);
}
}
}
return true;
}
Aggregations