use of org.commonjava.o11yphant.metrics.annotation.Measure in project indy by Commonjava.
the class IspnNotFoundCache method getMissing.
/**
* Get missing entries via pagination.
* @param location
* @param pageIndex starts from 0
* @param pageSize how many entries in each page
* @return
*/
@Override
@Measure
public Set<String> getMissing(Location location, int pageIndex, int pageSize) {
logger.debug("[NFC] getMissing for {} start, pageIndex: {}, pageSize: {}", location, pageIndex, pageSize);
Set<String> paths = new HashSet<>();
pageSize = getProperPageSize(pageSize);
long offset = pageIndex * pageSize;
Query query = queryFactory.from(NfcConcreteResourceWrapper.class).startOffset(offset).maxResults(pageSize).orderBy("path").having("location").eq(((KeyedLocation) location).getKey().toString()).toBuilder().build();
List<NfcConcreteResourceWrapper> matches = query.list();
matches.forEach(resource -> paths.add(resource.getPath()));
logger.debug("[NFC] getMissing complete, count: {}", matches.size());
return paths;
}
use of org.commonjava.o11yphant.metrics.annotation.Measure in project indy by Commonjava.
the class IspnNotFoundCache method getAllMissing.
@Override
@Measure
public Map<Location, Set<String>> getAllMissing(int pageIndex, int pageSize) {
logger.debug("[NFC] getAllMissing start, pageIndex: {}, pageSize: {}", pageIndex, pageSize);
Map<Location, Set<String>> result = new HashMap<>();
pageSize = getProperPageSize(pageSize);
long offset = pageIndex * pageSize;
Query query = queryFactory.from(NfcConcreteResourceWrapper.class).startOffset(offset).maxResults(pageSize).orderBy("location").orderBy("path").build();
List<NfcConcreteResourceWrapper> all = query.list();
for (NfcConcreteResourceWrapper entry : all) {
String loc = entry.getLocation();
StoreKey storeKey = fromString(loc);
Set<String> paths = result.computeIfAbsent(new NfcKeyedLocation(storeKey), k -> new HashSet<>());
paths.add(entry.getPath());
}
logger.debug("[NFC] getAllMissing complete, size: {}", all.size());
return result;
}
use of org.commonjava.o11yphant.metrics.annotation.Measure in project indy by Commonjava.
the class IspnNotFoundCache method getMissing.
@Override
@Measure
public Set<String> getMissing(final Location location) {
logger.debug("[NFC] getMissing for {} start", location);
Set<String> paths = new HashSet<>();
Query query = queryFactory.from(NfcConcreteResourceWrapper.class).maxResults(maxResultSetSize).having("location").eq(((KeyedLocation) location).getKey().toString()).toBuilder().build();
List<NfcConcreteResourceWrapper> matches = query.list();
matches.forEach(resource -> paths.add(resource.getPath()));
logger.debug("[NFC] getMissing complete, count: {}", matches.size());
return paths;
}
use of org.commonjava.o11yphant.metrics.annotation.Measure in project indy by Commonjava.
the class IspnNotFoundCache method clearMissing.
@Override
@Measure
public void clearMissing(final ConcreteResource resource) {
String key = getResourceKey(resource);
nfcCache.execute(cache -> cache.remove(key));
}
use of org.commonjava.o11yphant.metrics.annotation.Measure in project indy by Commonjava.
the class CassandraStoreDataManager method affectedBy.
@Override
@Measure
public Set<Group> affectedBy(Collection<StoreKey> keys) throws IndyDataException {
final Set<Group> result = new HashSet<>();
// use these to avoid recursion
final Set<StoreKey> processed = new HashSet<>();
final LinkedList<StoreKey> toProcess = new LinkedList<>(keys);
while (!toProcess.isEmpty()) {
StoreKey key = toProcess.removeFirst();
if (key == null) {
continue;
}
if (processed.add(key)) {
DtxAffectedStore affectedStore = storeQuery.getAffectedStore(key);
if (affectedStore == null) {
processed.add(key);
continue;
}
Set<StoreKey> affected = affectedStore.getAffectedStoreKeys();
if (affected != null) {
logger.debug("Get affectedByStores, key: {}, affected: {}", key, affected);
affected = affected.stream().filter(k -> k.getType() == group).collect(Collectors.toSet());
for (StoreKey gKey : affected) {
// avoid loading the ArtifactStore instance again and again
if (!processed.contains(gKey) && !toProcess.contains(gKey)) {
ArtifactStore store = getArtifactStoreInternal(gKey);
// if this group is disabled, we don't want to keep loading it again and again.
if (store.isDisabled()) {
processed.add(gKey);
} else {
// add the group to the toProcess list so we can find any result that might include it in their own membership
toProcess.addLast(gKey);
result.add((Group) store);
}
}
}
}
}
}
if (logger.isTraceEnabled()) {
logger.trace("Groups affected by {} are: {}", keys, result.stream().map(ArtifactStore::getKey).collect(Collectors.toSet()));
}
return filterAffectedGroups(result);
}
Aggregations